Issue #2235 duplicate

Amend fails on a commit with rename (or delete)

kankri
created an issue

Input

  1. hg init
  2. echo a > a
  3. hg commit -A -m "a"
  4. hg mv a b
  5. hg commit -m "a -> b"
  6. echo c > c
  7. hg add c
  8. thg commit
  9. Change Commit button to Amend
  10. Select file c (in addition to preselected a and b)
  11. Press Amend

Result

% hg commit --repository C:\Users\kankri\wrk\hg_amend_test --verbose --user someone@example.com --message=a -> b --amend -- b c a
amending changeset e0191deaba30
abort: a: The system cannot find the file specified

If a is manually deselected, amend succeeds, but this feels counter-intuitive.

The GUI could show an unselectable check mark for the committed removal of a and filter out any non-changed files in the actual hg commit --amend command.

But I'm thinking that maybe it's the wrong approach to try to show what the commit will contain after amending instead of showing what is being amended. That is, show the same information for Amend as what is shown for Commit.

Comments (9)

  1. Steve Borho

    This looks to me like a possible bug in Mercurial. If the commit removed a file, then amending that commit shouldn't abort if you include the deleted file in the commit list

  2. kankri reporter

    Not sure about that...

    After all, the file a doesn't exist, what should Mercurial do when I tell it to amend changes from file a? And what should it do differently if I don't tell it to amend a?

    The thg dialog would be reasonable for qrefresh which can both add and remove files from a patch, but amend works quite differently...

  3. simonbuchan

    Found pretty exhaustive discussion of --amend here: http://mercurial.808500.n3.nabble.com/Use-hg-commit-amend-to-change-the-files-that-are-included-in-a-commit-td3987824.html

    It seems to me that Tortoise is expecting amend to work like qrefresh: select what you want to be in the commit; whereas hg expects simply a filter on what you want to change, and changing a removed file doesn't make sense in that context. If you want Tortoise to follow the commandline's behavior, I would simply exclude removed files from the files that are checked by default (my preference). If you want it to work closer to qrefresh, about the only thing to do is to run something like "hg revert -r -2 <unselected files>", between shelving and unshelving modified files to keep them of course. I prefer the first quite strongly.

  4. Log in to comment