Patchwork D9802: copies: explicitly filter out existing file in graftcopies

login
register
mail settings
Submitter phabricator
Date Jan. 16, 2021, 1:23 a.m.
Message ID <differential-rev-PHID-DREV-pyavhbaf6r7uspxa3lm2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48113/
State Superseded
Headers show

Comments

phabricator - Jan. 16, 2021, 1:23 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9802

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -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)