# HG changeset patch # User Martin von Zweigbergk # Date 1555567829 25200 # Node ID fdbeacb9d456c0b98b00df66a9921fd884826cf1 # Parent 5a3979529740182658459788704f4a8934a13e55 copies: filter out copies from non-existent source later in _chain() _changesetforwardcopies() repeatedly calls _chain(). That is very expensive because _chain() does lookups in the manifest. I hope to split up the function in two parts: 1) simple chaining, not considering end points, and 2) filter out files that don't exist in the end points (and ping-pong copies/renames). This patches gets us closer to that by moving the check for non-existent source later in the function. Now there are no more checks for "src" and "dst" in the first loop; all the filtering of invalid copies is done in the second loop. The code also looks much more consistent now. No measureable impact on `hg debugpathcopies 4.0 4.8`. That shouldn't be surprising since the only case we're doing more checks now is in case of chained copies/renames, which are quire rare in practice. Differential Revision: https://phab.mercurial-scm.org/D6277 diff -r 5a3979529740 -r fdbeacb9d456 mercurial/copies.py --- a/mercurial/copies.py Thu Apr 18 00:12:56 2019 -0700 +++ b/mercurial/copies.py Wed Apr 17 23:10:29 2019 -0700 @@ -134,13 +134,16 @@ if t[v] != k: # file wasn't renamed back to itself (i.e. case 4, not 3) t[k] = t[v] - elif v in src: - # file is a copy of an existing file, i.e. case 6. + else: + # Renamed only in 'b', i.e. cases 5 & 6. We'll remove case 5 later. t[k] = v for k, v in list(t.items()): + # remove copies from files that didn't exist, i.e. case 5 + if v not in src: + del t[k] # remove criss-crossed copies, i.e. case 3 - if k in src and v in dst: + elif k in src and v in dst: del t[k] # remove copies to files that were then removed, i.e. case 1 # and file 'y' in cases 3 & 4 (in case of rename)