Page MenuHomePhabricator

Don't consider a no-op amend to be an error in Mercurial
ClosedPublic

Authored by epriestley on Jan 28 2014, 10:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 1:49 PM
Unknown Object (File)
Fri, Apr 12, 1:46 PM
Unknown Object (File)
Fri, Apr 12, 4:39 AM
Unknown Object (File)
Fri, Apr 12, 4:39 AM
Unknown Object (File)
Fri, Apr 12, 4:07 AM
Unknown Object (File)
Wed, Apr 3, 10:30 PM
Unknown Object (File)
Tue, Apr 2, 12:32 AM
Unknown Object (File)
Mar 10 2024, 3:42 AM
Subscribers

Details

Summary

Unlike git, Mercurial considers an hg commit --amend which doesn't change the working copy to be an error.

The current behavior for this is fairly bad, since the user gets an exception wrapping the entire command ("Command Failed! ...") and it's pretty verbose and not obvious what has happened.

Some alternatives are:

  1. Detect this condition and raise a more tailored exception, like a UsageException.
  2. Detect this condition and succeed.

Although I tend to think (1) is the right approach in general (that is, arc x should usually behave like git x or hg x), I went with (2) here because we have a handful of amend callsites and they all assume git semantics (no-op amends are successful), and because I think Mercurial's behavior is a little silly (the working copy ends up in the correct / expected state, which seems fairly clearly like a success to me).

Test Plan
  • Had reporting user verify patch.
  • Ran arc amend --revision Dxxx twice in a Mercurial working copy.

The old output looked like this:

$ arc amend --revision 922
Amending commit message to reflect revision D922: Improve performance of PhutilSymbolLoader::selectAndLoadSymbols().
Exception
Command failed with error #1!
COMMAND
HGPLAIN=1 hg commit --amend -l '/private/var/folders/8k/c3vkmjy5335gcxdzxkhwq82w0000gn/T/71k8q057844c4g84/3539-gfkvV4'

STDOUT
nothing changed

STDERR
(empty)
(Run with --trace for a full exception trace.)

The new output looks like this:

$ arc amend --revision 922
Amending commit message to reflect revision D922: Improve performance of PhutilSymbolLoader::selectAndLoadSymbols().
Done.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

okay I'm going back to bed now

have a good night