|
@@ -61,12 +61,22 @@ class Repo(object):
|
|
|
def controldir(self):
|
|
|
return self._controldir
|
|
|
|
|
|
- def fetch_objects(self, determine_wants, graph_walker, progress):
|
|
|
+ def find_missing_objects(self, determine_wants, graph_walker, progress):
|
|
|
+ """Fetch the missing objects required for a set of revisions.
|
|
|
+
|
|
|
+ :param determine_wants: Function that takes a dictionary with heads
|
|
|
+ and returns the list of heads to fetch.
|
|
|
+ :param graph_walker: Object that can iterate over the list of revisions
|
|
|
+ to fetch and has an "ack" method that will be called to acknowledge
|
|
|
+ that a revision is present.
|
|
|
+ :param progress: Simple progress function that will be called with
|
|
|
+ updated progress strings.
|
|
|
+ """
|
|
|
wants = determine_wants(self.heads())
|
|
|
- commits_to_send = []
|
|
|
+ commits_to_send = wants
|
|
|
ref = graph_walker.next()
|
|
|
while ref:
|
|
|
- commits_to_send.append(ref)
|
|
|
+ commits_to_send.add(ref)
|
|
|
if ref in self.object_store:
|
|
|
graph_walker.ack(ref)
|
|
|
ref = graph_walker.next()
|
|
@@ -86,7 +96,7 @@ class Repo(object):
|
|
|
sha_done.add(x)
|
|
|
parse_tree(t, sha_done)
|
|
|
except:
|
|
|
- sha_done.append(x)
|
|
|
+ sha_done.add(x)
|
|
|
|
|
|
treesha = c.tree
|
|
|
if treesha not in sha_done:
|
|
@@ -95,9 +105,22 @@ class Repo(object):
|
|
|
parse_tree(t, sha_done)
|
|
|
|
|
|
progress("counting objects: %d\r" % len(sha_done))
|
|
|
+ return sha_done
|
|
|
|
|
|
- for sha in sha_done:
|
|
|
- yield self.get_object(sha)
|
|
|
+ def fetch_objects(self, determine_wants, graph_walker, progress):
|
|
|
+ """Fetch the missing objects required for a set of revisions.
|
|
|
+
|
|
|
+ :param determine_wants: Function that takes a dictionary with heads
|
|
|
+ and returns the list of heads to fetch.
|
|
|
+ :param graph_walker: Object that can iterate over the list of revisions
|
|
|
+ to fetch and has an "ack" method that will be called to acknowledge
|
|
|
+ that a revision is present.
|
|
|
+ :param progress: Simple progress function that will be called with
|
|
|
+ updated progress strings.
|
|
|
+ """
|
|
|
+ shas = self.find_missing_objects(determine_wants, graph_walker, progress)
|
|
|
+ for sha in shas:
|
|
|
+ yield self.get_object(sha)
|
|
|
|
|
|
def object_dir(self):
|
|
|
return os.path.join(self.controldir(), OBJECTDIR)
|