[Request] [+ ] D8616: merge: chain copies with existing copies in working copy
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sat Jun 6 01:39:19 UTC 2020
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This makes the merge code chain and filter copies when grafting with
copies already in the working copy. For example, if the working copy
has renamed file A to B and you somehow graft in a change that renames
B to C, then that will now become a rename from A to C. That will
soon be necessary for `hg rebase --collapse`. It seems that we don't
have any existing cases where chaining makes a difference.
REPOSITORY
rHG Mercurial
BRANCH
default
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,9 +1887,12 @@
)
wantfiledata = updatedirstate and not branchmerge
- copies = {}
+ resulting_copies = {}
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
@@ -1908,7 +1911,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: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200606/61d6e72b/attachment.html>
More information about the Mercurial-patches
mailing list