Browse Source

Implement ObjectStore.find_common_revisions().

Jelmer Vernooij 16 years ago
parent
commit
5b6585bfd8
2 changed files with 16 additions and 1 deletions
  1. 15 0
      dulwich/object_store.py
  2. 1 1
      dulwich/repo.py

+ 15 - 0
dulwich/object_store.py

@@ -109,6 +109,21 @@ class BaseObjectStore(object):
         """
         return iter(MissingObjectFinder(self, haves, wants, progress).next, None)
 
+    def find_common_revisions(self, graphwalker):
+        """Find which revisions this store has in common using graphwalker.
+
+        :param graphwalker: A graphwalker object.
+        :return: List of SHAs that are in common
+        """
+        haves = []
+        sha = graphwalker.next()
+        while sha:
+            if sha in self:
+                haves.append(sha)
+                graphwalker.ack(sha)
+            sha = graphwalker.next()
+        return haves
+
     def get_graph_walker(self, heads):
         """Obtain a graph walker for this object store.
         

+ 1 - 1
dulwich/repo.py

@@ -228,7 +228,7 @@ class Repo(object):
         :return: tuple with number of objects, iterator over objects
         """
         wants = determine_wants(self.get_refs())
-        haves = self.object_store.find_missing_revisions(graphwalker)
+        haves = self.object_store.find_common_revisions(graphwalker)
         return self.object_store.iter_shas(
             self.object_store.find_missing_objects(haves, wants, progress))