[Updated] [+- ] D8653: copies: handle more cases where a file got replaced by a copy

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Oct 23 04:18:12 UTC 2020


martinvonz updated this revision to Diff 23295.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8653?vs=23175&id=23295

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/merge.py
  tests/test-copies.t

CHANGE DETAILS

diff --git a/tests/test-copies.t b/tests/test-copies.t
--- a/tests/test-copies.t
+++ b/tests/test-copies.t
@@ -496,16 +496,17 @@
   1 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
   [1]
-BROKEN: should be "modified"
+This should ideally be "modified", but we will probably not be able to fix
+that in the filelog case.
   $ cat y
   original
 #else
   $ hg merge 2
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merging x and y to y
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
-BROKEN: should be "modified"
   $ cat y
-  original
+  modified
 #endif
 Same as above, but in the opposite direction
 #if filelog
@@ -523,11 +524,11 @@
 #else
   $ hg co -qC 2
   $ hg merge 3
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merging y and x to y
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
-BROKEN: should be "modified"
   $ cat y
-  original
+  modified
 #endif
 
 Create x and y, then rename x to z on one side of merge, and rename y to z and
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -817,6 +817,22 @@
                     args = (f, f, None, False, pa.node())
                     msg = b'both created'
                 mresult.addfile(f, mergestatemod.ACTION_MERGE, args, msg)
+            elif f in branch_copies1.copy:
+                fa = branch_copies1.copy[f]
+                mresult.addfile(
+                    f,
+                    mergestatemod.ACTION_MERGE,
+                    (f, fa, fa, False, pa.node()),
+                    b'local replaced from %s' % fa,
+                )
+            elif f in branch_copies2.copy:
+                fa = branch_copies2.copy[f]
+                mresult.addfile(
+                    f,
+                    mergestatemod.ACTION_MERGE,
+                    (fa, f, fa, False, pa.node()),
+                    b'other replaced from %s' % fa,
+                )
             else:
                 a = ma[f]
                 fla = ma.flags(f)



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


More information about the Mercurial-patches mailing list