Rev 77: Handle NULL_REVISION in get_parent_map. in http://people.samba.org/bzr/jelmer/bzr-git/trunk

Jelmer Vernooij jelmer at samba.org
Sat Jul 26 17:27:49 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-git/trunk

------------------------------------------------------------
revno: 77
revision-id: jelmer at samba.org-20080726161053-msgl8n8xn5w12b6b
parent: jelmer at samba.org-20080726160902-xj11yfyxs4u5eart
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sat 2008-07-26 18:10:53 +0200
message:
  Handle NULL_REVISION in get_parent_map.
modified:
  git_repository.py              git_repository.py-20071108234408-ygidvy5hviixghsd-2
  tests/test_git_repository.py   test_git_repository.-20071108234408-ygidvy5hviixghsd-5
=== modified file 'git_repository.py'
--- a/git_repository.py	2008-07-26 16:08:46 +0000
+++ b/git_repository.py	2008-07-26 16:10:53 +0000
@@ -126,8 +126,11 @@
     def get_parent_map(self, revision_ids):
         ret = {}
         for revid in revision_ids:
-            commit = self._git.commit(ids.convert_revision_id_bzr_to_git(revid))
-            ret[revid] = tuple([ids.convert_revision_id_git_to_bzr(p.id) for p in commit.parents])
+            if revid == revision.NULL_REVISION:
+                ret[revid] = ()
+            else:
+                commit = self._git.commit(ids.convert_revision_id_bzr_to_git(revid))
+                ret[revid] = tuple([ids.convert_revision_id_git_to_bzr(p.id) for p in commit.parents])
         return ret
 
     def get_revision(self, revision_id):

=== modified file 'tests/test_git_repository.py'
--- a/tests/test_git_repository.py	2008-07-26 16:08:53 +0000
+++ b/tests/test_git_repository.py	2008-07-26 16:10:53 +0000
@@ -152,6 +152,10 @@
         self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
         self.assertIsNullInventory(tree.inventory)
 
+    def test_get_parent_map_null(self):
+        self.assertEquals({revision.NULL_REVISION: ()}, 
+                           self.git_repo.get_parent_map([revision.NULL_REVISION]))
+
 
 class GitRepositoryFormat(tests.TestCase):
 




More information about the bazaar-commits mailing list