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

2022-05-11 Thread spectral (Kyle Lippincott)
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

$ 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

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



To: spectral, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D12624: amend: add test showing poor behavior when copies are involved

2022-05-11 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-amend.t

CHANGE DETAILS

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -609,3 +609,20 @@
   >   hg status
   > fi
   OK.
+
+Amending a commit that has copies but not specifying those copies shouldn't
+cause them to be lost
+
+  $ cd $TESTTMP
+  $ hg init dont-lose-copies; cd dont-lose-copies
+  $ echo r0 > r0; hg commit -qAm "r0"
+  $ hg cp r0 r0_copied; hg commit -qm "copy r0"
+  $ echo hi > new_file_amend_me
+  $ hg status --change . --copies
+  A r0_copied
+r0
+  $ hg amend -qA new_file_amend_me
+  $ hg status --change . --copies
+  A new_file_amend_me
+  A r0_copied
+r0 (missing-correct-output !)



To: spectral, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel