# HG changeset patch # User Pierre-Yves David # Date 1610759935 -3600 # Node ID f213b250fed0c88c7be9f32538477dd64eab8184 # Parent 11ce2977572f058fdf3ea12cb69d480b24a24efc copies: explicitly filter out existing file in graftcopies The `graftcopies` function does something very strange (maybe even wrong), it calls `_filter` with a pair of changeset that does not match the one used to compute the copies informations. We are about to do some rework of `_filter` to make it closer to its documented intent and fix a couple of bug. This means some of the logic that only make sense for graft need to go somewhere else. We add the extra filtering with proper documentation to `graftcopies`. Differential Revision: https://phab.mercurial-scm.org/D9802 diff -r 11ce2977572f -r f213b250fed0 mercurial/copies.py --- a/mercurial/copies.py Fri Jan 22 15:43:06 2021 -0500 +++ b/mercurial/copies.py Sat Jan 16 02:18:55 2021 +0100 @@ -1220,6 +1220,12 @@ by merge.update(). """ new_copies = pathcopies(base, ctx) - _filter(wctx.p1(), wctx, new_copies) + parent = wctx.p1() + _filter(parent, wctx, new_copies) + # extra filtering to drop copy information for files that existed before + # the graft (otherwise we would create merge filelog for non-merge commit + for dest, __ in list(new_copies.items()): + if dest in parent: + del new_copies[dest] for dst, src in pycompat.iteritems(new_copies): wctx[dst].markcopied(src)