amend: stop specifying matcher, get all copies in wctx stable
authorKyle Lippincott <spectral@google.com>
Wed, 11 May 2022 17:56:29 -0700
branchstable
changeset 49179 df68d64b0d50
parent 49178 dc342071297f
child 49180 c577d394ed6b
child 49181 477b5145e1a0
amend: stop specifying matcher, get all copies in wctx When we're recreating the commit that we'll be committing, we don't want to filter our copy information based on just the *new* [versions of the] files we're amending. The test has an example of this case, but for clarity, the situation is: ``` $ hg cp src dst && hg commit <do some work> $ hg amend some_unrelated_file.txt $ hg status --copies A dst A some_unrelated_file.txt ``` What *should* happen is that `dst` should remain marked as a copy of `src`, but this did not previously happen. `matcher` here only includes the files that were specified on the commandline, so it only gets the copy information (if any, in this example there's not) for `some_unrelated_file.txt`. When it goes to apply the memctx to actually create the commit, the file copy information is incomplete and loses the information for the files that shouldn't have been affected at all by the amend. Differential Revision: https://phab.mercurial-scm.org/D12625
mercurial/cmdutil.py
tests/test-amend.t
--- a/mercurial/cmdutil.py	Wed May 11 17:56:10 2022 -0700
+++ b/mercurial/cmdutil.py	Wed May 11 17:56:29 2022 -0700
@@ -2915,9 +2915,9 @@
         # filectxs from the old commit.
         if changes or changeset_copies:
             # Recompute copies (avoid recording a -> b -> a)
-            copied = copies.pathcopies(base, wctx, matcher)
-            if old.p2:
-                copied.update(copies.pathcopies(old.p2(), wctx, matcher))
+            copied = copies.pathcopies(base, wctx)
+            if old.p2():
+                copied.update(copies.pathcopies(old.p2(), wctx))
 
             # Prune files which were reverted by the updates: if old
             # introduced file X and the file was renamed in the working
--- a/tests/test-amend.t	Wed May 11 17:56:10 2022 -0700
+++ b/tests/test-amend.t	Wed May 11 17:56:29 2022 -0700
@@ -625,4 +625,4 @@
   $ hg status --change . --copies
   A new_file_amend_me
   A r0_copied
-    r0 (missing-correct-output !)
+    r0