hg diff/status always returns zero?

Stephen Rasku mercurial at srasku.net
Wed May 6 14:55:07 CDT 2009


On Wed, May 6, 2009 at 15:32, Ted Pavlic <ted at tedpavlic.com> wrote:
>> It seems that "hg status" and "hg diff" always return zero regardless
>> of whether there are changes or not.  Is this correct?  If so, is it
>> deliberate?  I would like to call these functions from a script and
>> having a non-zero return code when there are changes would simplify my
>> development.
> When would you want it to return a non-zero value? Is it enough to have new
> untracked files? Or would you want it to return non-zero only if a tracked
> file was modified/deleted or a file was added?

For "hg status" I would say the second case. Untracked files are, by
definition, not part of the repository so it shouldn't affect the
return value of "hg status".

For "hg diff" it should return a non-zero status if any diffs are generated.

> The answer to these questions will vary from hg user to hg user, and so it's
> probably best to parse the output. For example...
>
> hg st|grep -q '^\(M\|D\|R\|!\|C\)'
>
> or something similar...

I can get this to work for me.  It's not as clean but I suppose it's
more flexible.

...Stephen



More information about the Mercurial mailing list