diff --git a/README.rst b/README.rst index 5d116a7..53d69ab 100644 --- a/README.rst +++ b/README.rst @@ -79,6 +79,43 @@ Authors Changelog ============== +0.20.2 (2014-02-XX) +------------------- + +- New ``Blob.diff(...)`` and ``Blob.diff_to_buffer(...)`` + `#307 `_ + +- New ``Repository.default_signature`` + `#310 `_ + +- New ``Commit.tree_id`` and ``Commit.parent_ids`` + `#730 `_ + + +- New rich comparison between tree entries +- New ``Config`` iterator replaces ``Config.foreach`` +- New type ``Refspec`` +- New ``Remote.push_url`` +- New ``Remote.add_push`` and ``Remote.add_fetch`` +- New ``Remote.fetch_refspecs`` replaces ``Remote.get_fetch_refspecs()`` and + ``Remote.set_fetch_refspecs(...)`` +- New ``Remote.push_refspecs`` replaces ``Remote.get_push_refspecs()`` and + ``Remote.set_push_refspecs(...)`` +- Now *path* in ``Tree`` works +- New ``str(Oid)`` deprecates ``Oid.hex`` +- New ``Object.id`` deprecates ``Object.oid`` +- New ``TreeEntry.id`` deprecates ``TreeEntry.oid`` +- New ``Remote.progress``, ``Remote.transfer_progress`` and + ``Remote.update_tips`` +- New type ``TransferProgress`` +- Now possible to create ``IndexEntry(...)`` +- Now ``IndexEntry.path``, ``IndexEntry.oid`` and ``IndexEntry.mode`` are + writable +- Now ``Index.add(...)`` accepts an ``IndexEntry`` too +- Now ``Index.write_tree(...)`` is able to write to a different repository +- Support pypy + + 0.20.1 (2013-12-24) ------------------- @@ -117,18 +154,10 @@ Changelog - Upgrade to libgit2 v0.20.0: `#288 `_ - Rename ``Repository.head_is_orphaned`` to ``Repository.head_is_unborn`` +- New ``Repository.head_is_unborn`` replaces ``Repository.head_is_orphaned`` - Prototype of ``pygit2.clone_repository(...)`` changed:: - - # Before - pygit2.clone_repository(url, path, bare=False, remote_name='origin', - push_url=None, fetch_spec=None, push_spec=None, - checkout_branch=None) - - # Now - pygit2.clone_repository(url, path, bare=False, ignore_cert_errors=False, - remote_name='origin', checkout_branch=None) +- Changed ``pygit2.clone_repository(...)``. Drop ``push_url``, ``fetch_spec`` + and ``push_spec`` parameters. Add ``ignore_cert_errors``. - New ``Patch.additions`` and ``Patch.deletions``: `#275 `_ diff --git a/docs/config.rst b/docs/config.rst index ef3a1a5..e9b5c64 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -14,13 +14,12 @@ The Config type .. automethod:: pygit2.Config.get_multivar .. automethod:: pygit2.Config.set_multivar +.. method:: for (name, value) in Config + + The :class:`Config` class has an iterator which can be used to loop + through all the entries in the configuration. Each element is a tuple + containing the name and the value of each configuration variable. Be + aware that this may return multiple versions of each entry if they are + set multiple times in the configuration files. + The :class:`Config` Mapping interface. - -Iterator -========= - -The :class:`Config` class has an iterator which can be used to loop -through all the entries in the configuration. Each element is a tuple -containing the name and the value of each configuration variable. Be -aware that this may return multiple versions of each entry if they are -set multiple times in the configuration files. diff --git a/docs/objects.rst b/docs/objects.rst index 4c868c9..432481b 100644 --- a/docs/objects.rst +++ b/docs/objects.rst @@ -79,8 +79,6 @@ New objects are created using an specific API we will see later. This is the common interface for all Git objects: .. autoattribute:: pygit2.Object.id -.. autoattribute:: pygit2.Object.oid -.. autoattribute:: pygit2.Object.hex .. autoattribute:: pygit2.Object.type .. automethod:: pygit2.Object.read_raw @@ -112,6 +110,9 @@ This is their API: .. autoattribute:: pygit2.Blob.is_binary +.. automethod:: pygit2.Blob.diff +.. automethod:: pygit2.Blob.diff_to_buffer + Creating blobs -------------- @@ -172,11 +173,12 @@ Tree entries .. autoattribute:: pygit2.TreeEntry.name .. autoattribute:: pygit2.TreeEntry.id -.. autoattribute:: pygit2.TreeEntry.oid .. autoattribute:: pygit2.TreeEntry.hex .. autoattribute:: pygit2.TreeEntry.filemode -:class:`TreeEntry` supports comparison against other tree entries. +.. method:: cmp(TreeEntry, TreeEntry) + + Rich comparison between tree entries. Example:: diff --git a/docs/oid.rst b/docs/oid.rst index c01e1af..66adcdb 100644 --- a/docs/oid.rst +++ b/docs/oid.rst @@ -65,7 +65,7 @@ And the other way around, from an Oid object we can get the hexadecimal and raw forms. You can use the built-in `str()` (or `unicode()` in python 2) to get the hexadecimal representation of the Oid. -.. autoattribute:: pygit2.Oid.hex +.. automethod:: str(pygit2.Oid) .. autoattribute:: pygit2.Oid.raw The Oid type supports: diff --git a/docs/remotes.rst b/docs/remotes.rst index e7c5129..f77bd73 100644 --- a/docs/remotes.rst +++ b/docs/remotes.rst @@ -19,14 +19,12 @@ The Remote type .. autoattribute:: pygit2.Remote.progress .. autoattribute:: pygit2.Remote.transfer_progress .. autoattribute:: pygit2.Remote.update_tips -.. automethod:: pygit2.Remote.get_push_refspecs -.. automethod:: pygit2.Remote.get_fetch_refspecs -.. automethod:: pygit2.Remote.set_push_refspecs -.. automethod:: pygit2.Remote.set_fetch_refspecs .. automethod:: pygit2.Remote.get_refspec .. automethod:: pygit2.Remote.fetch .. automethod:: pygit2.Remote.push .. automethod:: pygit2.Remote.save +.. automethod:: pygit2.Remote.add_push +.. automethod:: pygit2.Remote.add_fetch The TransferProgress type =========================== diff --git a/src/remote.c b/src/remote.c index 3f2388c..63d11c8 100644 --- a/src/remote.c +++ b/src/remote.c @@ -43,9 +43,9 @@ extern PyTypeObject TransferProgressType; Refspec * wrap_refspec(const Remote *owner, const git_refspec *refspec) { - Refspec *spec; + Refspec *spec; - spec = PyObject_New(Refspec, &RefspecType); + spec = PyObject_New(Refspec, &RefspecType); if (!spec) return NULL; @@ -258,7 +258,7 @@ PyDoc_STRVAR(Refspec__doc__, "Refspec object."); PyTypeObject RefspecType = { PyVarObject_HEAD_INIT(NULL, 0) "_pygit2.Refspec", /* tp_name */ - sizeof(Refspec), /* tp_basicsize */ + sizeof(Refspec), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)Refspec_dealloc, /* tp_dealloc */ 0, /* tp_print */ @@ -331,7 +331,7 @@ PyMemberDef TransferProgress_members[] = { RMEMBER(TransferProgress, indexed_deltas, T_UINT, "Deltas which have been indexed"), /* FIXME: technically this is unsigned, but there's no value for size_t here. */ RMEMBER(TransferProgress, received_bytes, T_PYSSIZET, "Number of bytes received up to now"), - {NULL}, + {NULL}, }; PyDoc_STRVAR(TransferProgress__doc__, "Progress downloading and indexing data during a fetch"); @@ -639,59 +639,6 @@ Remote_push_refspecs__set__(Remote *self, PyObject *py_list) return 0; } -PyDoc_STRVAR(Remote_get_fetch_refspecs__doc__, - "Fetch refspecs.\n" - "This function is deprecated, please use the fetch_refspecs attribute" - "\n"); - - -PyObject * -Remote_get_fetch_refspecs(Remote *self) -{ - return Remote_fetch_refspecs__get__(self); -} - - -PyDoc_STRVAR(Remote_get_push_refspecs__doc__, "Push refspecs"); - - -PyObject * -Remote_get_push_refspecs(Remote *self) -{ - return Remote_push_refspecs__get__(self); -} - -PyDoc_STRVAR(Remote_set_fetch_refspecs__doc__, - "set_fetch_refspecs([str])\n" - "This function is deprecated, please use the push_refspecs attribute" - "\n"); - - -PyObject * -Remote_set_fetch_refspecs(Remote *self, PyObject *args) -{ - if (Remote_fetch_refspecs__set__(self, args) < 0) - return NULL; - - Py_RETURN_NONE; -} - - -PyDoc_STRVAR(Remote_set_push_refspecs__doc__, - "set_push_refspecs([str])\n" - "This function is deprecated, please use the push_refspecs attribute" - "\n"); - - -PyObject * -Remote_set_push_refspecs(Remote *self, PyObject *args) -{ - if (Remote_push_refspecs__set__(self, args) < 0) - return NULL; - - Py_RETURN_NONE; -} - PyDoc_STRVAR(Remote_url__doc__, "Url of the remote"); @@ -699,7 +646,7 @@ PyDoc_STRVAR(Remote_url__doc__, "Url of the remote"); PyObject * Remote_url__get__(Remote *self) { - const char *url; + const char *url; url = git_remote_url(self->remote); if (!url) @@ -735,7 +682,7 @@ PyDoc_STRVAR(Remote_push_url__doc__, "Push url of the remote"); PyObject * Remote_push_url__get__(Remote *self) { - const char *url; + const char *url; url = git_remote_pushurl(self->remote); if (!url) @@ -976,10 +923,6 @@ PyMethodDef Remote_methods[] = { METHOD(Remote, push, METH_VARARGS), METHOD(Remote, add_push, METH_VARARGS), METHOD(Remote, add_fetch, METH_VARARGS), - METHOD(Remote, get_fetch_refspecs, METH_NOARGS), - METHOD(Remote, set_fetch_refspecs, METH_O), - METHOD(Remote, get_push_refspecs, METH_NOARGS), - METHOD(Remote, set_push_refspecs, METH_O), {NULL} }; diff --git a/src/tree.c b/src/tree.c index bd2c087..dae77dc 100644 --- a/src/tree.c +++ b/src/tree.c @@ -201,9 +201,11 @@ Tree_len(Tree *self) int Tree_contains(Tree *self, PyObject *py_name) { - int err; + int err; git_tree_entry *entry; - char *name = py_path_to_c_str(py_name); + char *name; + + name = py_path_to_c_str(py_name); if (name == NULL) return -1; diff --git a/test/test_remote.py b/test/test_remote.py index ce146e0..d98bfc5 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -92,53 +92,49 @@ class RepositoryTest(utils.RepoTestCase): self.assertEqual(True, refspec.force) self.assertEqual(ORIGIN_REFSPEC, refspec.string) - self.assertEqual(list, type(remote.get_fetch_refspecs())) - self.assertEqual(1, len(remote.get_fetch_refspecs())) - self.assertEqual(ORIGIN_REFSPEC, remote.get_fetch_refspecs()[0]) + self.assertEqual(list, type(remote.fetch_refspecs)) + self.assertEqual(1, len(remote.fetch_refspecs)) + self.assertEqual(ORIGIN_REFSPEC, remote.fetch_refspecs[0]) self.assertTrue(refspec.src_matches('refs/heads/master')) self.assertTrue(refspec.dst_matches('refs/remotes/origin/master')) self.assertEqual('refs/remotes/origin/master', refspec.transform('refs/heads/master')) self.assertEqual('refs/heads/master', refspec.rtransform('refs/remotes/origin/master')) - self.assertEqual(list, type(remote.get_push_refspecs())) - self.assertEqual(0, len(remote.get_push_refspecs())) + self.assertEqual(list, type(remote.push_refspecs)) + self.assertEqual(0, len(remote.push_refspecs)) push_specs = remote.push_refspecs self.assertEqual(list, type(push_specs)) self.assertEqual(0, len(push_specs)) - remote.set_fetch_refspecs(['+refs/*:refs/remotes/*']) - self.assertEqual('+refs/*:refs/remotes/*', - remote.get_fetch_refspecs()[0]) + remote.fetch_refspecs = ['+refs/*:refs/remotes/*'] + self.assertEqual('+refs/*:refs/remotes/*', remote.fetch_refspecs[0]) fetch_specs = remote.fetch_refspecs self.assertEqual(list, type(fetch_specs)) self.assertEqual(1, len(fetch_specs)) self.assertEqual('+refs/*:refs/remotes/*', fetch_specs[0]) - remote.set_fetch_refspecs([ - '+refs/*:refs/remotes/*', - '+refs/test/*:refs/test/remotes/*' - ]) - self.assertEqual('+refs/*:refs/remotes/*', - remote.get_fetch_refspecs()[0]) + remote.fetch_refspecs = ['+refs/*:refs/remotes/*', + '+refs/test/*:refs/test/remotes/*'] + self.assertEqual('+refs/*:refs/remotes/*', remote.fetch_refspecs[0]) self.assertEqual('+refs/test/*:refs/test/remotes/*', - remote.get_fetch_refspecs()[1]) + remote.fetch_refspecs[1]) - remote.set_push_refspecs([ - '+refs/*:refs/remotes/*', - '+refs/test/*:refs/test/remotes/*' - ]) + remote.push_refspecs = ['+refs/*:refs/remotes/*', + '+refs/test/*:refs/test/remotes/*'] - self.assertRaises(TypeError, setattr, remote, 'push_refspecs', '+refs/*:refs/*') - self.assertRaises(TypeError, setattr, remote, 'fetch_refspecs', '+refs/*:refs/*') - self.assertRaises(TypeError, setattr, remote, 'fetch_refspecs', ['+refs/*:refs/*', 5]) + self.assertRaises(TypeError, setattr, remote, 'push_refspecs', + '+refs/*:refs/*') + self.assertRaises(TypeError, setattr, remote, 'fetch_refspecs', + '+refs/*:refs/*') + self.assertRaises(TypeError, setattr, remote, 'fetch_refspecs', + ['+refs/*:refs/*', 5]) - self.assertEqual('+refs/*:refs/remotes/*', - remote.get_push_refspecs()[0]) + self.assertEqual('+refs/*:refs/remotes/*', remote.push_refspecs[0]) self.assertEqual('+refs/test/*:refs/test/remotes/*', - remote.get_push_refspecs()[1]) + remote.push_refspecs[1]) def test_remote_list(self): @@ -169,10 +165,10 @@ class RepositoryTest(utils.RepoTestCase): remote = self.repo.create_remote('test_add_refspec', REMOTE_URL) remote.add_push('refs/heads/*:refs/heads/test_refspec/*') self.assertEqual('refs/heads/*:refs/heads/test_refspec/*', - remote.get_push_refspecs()[0]) + remote.push_refspecs[0]) remote.add_fetch('+refs/heads/*:refs/remotes/test_refspec/*') self.assertEqual('+refs/heads/*:refs/remotes/test_refspec/*', - remote.get_fetch_refspecs()[1]) + remote.fetch_refspecs[1]) def test_remote_callback_typecheck(self): remote = self.repo.remotes[0]