Can't amend a commit that contains removed files.

Issue #2567 resolved
Cristian Diaconescu
created an issue
  1. Create a changeset that removes a file from the repo and commit it.
  2. Oops, need to fix description.
  3. Amend the changeset (e.g. change the description message).

Result: Amend fails with "The system cannot find the file specified"

Here's the log:

% hg remove "D:\_src.NET_\CTUCsharpRuntime-hg\CTUFrameworkSyncTool/New Text Document.txt"
[command completed successfully Tue Apr 30 18:21:48 2013]
% hg commit --verbose --user cdiaconescu "--message=Test rem" -- "D:\_src.NET_\CTUCsharpRuntime-hg\CTUFrameworkSyncTool/New Text Document.txt"
committed changeset 375:246a3f057409
[command completed successfully Tue Apr 30 18:21:49 2013]
% hg commit --verbose --user cdiaconescu "--message=Test rem2" --amend -- "D:\_src.NET_\CTUCsharpRuntime-hg\CTUFrameworkSyncTool/New Text Document.txt"
amending changeset 246a3f057409
abort: CTUFrameworkSyncTool/New Text Document.txt: The system cannot find the file specified
[command returned code 255 Tue Apr 30 18:21:56 2013]

Workaround (using MQ):

  1. Create a changeset that removes a file from the repo and commit it.
  2. Oops, need to fix description.
  3. Amend the changeset. Doesn't work. Curse.
  4. Import changeset to MQ => patch
  5. Change the description of the patch
  6. QRefresh patch
  7. Finish patch.

Comments (9)

  1. Angel Ezquerra

    The reason why this happens is because by default all files modified, added or removed on the revision being amended are selected by TortoiseHg. When you click "amend" TortoiseHg asks mercurial to amend all the checked files, including those that were deleted. But those files are not found on the revision being amended, nor on the working directory, which triggers the error.

    To solve it, simply deselected all removed files before clicking amend. In fact, if you just want to edit the commit message, you can just uncheck all files on the revision being amended (by clicking on the checkbox that is found on the commit file list header), and then click amend. This works because amend, as opposed to QRefresh, gets a list of files to amend. If you provide no files, no files will be amended.

    The underlying problem is that we (I) reused the QRefresh mode of the commit panel to implement the amend mode. This kind of works but there are enough differences with QRefresh that things do not quite work as expected.

    For now we could not select any removed files by default when amend is selected, but this would just be a stop gap solution IMHO.

  2. Cristian Diaconescu reporter
    • changed status to open

    Not fixed in 2.8.1. Here's the log output for amending a change that contains a deleted file:

    % hg add "D:\_src.NET_\test\.hgignore" "D:\_src.NET_\test\New Text Document.txt"
    [command completed successfully Fri Jul 12 15:23:29 2013]
    % hg commit --verbose --user cdiaconescu --message=1st -- "D:\_src.NET_\test\.hgignore" "D:\_src.NET_\test\New Text Document.txt"
    .hgignore
    New Text Document.txt
    committed changeset 0:05bbadc92412
    [command completed successfully Fri Jul 12 15:23:29 2013]
    % hg remove "D:\_src.NET_\test\New Text Document.txt"
    [command completed successfully Fri Jul 12 15:23:47 2013]
    % hg commit --verbose --user cdiaconescu --message=del -- "D:\_src.NET_\test\New Text Document.txt"
    committed changeset 1:b1d4a5bdd0a7
    [command completed successfully Fri Jul 12 15:23:47 2013]
    % hg add "D:\_src.NET_\test\New Compressed (zipped) Folder.zip"
    [command completed successfully Fri Jul 12 15:24:08 2013]
    % hg commit --verbose --user cdiaconescu --message=del --amend -- "D:\_src.NET_\test\New Text Document.txt" "D:\_src.NET_\test\New Compressed (zipped) Folder.zip"
    amending changeset b1d4a5bdd0a7
    abort: New Text Document.txt: The system cannot find the file specified
    [command returned code 255 Fri Jul 12 15:24:08 2013]
    test%
    

    FWIW Here's the complete version info for TortoiseHG: version 2.8.1 with Mercurial-2.6.2, Python-2.7.3, PyQt-4.9.6, Qt-4.8.4

  3. Angel Ezquerra

    commit: properly set the file list "defcheck" when amend is selected (fixes #2567)

    Since b64381bf9057 we were supposed to exclude removed and missing files by default during amend. However this was not true because there was an incorrect comparison between curraction and 'amend'. Fixing the comparison fixes the issue.

    → <<cset 986670508a18>>

  4. Log in to comment