Patchwork D12625: amend: stop specifying matcher, get all copies in wctx

login
register
mail settings
Submitter phabricator
Date May 12, 2022, 1:17 a.m.
Message ID <differential-rev-PHID-DREV-a5ukuhhrip62trppntqk-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50977/
State New
Headers show

Comments

phabricator - May 12, 2022, 1:17 a.m.
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-amend.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -625,4 +625,4 @@ 
   $ hg status --change . --copies
   A new_file_amend_me
   A r0_copied
-    r0 (missing-correct-output !)
+    r0
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2914,9 +2914,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