Patchwork D9159: [RFC] merge: stop caring about whether files are related (issue6163)

login
register
mail settings
Submitter phabricator
Date Oct. 7, 2020, 12:06 a.m.
Message ID <differential-rev-PHID-DREV-w7vs6ppv6t67djrotdpa-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47388/
State New
Headers show

Comments

phabricator - Oct. 7, 2020, 12:06 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  See discussion in
  https://bz.mercurial-scm.org/show_bug.cgi?id=6163. D9130 <https://phab.mercurial-scm.org/D9130> reminded me
  of this idea.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




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

Patch

diff --git a/tests/test-copies-unrelated.t b/tests/test-copies-unrelated.t
--- a/tests/test-copies-unrelated.t
+++ b/tests/test-copies-unrelated.t
@@ -100,6 +100,13 @@ 
   |/   x
   o  0 add x
      x
+#if no-filelog
+  $ hg debugpathcopies 0 4
+  x -> y
+  $ hg graft -r 1
+  grafting 1:* "modify x" (glob)
+  merging y and x to y
+#else
   $ hg debugpathcopies 0 4
 BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 1
@@ -110,6 +117,7 @@ 
   abort: unresolved conflicts, can't continue
   (use 'hg resolve' and 'hg graft --continue')
   [1]
+#endif
 
 Add x, remove it, then add it back, then rename x to y. Similar to the case
 above, but here the break in history is before the rename.
@@ -196,15 +204,9 @@ 
   [1]
 #endif
   $ hg co -qC 2
-BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 5
   grafting 5:* "rename x to y"* (glob)
-  file 'x' was deleted in other [graft] but was modified in local [local].
-  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
-  What do you want to do? u
-  abort: unresolved conflicts, can't continue
-  (use 'hg resolve' and 'hg graft --continue')
-  [1]
+  merging x and y to y
 
 Add x, remove it, then add it back, rename x to y from the first commit.
 Similar to the case above, but here the break in history is parallel to the
@@ -270,15 +272,9 @@ 
   $ hg graft -r 2
   grafting 2:* "add x again with different content" (glob)
   $ hg co -qC 2
-BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 3
   grafting 3:* "rename x to y" (glob)
-  file 'x' was deleted in other [graft] but was modified in local [local].
-  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
-  What do you want to do? u
-  abort: unresolved conflicts, can't continue
-  (use 'hg resolve' and 'hg graft --continue')
-  [1]
+  merging x and y to y
 
 Add x on two branches, then rename x to y on one side. Similar to the case
 above, but here the break in history is via the base commit.
@@ -364,15 +360,9 @@ 
   [1]
 #endif
   $ hg co -qC 2
-BROKEN: This should succeed and merge the changes from x into y
   $ hg graft -r 5
   grafting 5:* "rename x to y"* (glob)
-  file 'x' was deleted in other [graft] but was modified in local [local].
-  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
-  What do you want to do? u
-  abort: unresolved conflicts, can't continue
-  (use 'hg resolve' and 'hg graft --continue')
-  [1]
+  merging x and y to y
 
 Copies via null revision (there shouldn't be any)
   $ newrepo
diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -314,10 +314,12 @@ 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBCm-1")'
   M b
   A d
+    a (no-filelog !)
   R a
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCBm-1")'
   M b
   A d
+    a (no-filelog !)
   R a
 
 Comparing with a merge re-adding the file afterward
@@ -414,10 +416,12 @@ 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBDm-0")'
   M b
   A d
+    a (no-filelog !)
   R a
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDBm-0")'
   M b
   A d
+    a (no-filelog !)
   R a
 
 
@@ -699,7 +703,7 @@ 
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mDGm-0")'
   A d
-    a (filelog !)
+    a
   R a
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGDm-0")'
   A d
@@ -914,11 +918,11 @@ 
 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCGm-0")'
   A d
-    a (filelog !)
+    a
   R a
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mGCm-0")'
   A d
-    a (filelog !)
+    a
   R a
   $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCGm-0")'
   A d
@@ -978,12 +982,12 @@ 
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mCB-revert-m-0")'
   M b
   A d
-    a (filelog !)
+    a
   R a
   $ hg status --copies --rev 'desc("i-0")' --rev 'desc("mBC-revert-m-0")'
   M b
   A d
-    a (filelog !)
+    a
   R a
   $ hg status --copies --rev 'desc("c-1")' --rev 'desc("mCB-revert-m-0")'
   M b
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -313,14 +313,6 @@ 
                         source = prev[1]
                     newcopies[dest] = (c, source)
                 assert newcopies is not copies
-            for f in changes.removed:
-                if f in newcopies:
-                    if newcopies is copies:
-                        # copy on write to avoid affecting potential other
-                        # branches.  when there are no other branches, this
-                        # could be avoided.
-                        newcopies = copies.copy()
-                    newcopies[f] = (c, None)
             othercopies = all_copies.get(c)
             if othercopies is None:
                 all_copies[c] = newcopies
@@ -386,7 +378,6 @@ 
     * p2: revision number of first parent
     * p1copies: mapping of copies from p1
     * p2copies: mapping of copies from p2
-    * removed: a list of removed files
     * ismerged: a callback to know if file was merged in that revision
     """
     cl = repo.changelog
@@ -412,8 +403,7 @@ 
         p1, p2 = parents(rev)
         ctx = repo[rev]
         p1copies, p2copies = ctx._copies
-        removed = ctx.filesremoved()
-        return p1, p2, p1copies, p2copies, removed, get_ismerged(rev)
+        return p1, p2, p1copies, p2copies, get_ismerged(rev)
 
     return revinfo
 
@@ -431,7 +421,7 @@ 
             # this is a root
             copies = {}
         for i, c in enumerate(children[r]):
-            p1, p2, p1copies, p2copies, removed, ismerged = revinfo(c)
+            p1, p2, p1copies, p2copies, ismerged = revinfo(c)
             if r == p1:
                 parent = 1
                 childcopies = p1copies
@@ -452,14 +442,6 @@ 
                         source = prev[1]
                     newcopies[dest] = (c, source)
                 assert newcopies is not copies
-            for f in removed:
-                if f in newcopies:
-                    if newcopies is copies:
-                        # copy on write to avoid affecting potential other
-                        # branches.  when there are no other branches, this
-                        # could be avoided.
-                        newcopies = copies.copy()
-                    newcopies[f] = (c, None)
             othercopies = all_copies.get(c)
             if othercopies is None:
                 all_copies[c] = newcopies
@@ -689,8 +671,6 @@ 
         # thing in pathcopies(): pathcopies(x, y) can return a copy where the
         # destination doesn't exist in y.
         pass
-    elif mb[src] != m2[src] and not _related(c2[src], base[src]):
-        return
     elif mb[src] != m2[src] or mb.flags(src) != m2.flags(src):
         # modified on side 2
         for dst in dsts1: