[PATCH stable] rebase: add return codes

Jason Harris jason at jasonfharris.com
Thu May 20 09:11:21 CDT 2010


On May 20, 2010, at 3:41 PM, Martin Geisler wrote:

> Dirk Hasselbalch <dirk.hasselbalch at edlund.dk> writes:
> 
>> # HG changeset patch
>> # User Dirk Hasselbalch <dirk.hasselbalch at edlund.dk>
>> # Date 1274347380 -7200
>> # Branch stable
>> # Node ID 71ba9e6d27b0a1956297036dffc154b0bb3f2818
>> # Parent  46bb491344988abb22a93d7570852d532d7df74f
>> rebase: add return codes
> 
> Nice, but could you please also update the help text to document this?
> 
>> diff -r 46bb49134498 -r 71ba9e6d27b0 hgext/rebase.py
>> --- a/hgext/rebase.py	Wed May 19 22:09:58 2010 +0200
>> +++ b/hgext/rebase.py	Thu May 20 11:23:00 2010 +0200
>> @@ -113,7 +113,7 @@
>>                                 keepbranchesf, external) = restorestatus(repo)
>>             if abortf:
>>                 abort(repo, originalwd, target, state)
>> -                return
>> +                return 0
> 
> I think it would be better to let abort return the exit code (I saw that
> the abort function can warn about not stripping changesets and that may
> warrent a non-zero exit code).
> 
>>         else:
>>             if srcf and basef:
>>                 raise error.ParseError('rebase', _('cannot specify both a '
>> @@ -131,7 +131,7 @@
>>             if not result:
>>                 # Empty state built, nothing to rebase
>>                 ui.status(_('nothing to rebase\n'))
>> -                return
>> +                return 1
> 
> If there is nothing to do, then I think that should count as a succesful
> rebase.

Well... Right now "pull" with nothing to pull returns exit code 1, which to me still feels wrong but Matt says it makes it easy to code. (I personally don't think this a good reason to issue that exit code.)

In that email thread I started titled "Versioning of external extensions?"... Matt Mackall said:
> For the most part, things work like this:
> 
> 0: success
> 1: nothing to do, unresolved files, no matches, non-fatal errors
> 255: abort or other exception

It would be nice if the exit codes were a little more fine grained. For instance see:
http://www.freebsd.org/cgi/man.cgi?query=sysexits&sektion=3

Note that python http://www.wingware.com/psupport/python-manual/2.6/library/sys.html says "any nonzero value is considered “abnormal termination” by shells and the like. Most systems require it to be in the range 0-127, and produce undefined results otherwise. Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command line syntax errors and 1 for all other kind of errors."

I just don't think a pull with nothing to pull should be an abnormal error, or indeed a rebase with nothing to do should do an "abnormal termination".

Then again at least the policy is fairly clear.

Cheers,
  Jas

>>             else:
>>                 originalwd, target, state = result
>>                 if collapsef:
>> @@ -213,6 +213,8 @@
>>             util.unlink(repo.sjoin('undo'))
>>         if skipped:
>>             ui.note(_("%d revisions have been skipped\n") % len(skipped))
>> +
>> +        return 0
>>     finally:
>>         release(lock, wlock)
> 
> 
> -- 
> Martin Geisler
> 
> aragost Trifork
> Professional Mercurial support
> http://aragost.com/mercurial/
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list