# HG changeset patch # User Durham Goode # Date 1422408252 28800 # Node ID d7d08337b3f6bdb34f072756de19820f99909b0b # Parent a63c2b159df461989f7389de24f9299ce158ba29 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). diff -r a63c2b159df4 -r d7d08337b3f6 mercurial/copies.py --- 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]