Patchwork D12573: amend: don't remove unselected removals from memctx

login
register
mail settings
Submitter phabricator
Date April 19, 2022, 4:27 a.m.
Message ID <differential-rev-PHID-DREV-4voa2g4evwe5ky3356oi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50921/
State New
Headers show

Comments

phabricator - April 19, 2022, 4:27 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  When there are removed files in the working copy and they are not
  selected to be amended into the parent, the `filectxfn` we create for
  the `memctx` would still return `None` before this patch. That's
  clearly incorrect; we should return the `filectx` from the unamended
  commit. Somehow it seems to not matter much except for the case with
  copies stored in changesets.
  
  Thanks to Kyle Lippincott for doing all the debugging and identifying
  the fix for this issue.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-copies-in-changeset.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-copies-in-changeset.t b/tests/test-copies-in-changeset.t
--- a/tests/test-copies-in-changeset.t
+++ b/tests/test-copies-in-changeset.t
@@ -331,8 +331,8 @@ 
   A l
   $ echo modified >> a
   $ hg rm l
-  $ hg commit --amend a 2>&1 | grep AttributeError
-  AttributeError: 'NoneType' object has no attribute 'renamed' (known-bad-output !)
+  $ hg commit --amend a
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
 
   $ cd ..
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2935,7 +2935,7 @@ 
             def filectxfn(repo, ctx_, path):
                 try:
                     # Return None for removed files.
-                    if path in wctx.removed():
+                    if path in wctx.removed() and path in filestoamend:
                         return None
 
                     # If the file being considered is not amongst the files