From 541012818750dc2a549028bf3b4c15a31729d242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 24 Jan 2014 11:25:39 +0100 Subject: [PATCH] TreeEntry: move to use 'id' attribute for the object's id Similar to the Object change, we should be using 'id' when referring to the target's id.x --- src/tree.c | 14 ++++++++++++-- test/test_tree.py | 6 +++--- test/test_treebuilder.py | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/tree.c b/src/tree.c index ca91cc0..bd2c087 100644 --- a/src/tree.c +++ b/src/tree.c @@ -67,10 +67,10 @@ TreeEntry_name__get__(TreeEntry *self) } -PyDoc_STRVAR(TreeEntry_oid__doc__, "Object id."); +PyDoc_STRVAR(TreeEntry_id__doc__, "Object id."); PyObject * -TreeEntry_oid__get__(TreeEntry *self) +TreeEntry_id__get__(TreeEntry *self) { const git_oid *oid; @@ -78,6 +78,15 @@ TreeEntry_oid__get__(TreeEntry *self) return git_oid_to_python(oid); } +PyDoc_STRVAR(TreeEntry_oid__doc__, "Object id.\n" + "This attribute is deprecated. Please use 'id'"); + +PyObject * +TreeEntry_oid__get__(TreeEntry *self) +{ + return TreeEntry_id__get__(self); +} + PyObject * TreeEntry_richcompare(PyObject *a, PyObject *b, int op) { @@ -133,6 +142,7 @@ PyGetSetDef TreeEntry_getseters[] = { GETTER(TreeEntry, filemode), GETTER(TreeEntry, name), GETTER(TreeEntry, oid), + GETTER(TreeEntry, id), GETTER(TreeEntry, hex), {NULL} }; diff --git a/test/test_tree.py b/test/test_tree.py index e5838ac..25ba7ed 100644 --- a/test/test_tree.py +++ b/test/test_tree.py @@ -77,7 +77,7 @@ class TreeTest(utils.BareRepoTestCase): subtree_entry = tree['c'] self.assertTreeEntryEqual(subtree_entry, SUBTREE_SHA, 'c', 0o0040000) - subtree = self.repo[subtree_entry.oid] + subtree = self.repo[subtree_entry.id] self.assertEqual(1, len(subtree)) sha = '297efb891a47de80be0cfe9c639e4b8c9b450989' self.assertTreeEntryEqual(subtree[0], sha, 'd', 0o0100644) @@ -100,8 +100,8 @@ class TreeTest(utils.BareRepoTestCase): self.assertEqual(x.filemode, 0o0100644) self.assertEqual(y.filemode, 0o0100755) - self.assertEqual(repo[x.oid].id, b0) - self.assertEqual(repo[y.oid].id, b1) + self.assertEqual(repo[x.id].id, b0) + self.assertEqual(repo[y.id].id, b1) def test_modify_tree(self): diff --git a/test/test_treebuilder.py b/test/test_treebuilder.py index c10c4f3..5c7fa67 100644 --- a/test/test_treebuilder.py +++ b/test/test_treebuilder.py @@ -68,7 +68,7 @@ class TreeBuilderTest(utils.BareRepoTestCase): name = entry.name self.assertTrue(bld.get(name) is None) bld.insert(name, entry.hex, entry.filemode) - self.assertEqual(bld.get(name).oid, entry.oid) + self.assertEqual(bld.get(name).id, entry.id) result = bld.write() self.assertEqual(len(bld), len(tree))