Prechádzať zdrojové kódy

Turn Commit.parents into a property, for compatibility with python-git.

Jelmer Vernooij 16 rokov pred
rodič
commit
acaee12556
3 zmenil súbory, kde vykonal 5 pridanie a 4 odobranie
  1. 1 0
      dulwich/objects.py
  2. 1 1
      dulwich/repo.py
  3. 3 3
      dulwich/tests/test_objects.py

+ 1 - 0
dulwich/objects.py

@@ -347,6 +347,7 @@ class Commit(ShaFile):
     """Returns the tree that is the state of this commit"""
     return self._tree
 
+  @property
   def parents(self):
     """Return a list of parents of this commit."""
     return self._parents

+ 1 - 1
dulwich/repo.py

@@ -162,7 +162,7 @@ class Repo(object):
           break
         i += 1
       history.insert(i, commit)
-      parents = commit.parents()
+      parents = commit.parents
       pending_commits += parents
     history.reverse()
     return history

+ 3 - 3
dulwich/tests/test_objects.py

@@ -83,7 +83,7 @@ class BlobReadTests(unittest.TestCase):
     sha = '60dacdc733de308bb77bb76ce0fb0f9b44c9769e'
     c = self.commit(sha)
     self.assertEqual(c.tree(), tree_sha)
-    self.assertEqual(c.parents(), ['0d89f20333fbb1d2f3a94da77f4981373d8f4310'])
+    self.assertEqual(c.parents, ['0d89f20333fbb1d2f3a94da77f4981373d8f4310'])
     self.assertEqual(c.author(),
         'James Westby <jw+debian@jameswestby.net>')
     self.assertEqual(c.committer(),
@@ -95,7 +95,7 @@ class BlobReadTests(unittest.TestCase):
     sha = '0d89f20333fbb1d2f3a94da77f4981373d8f4310'
     c = self.commit(sha)
     self.assertEqual(c.tree(), '90182552c4a85a45ec2a835cadc3451bebdfe870')
-    self.assertEqual(c.parents(), [])
+    self.assertEqual(c.parents, [])
     self.assertEqual(c.author(),
         'James Westby <jw+debian@jameswestby.net>')
     self.assertEqual(c.committer(),
@@ -107,7 +107,7 @@ class BlobReadTests(unittest.TestCase):
     sha = '5dac377bdded4c9aeb8dff595f0faeebcc8498cc'
     c = self.commit(sha)
     self.assertEqual(c.tree(), 'd80c186a03f423a81b39df39dc87fd269736ca86')
-    self.assertEqual(c.parents(), ['ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd',
+    self.assertEqual(c.parents, ['ab64bbdcc51b170d21588e5c5d391ee5c0c96dfd',
                                    '4cffe90e0a41ad3f5190079d7c8f036bde29cbe6'])
     self.assertEqual(c.author(),
         'James Westby <jw+debian@jameswestby.net>')