瀏覽代碼

Use property to access commit parents.

Jelmer Vernooij 15 年之前
父節點
當前提交
74e8924d98
共有 2 個文件被更改,包括 7 次插入9 次删除
  1. 5 5
      dulwich/server.py
  2. 2 4
      dulwich/tests/test_server.py

+ 5 - 5
dulwich/server.py

@@ -300,9 +300,9 @@ class UploadPackHandler(Handler):
 class ProtocolGraphWalker(object):
 class ProtocolGraphWalker(object):
     """A graph walker that knows the git protocol.
     """A graph walker that knows the git protocol.
 
 
-    As a graph walker, this class implements ack(), next(), and reset(). It also
-    contains some base methods for interacting with the wire and walking the
-    commit tree.
+    As a graph walker, this class implements ack(), next(), and reset(). It
+    also contains some base methods for interacting with the wire and walking
+    the commit tree.
 
 
     The work of determining which acks to send is passed on to the
     The work of determining which acks to send is passed on to the
     implementation instance stored in _impl. The reason for this is that we do
     implementation instance stored in _impl. The reason for this is that we do
@@ -452,10 +452,10 @@ class ProtocolGraphWalker(object):
             commit = pending.popleft()
             commit = pending.popleft()
             if commit.id in haves:
             if commit.id in haves:
                 return True
                 return True
-            if not getattr(commit, 'get_parents', None):
+            if commit.type_name != "commit":
                 # non-commit wants are assumed to be satisfied
                 # non-commit wants are assumed to be satisfied
                 continue
                 continue
-            for parent in commit.get_parents():
+            for parent in commit.parents:
                 parent_obj = self.store[parent]
                 parent_obj = self.store[parent]
                 # TODO: handle parents with later commit times than children
                 # TODO: handle parents with later commit times than children
                 if parent_obj.commit_time >= earliest:
                 if parent_obj.commit_time >= earliest:

+ 2 - 4
dulwich/tests/test_server.py

@@ -175,11 +175,9 @@ class TestCommit(object):
 
 
     def __init__(self, sha, parents, commit_time):
     def __init__(self, sha, parents, commit_time):
         self.id = sha
         self.id = sha
-        self._parents = parents
+        self.parents = parents
         self.commit_time = commit_time
         self.commit_time = commit_time
-
-    def get_parents(self):
-        return self._parents
+        self.type_name = "commit"
 
 
     def __repr__(self):
     def __repr__(self):
         return '%s(%s)' % (self.__class__.__name__, self._sha)
         return '%s(%s)' % (self.__class__.__name__, self._sha)