Issue186

Title pull, push, etc. need sane exit codes
Priority bug Status resolved
Superseder Nosy List ThomasAH, alexis, bos, brendan, dduvall, eydaimon, junkblocker, kupfer, mpm, tonfa
Assigned To Topics ui

Created on 2006-03-28.15:46:04 by bos, last changed 2007-06-22.23:10:16 by mpm.

Messages
msg3270 (view) Author: mpm Date: 2007-06-22.23:10:16
Setting this to resolved. The new 'hg id' features make this easy:

REMOTETIP=`hg id default`
hg id -r `hg id default` || echo "incoming!"

This checks whether the remote tip is present locally.
msg2982 (view) Author: ThomasAH Date: 2007-04-11.05:54:23
I don't think using incoming would be cleaner. For remote repos it actually
would double the transfered data unless you use --bundle and then pull from that
bundle.

Additionally you still need a sane exit code for incoming then (or look at the
size of the bundle)
msg2980 (view) Author: kupfer Date: 2007-04-10.23:43:10
I like the idea of being able to tell in a script whether (for
example) it's worth starting a build.  But I wonder if it would be
cleaner for such a script to use "incoming" and then initiate the pull
only if "incoming" shows there is something there.
msg2971 (view) Author: eydaimon Date: 2007-04-07.17:17:40
I'm sorry. I missed the whole part that this would only happen when a switch 
was specified. I still don't think the normal behavior should give an exit-code 
of 1 when there's nothing to pull however.
msg2970 (view) Author: ThomasAH Date: 2007-04-07.08:55:02
I don't like grepping in output for such things, this will yield problems, e.g.
when 404 changesets were transmitted.
Adding some machine readable output uglifies the normal output.

What do others think about my suggestion for --report?
msg2968 (view) Author: eydaimon Date: 2007-04-07.03:46:50
typically non-zero exit codes are reserved for unexpected failures. doing a 
pull and not getting anything when no changes have been submitted isn't really 
unexpected.
It's easy enough to make a check to see if there was no submits anyway if a 
message is printed.

hg pull ... | grep "No new checkins"

for example.

Another way would be to actually print some sort of error code like apache 
does. Apache doesn't really have a failure itself if a document doesn't exist, 
but it prints a 404.
so maybe:

hg pull ... | grep "404: No new checkins"

which can obviously be reduced to
hg pull ... | grep 404

This may be good to use where error messages may change, but codes usually 
remain static.
msg2899 (view) Author: ThomasAH Date: 2007-03-15.10:27:55
Since 0.8.1 we return 0, even if no changes are found.
I just hit this when I wanted to run tests only when pulling yields new changesets.

My suggestion:
rc=255 on errors
rc=0 if ok
(until here it is compatible with the current behaviour)

rc=1 if there was no error, but no real action was done.
As this might be annoying for regular use, maybe only activate this feature when
a certain switch is used, e.g. --report?
msg860 (view) Author: ThomasAH Date: 2006-03-28.19:32:33
closed issue178 (which discusses the same topic) and added junkbocker to this
issue's nosy list.
As noted in the other issue: grep uses exit code 1 if no matches, 2 on errors.
msg849 (view) Author: bos Date: 2006-03-28.15:46:03
Right now, there's no way to tell what kind of problem a hg command encountered
if it exits with non-zero status.

For example, doing a pull when there are no changes to pull gives an exit code
of 1, but doing a pull into a corrupted repo does too, as does a pull from an
invalid URL.

I sort of don't care what the actual status codes are, I just don't want to have
to grep through hg output to see whether or not I have a real error :-(

For example, a pull that brings in no changes should probably exit with either
status 0 or a different status than all of the other exit cases.
History
Date User Action Args
2007-06-22 23:10:16mpmsetpriority: feature -> bug
status: chatting -> resolved
messages: + msg3270
nosy: + mpm
2007-06-22 22:59:49mpmsetpriority: bug -> feature
nosy: bos, ThomasAH, tonfa, brendan, alexis, junkblocker, kupfer, dduvall, eydaimon
2007-04-11 05:54:24ThomasAHsetnosy: bos, ThomasAH, tonfa, brendan, alexis, junkblocker, kupfer, dduvall, eydaimon
messages: + msg2982
2007-04-10 23:43:11kupfersetnosy: bos, ThomasAH, tonfa, brendan, alexis, junkblocker, kupfer, dduvall, eydaimon
messages: + msg2980
2007-04-07 17:17:41eydaimonsetnosy: bos, ThomasAH, tonfa, brendan, alexis, junkblocker, kupfer, dduvall, eydaimon
messages: + msg2971
2007-04-07 08:55:03ThomasAHsetnosy: bos, ThomasAH, tonfa, brendan, alexis, junkblocker, kupfer, dduvall, eydaimon
messages: + msg2970
2007-04-07 03:46:52eydaimonsetnosy: + eydaimon
messages: + msg2968
2007-03-15 10:27:55ThomasAHsettopic: + ui
nosy: + brendan, alexis
messages: + msg2899
2006-05-02 20:22:45dduvallsetnosy: + dduvall
2006-04-24 23:53:08kupfersetnosy: + kupfer
2006-04-01 05:17:12tonfasetnosy: + tonfa
2006-03-28 19:32:34ThomasAHsetstatus: unread -> chatting
nosy: + junkblocker
messages: + msg860
2006-03-28 19:30:26ThomasAHlinkissue178 superseder
2006-03-28 19:28:12ThomasAHsetnosy: + ThomasAH
2006-03-28 15:46:04boscreate