remotefilelog: add seen set to annotate algorithm

The remotefilelog annotate logic was not keeping track of which commits it had
seen when doing the bfs ancestor walk. For very mergy histories this resulted in
a ton of duplicate work.

Differential Revision: https://phab.mercurial-scm.org/D771
This commit is contained in:
Durham Goode 2017-09-21 21:31:52 -07:00
parent 0e25d26f20
commit 999e3b7af5

View File

@ -377,7 +377,9 @@ class remotefilectx(context.filectx):
# like self.ancestors, but append to "fetch" and skip visiting parents
# of nodes in "prefetchskip".
fetch = []
seen = set()
queue = collections.deque((introctx,))
seen.add(introctx.node())
while queue:
current = queue.pop()
if current.filenode() != self.filenode():
@ -386,7 +388,10 @@ class remotefilectx(context.filectx):
fetch.append((current.path(), hex(current.filenode())))
if prefetchskip and current in prefetchskip:
continue
map(queue.append, current.parents())
for parent in current.parents():
if parent.node() not in seen:
seen.add(parent.node())
queue.append(parent)
self._repo.ui.debug('remotefilelog: prefetching %d files '
'for annotate\n' % len(fetch))