adjustlinknode: remove unnecessary ancestor walk

Summary:
Since we added the C code ancestor walk to this function, this python ancestor
walk is completely unnecessary, and can cause significant slow downs if none of
the ancestors are known linknodes (it walks the entire history).

Test Plan: Ran the tests

Reviewers: #sourcecontrol, ttung

Differential Revision: https://phabricator.fb.com/D3136150
This commit is contained in:
Durham Goode 2016-04-04 15:30:47 -07:00
parent 2ec49732fd
commit f774b1b204

View File

@ -181,9 +181,6 @@ class remotefilectx(context.filectx):
ancestormap = self.ancestormap() ancestormap = self.ancestormap()
p1, p2, linknode, copyfrom = ancestormap[fnode] p1, p2, linknode, copyfrom = ancestormap[fnode]
# hack to reuse ancestor computation when searching for renames
memberanc = getattr(self, '_ancestrycontext', None)
iteranc = None
if srcrev is None: if srcrev is None:
# wctx case, used by workingfilectx during mergecopy # wctx case, used by workingfilectx during mergecopy
revs = [p.rev() for p in self._repo[None].parents()] revs = [p.rev() for p in self._repo[None].parents()]
@ -202,9 +199,6 @@ class remotefilectx(context.filectx):
# existing in the changelog. # existing in the changelog.
pass pass
if memberanc is None:
memberanc = cl.ancestors(revs, inclusive=inclusive)
# Build a list of linknodes that are known to be ancestors of fnode # Build a list of linknodes that are known to be ancestors of fnode
knownancestors = set() knownancestors = set()
queue = collections.deque(p for p in (p1, p2) if p != nullid) queue = collections.deque(p for p in (p1, p2) if p != nullid)
@ -214,15 +208,6 @@ class remotefilectx(context.filectx):
queue.extend(p for p in (p1, p2) if p != nullid) queue.extend(p for p in (p1, p2) if p != nullid)
knownancestors.add(anclinknode) knownancestors.add(anclinknode)
# Check if this linknode is an ancestor of srcrev
for anc in memberanc:
ancnode = cl.node(anc)
if ancnode == linknode:
return linknode
# Stop if we reach a node in history that is past the desired fnode.
elif ancnode in knownancestors:
break
iteranc = cl.ancestors(revs, inclusive=inclusive) iteranc = cl.ancestors(revs, inclusive=inclusive)
for a in iteranc: for a in iteranc:
ac = cl.read(a) # get changeset data (we avoid object creation) ac = cl.read(a) # get changeset data (we avoid object creation)