[PATCH 4 of 4 V6 STABLE] revert: suggest --rev when working dir is clean

Kevin Bullock kbullock+mercurial at ringworld.org
Tue Jun 21 13:26:15 CDT 2011


On Jun 21, 2011, at 2:51 AM, Adrian Buehlmann wrote:

> On 2011-06-21 06:11, Kevin Bullock wrote:
>> # HG changeset patch
>> # User Kevin Bullock <kbullock at ringworld.org>
>> # Date 1308626997 18000
>> # Branch stable
>> # Node ID 6be8fc98f63c2c767c664dc8079f1a6a8711f3c8
>> # Parent  ee0ea22c40b86d58437630881ec5ea1815ebe354
>> revert: suggest --rev when working dir is clean
>> 
>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>> --- a/mercurial/commands.py
>> +++ b/mercurial/commands.py
>> @@ -4199,6 +4199,9 @@
>>                 hint = _('use --all to revert all files, or '
>>                          "'hg update %s' to check out that revision"
>>                          ) % ctx.rev()
>> +        elif not dirty:
>> +            hint = _('nothing changed, use --rev to revert to another'
>> +                     'revision')
>>         raise util.Abort(msg, hint=hint)
>> 
>>     mf = ctx.manifest()
> 
> IMHO that hint is a very bad idea. There is no need to entice newbies
> into yet more disaster.
> 
> And there's no reason to abort if nothing was changed (other than Matt
> saying he wants an abort...).

I whipped this one off as a discussion starter, midway between your proposal and Matt's gut feeling. I'm sorta leaning towards a non-abort with an exit status of 1... but I'm not entirely clear on what our exit status protocol is.

> 
> In my book (status quo):
> 
>  $ hg revert commands.py
>  no changes needed to commands.py
> 
> fits quite nicely with (my proposal):
> 
>  $ hg revert
>  nothing changed
> 
> Consider also (status quo):
> 
>  $ hg commit -mfoo
>  nothing changed


Yeah, like I say, I'm starting to be convinced by this.

pacem in terris / mir / shanti / salaam / heiwa
Kevin R. Bullock



More information about the Mercurial-devel mailing list