changeset 24011:d7d08337b3f6

copy: move _forwardcopies file logic to a function Moves the _forwardcopies missingfiles logic to a separate function so that other extensions which need to prefetch information about the files being processed have a hook point. This saves extensions from having to recompute this information themselves, and thus saves several seconds off of various commands (like rebase).
author Durham Goode <durham@fb.com>
date Tue, 27 Jan 2015 17:24:12 -0800
parents a63c2b159df4
children bc75f8750cde
files mercurial/copies.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/copies.py	Tue Jan 27 17:23:18 2015 -0800
+++ b/mercurial/copies.py	Tue Jan 27 17:24:12 2015 -0800
@@ -144,6 +144,15 @@
             del c[k]
     return c
 
+def _computeforwardmissing(a, b):
+    """Computes which files are in b but not a.
+    This is its own function so extensions can easily wrap this call to see what
+    files _forwardcopies is about to process.
+    """
+    missing = set(b.manifest().iterkeys())
+    missing.difference_update(a.manifest().iterkeys())
+    return missing
+
 def _forwardcopies(a, b):
     '''find {dst@b: src@a} copy mapping where a is an ancestor of b'''
 
@@ -167,9 +176,7 @@
     # we currently don't try to find where old files went, too expensive
     # this means we can miss a case like 'hg rm b; hg cp a b'
     cm = {}
-    missing = set(b.manifest().iterkeys())
-    missing.difference_update(a.manifest().iterkeys())
-
+    missing = _computeforwardmissing(a, b)
     ancestrycontext = a._repo.changelog.ancestors([b.rev()], inclusive=True)
     for f in missing:
         fctx = b[f]