[Updated] [+ ] D8616: merge: chain copies with existing copies in working copy

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jun 11 14:34:30 UTC 2020


martinvonz updated this revision to Diff 21608.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8616?vs=21605&id=21608

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8616/new/

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1887,11 +1887,14 @@
             )
 
         wantfiledata = updatedirstate and not branchmerge
-        copies = {}
+        resulting_copies = {}
         # We don't want to record copies when doing `hg update -C` (which is
         # what `overwrite` is about)
         if not overwrite:
-            copies = _extract_copies(actions, branchmerge)
+            existing_copies = wc.p2copies()
+            existing_copies.update(wc.p1copies())
+            new_copies = _extract_copies(actions, branchmerge)
+            resulting_copies = copies.chain(existing_copies, new_copies)
 
         stats, getfiledata = applyupdates(
             repo, actions, wc, p2, overwrite, wantfiledata, labels=labels
@@ -1910,7 +1913,14 @@
                 if not branchmerge:
                     repo.dirstate.setbranch(p2.branch())
 
-        for dst, src in copies.items():
+        # This replicates copies.filter() but is modified to work with merges
+        for dst, src in resulting_copies.items():
+            if dst == src:
+                continue
+            if dst not in wc:
+                continue
+            if not (src in wc.p1() or src in wc.p2()):
+                continue
             wc[dst].markcopied(src)
 
     # If we're updating to a location, clean up any stale temporary includes



To: martinvonz, #hg-reviewers
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200611/fb4817f9/attachment-0002.html>


More information about the Mercurial-patches mailing list