diff --git a/src/object.c b/src/object.c index 6e018e5..d608e0c 100644 --- a/src/object.c +++ b/src/object.c @@ -49,11 +49,11 @@ Object_dealloc(Object* self) } -PyDoc_STRVAR(Object_oid__doc__, +PyDoc_STRVAR(Object_id__doc__, "The object id, an instance of the Oid type."); PyObject * -Object_oid__get__(Object *self) +Object_id__get__(Object *self) { const git_oid *oid; @@ -63,10 +63,20 @@ Object_oid__get__(Object *self) return git_oid_to_python(oid); } +PyDoc_STRVAR(Object_oid__doc__, + "The object id, an instance of the Oid type.\n" + "This attribute is deprecated, please use 'id'\n"); + +PyObject * +Object_oid__get__(Object *self) +{ + return Object_id__get__(self); +} PyDoc_STRVAR(Object_hex__doc__, "Hexadecimal representation of the object id. This is a shortcut for\n" - "Object.oid.hex"); + "Object.oid.hex\n" + "This attribute is deprecated, please use 'id'\n"); PyObject * Object_hex__get__(Object *self) @@ -119,6 +129,7 @@ Object_read_raw(Object *self) PyGetSetDef Object_getseters[] = { GETTER(Object, oid), + GETTER(Object, id), GETTER(Object, hex), GETTER(Object, type), {NULL} diff --git a/test/test_blame.py b/test/test_blame.py index 39dcd86..1f90774 100644 --- a/test/test_blame.py +++ b/test/test_blame.py @@ -122,7 +122,7 @@ class BlameTest(utils.RepoTestCase): for rev, num_commits in revs: commit = repo.revparse_single(rev) - blame = repo.blame(PATH, newest_commit=commit.oid) + blame = repo.blame(PATH, newest_commit=commit.id) self.assertEqual(len(blame), num_commits) diff --git a/test/test_blob.py b/test/test_blob.py index 30faee4..cc6bc0a 100644 --- a/test/test_blob.py +++ b/test/test_blob.py @@ -50,7 +50,7 @@ class BlobTest(utils.RepoTestCase): def test_read_blob(self): blob = self.repo[BLOB_SHA] self.assertEqual(blob.hex, BLOB_SHA) - sha = blob.oid.hex + sha = blob.id.hex self.assertEqual(sha, BLOB_SHA) self.assertTrue(isinstance(blob, pygit2.Blob)) self.assertFalse(blob.is_binary) @@ -66,7 +66,7 @@ class BlobTest(utils.RepoTestCase): self.assertTrue(isinstance(blob, pygit2.Blob)) self.assertEqual(pygit2.GIT_OBJ_BLOB, blob.type) - self.assertEqual(blob_oid, blob.oid) + self.assertEqual(blob_oid, blob.id) self.assertEqual( utils.gen_blob_sha1(BLOB_NEW_CONTENT), blob_oid.hex) @@ -83,7 +83,7 @@ class BlobTest(utils.RepoTestCase): self.assertTrue(isinstance(blob, pygit2.Blob)) self.assertEqual(pygit2.GIT_OBJ_BLOB, blob.type) - self.assertEqual(blob_oid, blob.oid) + self.assertEqual(blob_oid, blob.id) self.assertEqual( utils.gen_blob_sha1(BLOB_FILE_CONTENT), blob_oid.hex) diff --git a/test/test_commit.py b/test/test_commit.py index a944c40..f462f78 100644 --- a/test/test_commit.py +++ b/test/test_commit.py @@ -42,11 +42,11 @@ class CommitTest(utils.BareRepoTestCase): def test_read_commit(self): commit = self.repo[COMMIT_SHA] - self.assertEqual(COMMIT_SHA, commit.hex) + self.assertEqual(COMMIT_SHA, str(commit.id)) parents = commit.parents self.assertEqual(1, len(parents)) self.assertEqual('c2792cfa289ae6321ecf2cd5806c2194b0fd070c', - parents[0].hex) + str(parents[0].id)) self.assertEqual(None, commit.message_encoding) self.assertEqual(('Second test data commit.\n\n' 'This commit has some additional text.\n'), @@ -62,7 +62,7 @@ class CommitTest(utils.BareRepoTestCase): Signature('Dave Borowitz', 'dborowitz@google.com', 1288477363, -420)) self.assertEqual( - '967fce8df97cc71722d3c2a5930ef3e6f1d27b12', commit.tree.hex) + '967fce8df97cc71722d3c2a5930ef3e6f1d27b12', str(commit.tree.id)) def test_new_commit(self): repo = self.repo diff --git a/test/test_refs.py b/test/test_refs.py index 347d381..bac89db 100644 --- a/test/test_refs.py +++ b/test/test_refs.py @@ -213,7 +213,7 @@ class ReferencesTest(utils.RepoTestCase): def test_get_object(self): repo = self.repo ref = repo.lookup_reference('refs/heads/master') - self.assertEqual(repo[ref.target].oid, ref.get_object().oid) + self.assertEqual(repo[ref.target].id, ref.get_object().id) if __name__ == '__main__': diff --git a/test/test_remote.py b/test/test_remote.py index 13fc93c..267c22e 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -199,27 +199,27 @@ class PushTestCase(unittest.TestCase): tip = self.clone[self.clone.head.target] oid = self.clone.create_commit( 'refs/heads/master', tip.author, tip.author, 'empty commit', - tip.tree.oid, [tip.oid] + tip.tree.id, [tip.id] ) self.remote.push('refs/heads/master') - self.assertEqual(self.origin[self.origin.head.target].oid, oid) + self.assertEqual(self.origin[self.origin.head.target].id, oid) def test_push_when_up_to_date_succeeds(self): self.remote.push('refs/heads/master') - origin_tip = self.origin[self.origin.head.target].oid - clone_tip = self.clone[self.clone.head.target].oid + origin_tip = self.origin[self.origin.head.target].id + clone_tip = self.clone[self.clone.head.target].id self.assertEqual(origin_tip, clone_tip) def test_push_non_fast_forward_commits_to_remote_fails(self): tip = self.origin[self.origin.head.target] oid = self.origin.create_commit( 'refs/heads/master', tip.author, tip.author, 'some commit', - tip.tree.oid, [tip.oid] + tip.tree.id, [tip.id] ) tip = self.clone[self.clone.head.target] oid = self.clone.create_commit( 'refs/heads/master', tip.author, tip.author, 'other commit', - tip.tree.oid, [tip.oid] + tip.tree.id, [tip.id] ) self.assertRaises(pygit2.GitError, self.remote.push, 'refs/heads/master') diff --git a/test/test_repository.py b/test/test_repository.py index 081e792..acd54e4 100644 --- a/test/test_repository.py +++ b/test/test_repository.py @@ -309,7 +309,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): def test_merge_uptodate(self): branch_head_hex = '5ebeeebb320790caf276b9fc8b24546d63316533' - branch_oid = self.repo.get(branch_head_hex).oid + branch_oid = self.repo.get(branch_head_hex).id merge_result = self.repo.merge(branch_oid) self.assertTrue(merge_result.is_uptodate) self.assertFalse(merge_result.is_fastforward) @@ -318,7 +318,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): def test_merge_fastforward(self): branch_head_hex = 'e97b4cfd5db0fb4ebabf4f203979ca4e5d1c7c87' - branch_oid = self.repo.get(branch_head_hex).oid + branch_oid = self.repo.get(branch_head_hex).id merge_result = self.repo.merge(branch_oid) self.assertFalse(merge_result.is_uptodate) self.assertTrue(merge_result.is_fastforward) @@ -329,7 +329,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): def test_merge_no_fastforward_no_conflicts(self): branch_head_hex = '03490f16b15a09913edb3a067a3dc67fbb8d41f1' - branch_oid = self.repo.get(branch_head_hex).oid + branch_oid = self.repo.get(branch_head_hex).id merge_result = self.repo.merge(branch_oid) self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_fastforward) @@ -345,7 +345,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): def test_merge_no_fastforward_conflicts(self): branch_head_hex = '1b2bae55ac95a4be3f8983b86cd579226d0eb247' - branch_oid = self.repo.get(branch_head_hex).oid + branch_oid = self.repo.get(branch_head_hex).id merge_result = self.repo.merge(branch_oid) self.assertFalse(merge_result.is_uptodate) self.assertFalse(merge_result.is_fastforward) @@ -365,7 +365,7 @@ class RepositoryTest_III(utils.RepoTestCaseForMerging): def test_merge_already_something_in_index(self): branch_head_hex = '03490f16b15a09913edb3a067a3dc67fbb8d41f1' - branch_oid = self.repo.get(branch_head_hex).oid + branch_oid = self.repo.get(branch_head_hex).id with open(os.path.join(self.repo.workdir, 'inindex.txt'), 'w') as f: f.write('new content') self.repo.index.add('inindex.txt') diff --git a/test/test_tag.py b/test/test_tag.py index 9530eb5..7acfd30 100644 --- a/test/test_tag.py +++ b/test/test_tag.py @@ -92,7 +92,7 @@ class TagTest(utils.BareRepoTestCase): def test_get_object(self): repo = self.repo tag = repo[TAG_SHA] - self.assertEqual(repo[tag.target].oid, tag.get_object().oid) + self.assertEqual(repo[tag.target].id, tag.get_object().id) if __name__ == '__main__': diff --git a/test/test_tree.py b/test/test_tree.py index 507a22b..e5838ac 100644 --- a/test/test_tree.py +++ b/test/test_tree.py @@ -100,8 +100,8 @@ class TreeTest(utils.BareRepoTestCase): self.assertEqual(x.filemode, 0o0100644) self.assertEqual(y.filemode, 0o0100755) - self.assertEqual(repo[x.oid].oid, b0) - self.assertEqual(repo[y.oid].oid, b1) + self.assertEqual(repo[x.oid].id, b0) + self.assertEqual(repo[y.oid].id, b1) def test_modify_tree(self): diff --git a/test/test_treebuilder.py b/test/test_treebuilder.py index 6b2d99a..c10c4f3 100644 --- a/test/test_treebuilder.py +++ b/test/test_treebuilder.py @@ -49,7 +49,7 @@ class TreeBuilderTest(utils.BareRepoTestCase): result = bld.write() self.assertEqual(len(bld), len(tree)) - self.assertEqual(tree.oid, result) + self.assertEqual(tree.id, result) def test_noop_treebuilder_from_tree(self): @@ -58,7 +58,7 @@ class TreeBuilderTest(utils.BareRepoTestCase): result = bld.write() self.assertEqual(len(bld), len(tree)) - self.assertEqual(tree.oid, result) + self.assertEqual(tree.id, result) def test_rebuild_treebuilder(self): @@ -72,7 +72,7 @@ class TreeBuilderTest(utils.BareRepoTestCase): result = bld.write() self.assertEqual(len(bld), len(tree)) - self.assertEqual(tree.oid, result) + self.assertEqual(tree.id, result) if __name__ == '__main__':