title: Mercurial: how to amend the last commit?
body: <p>I'm looking for a counter-part of <code>git commit --amend</code> in Mercurial, i.e. a way to modify the commit which my working copy is linked to. I'm only interested in the last commit, not an arbitrary earlier commit.</p>
  
  <p>The requirements for this amend-procedure are:</p>
  
  <ul>
  <li><p>if possible, it should not require any extensions. It must <strong>not require non-default extensions</strong>, i.e. extensions which do not come with an official Mercurial installation.</p></li>
  <li><p>if the commit to amend is one head of my current branch, <strong>no new head</strong> should be created. If the commit is not head, a new head may be created.</p></li>
  <li><p>the procedure should be <strong>safe</strong> in a way that if for whatever reasons the amending fails, I want to have the same working copy and repository state restored as before the amending. With other words, if the amending itself can fail, there should be a fail-safe procedure to restore the working copy and repository state. I'm referring to "failures" which lie in the nature of the amend-procedure (like e.g. conflicts), not to file-system-related problems (like access restrictions, not being able to lock a file for writing, ...)</p></li>
  </ul>
  
  <p><strong>Update (1):</strong></p>
  
  <ul>
  <li>the procedure must be <strong>automatable</strong>, so it can be performed by a GUI client without any user interaction required.</li>
  </ul>
  
  <p><strong>Update (2):</strong></p>
  
  <ul>
  <li>files in the working directory must not be touched (there may be file system locks on certain modified files). This especially means, that a possible approach may at no point require a clean working directory.</li>
  </ul>