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
This commit is contained in:
Carlos Martín Nieto 2014-01-24 11:25:39 +01:00
parent 500a6793c4
commit 5410128187
3 changed files with 16 additions and 6 deletions

View File

@ -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}
};

View File

@ -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):

View File

@ -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))