|
@@ -162,7 +162,8 @@ class BaseObjectStore(object):
|
|
yield entry
|
|
yield entry
|
|
|
|
|
|
def find_missing_objects(self, haves, wants, progress=None,
|
|
def find_missing_objects(self, haves, wants, progress=None,
|
|
- get_tagged=None):
|
|
|
|
|
|
+ get_tagged=None,
|
|
|
|
+ get_parents=lambda commit: commit.parents):
|
|
"""Find the missing objects required for a set of revisions.
|
|
"""Find the missing objects required for a set of revisions.
|
|
|
|
|
|
:param haves: Iterable over SHAs already in common.
|
|
:param haves: Iterable over SHAs already in common.
|
|
@@ -171,9 +172,10 @@ class BaseObjectStore(object):
|
|
updated progress strings.
|
|
updated progress strings.
|
|
:param get_tagged: Function that returns a dict of pointed-to sha -> tag
|
|
:param get_tagged: Function that returns a dict of pointed-to sha -> tag
|
|
sha for including tags.
|
|
sha for including tags.
|
|
|
|
+ :param get_parents: Optional function for getting the parents of a commit.
|
|
:return: Iterator over (sha, path) pairs.
|
|
:return: Iterator over (sha, path) pairs.
|
|
"""
|
|
"""
|
|
- finder = MissingObjectFinder(self, haves, wants, progress, get_tagged)
|
|
|
|
|
|
+ finder = MissingObjectFinder(self, haves, wants, progress, get_tagged, get_parents=get_parents)
|
|
return iter(finder.next, None)
|
|
return iter(finder.next, None)
|
|
|
|
|
|
def find_common_revisions(self, graphwalker):
|
|
def find_common_revisions(self, graphwalker):
|
|
@@ -215,12 +217,14 @@ class BaseObjectStore(object):
|
|
obj = self[sha]
|
|
obj = self[sha]
|
|
return obj
|
|
return obj
|
|
|
|
|
|
- def _collect_ancestors(self, heads, common=set()):
|
|
|
|
|
|
+ def _collect_ancestors(self, heads, common=set(),
|
|
|
|
+ get_parents=lambda commit: commit.parents):
|
|
"""Collect all ancestors of heads up to (excluding) those in common.
|
|
"""Collect all ancestors of heads up to (excluding) those in common.
|
|
|
|
|
|
:param heads: commits to start from
|
|
:param heads: commits to start from
|
|
:param common: commits to end at, or empty set to walk repository
|
|
:param common: commits to end at, or empty set to walk repository
|
|
completely
|
|
completely
|
|
|
|
+ :param get_parents: Optional function for getting the parents of a commit.
|
|
:return: a tuple (A, B) where A - all commits reachable
|
|
:return: a tuple (A, B) where A - all commits reachable
|
|
from heads but not present in common, B - common (shared) elements
|
|
from heads but not present in common, B - common (shared) elements
|
|
that are directly reachable from heads
|
|
that are directly reachable from heads
|
|
@@ -236,7 +240,7 @@ class BaseObjectStore(object):
|
|
elif e not in commits:
|
|
elif e not in commits:
|
|
commits.add(e)
|
|
commits.add(e)
|
|
cmt = self[e]
|
|
cmt = self[e]
|
|
- queue.extend(cmt.parents)
|
|
|
|
|
|
+ queue.extend(get_parents(cmt))
|
|
return (commits, bases)
|
|
return (commits, bases)
|
|
|
|
|
|
def close(self):
|
|
def close(self):
|
|
@@ -970,12 +974,14 @@ class MissingObjectFinder(object):
|
|
:param progress: Optional function to report progress to.
|
|
:param progress: Optional function to report progress to.
|
|
:param get_tagged: Function that returns a dict of pointed-to sha -> tag
|
|
:param get_tagged: Function that returns a dict of pointed-to sha -> tag
|
|
sha for including tags.
|
|
sha for including tags.
|
|
|
|
+ :param get_parents: Optional function for getting the parents of a commit.
|
|
:param tagged: dict of pointed-to sha -> tag sha for including tags
|
|
:param tagged: dict of pointed-to sha -> tag sha for including tags
|
|
"""
|
|
"""
|
|
|
|
|
|
def __init__(self, object_store, haves, wants, progress=None,
|
|
def __init__(self, object_store, haves, wants, progress=None,
|
|
- get_tagged=None):
|
|
|
|
|
|
+ get_tagged=None, get_parents=lambda commit: commit.parents):
|
|
self.object_store = object_store
|
|
self.object_store = object_store
|
|
|
|
+ self._get_parents = get_parents
|
|
# process Commits and Tags differently
|
|
# process Commits and Tags differently
|
|
# Note, while haves may list commits/tags not available locally,
|
|
# Note, while haves may list commits/tags not available locally,
|
|
# and such SHAs would get filtered out by _split_commits_and_tags,
|
|
# and such SHAs would get filtered out by _split_commits_and_tags,
|
|
@@ -987,12 +993,16 @@ class MissingObjectFinder(object):
|
|
_split_commits_and_tags(object_store, wants, False)
|
|
_split_commits_and_tags(object_store, wants, False)
|
|
# all_ancestors is a set of commits that shall not be sent
|
|
# all_ancestors is a set of commits that shall not be sent
|
|
# (complete repository up to 'haves')
|
|
# (complete repository up to 'haves')
|
|
- all_ancestors = object_store._collect_ancestors(have_commits)[0]
|
|
|
|
|
|
+ all_ancestors = object_store._collect_ancestors(
|
|
|
|
+ have_commits,
|
|
|
|
+ get_parents=self._get_parents)[0]
|
|
# all_missing - complete set of commits between haves and wants
|
|
# all_missing - complete set of commits between haves and wants
|
|
# common - commits from all_ancestors we hit into while
|
|
# common - commits from all_ancestors we hit into while
|
|
# traversing parent hierarchy of wants
|
|
# traversing parent hierarchy of wants
|
|
- missing_commits, common_commits = \
|
|
|
|
- object_store._collect_ancestors(want_commits, all_ancestors)
|
|
|
|
|
|
+ missing_commits, common_commits = object_store._collect_ancestors(
|
|
|
|
+ want_commits,
|
|
|
|
+ all_ancestors,
|
|
|
|
+ get_parents=self._get_parents);
|
|
self.sha_done = set()
|
|
self.sha_done = set()
|
|
# Now, fill sha_done with commits and revisions of
|
|
# Now, fill sha_done with commits and revisions of
|
|
# files and directories known to be both locally
|
|
# files and directories known to be both locally
|