# HG changeset patch # User Martin von Zweigbergk # Date 1650339938 25200 # Node ID 770e1352e9f94e619ac39ca0595bb75eef1bed4e # Parent 65eda809b943c727e961decbbf0219d72b92ed92 amend: don't remove unselected removals from memctx 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. Differential Revision: https://phab.mercurial-scm.org/D12573 diff -r 65eda809b943 -r 770e1352e9f9 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Mon Apr 18 20:39:31 2022 -0700 +++ b/mercurial/cmdutil.py Mon Apr 18 20:45:38 2022 -0700 @@ -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 diff -r 65eda809b943 -r 770e1352e9f9 tests/test-copies-in-changeset.t --- a/tests/test-copies-in-changeset.t Mon Apr 18 20:39:31 2022 -0700 +++ b/tests/test-copies-in-changeset.t Mon Apr 18 20:45:38 2022 -0700 @@ -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 ..