With Mercurial 2.2.2 (but current default and almost any older version behave the same): Preparations: hg init empty cd empty 1. hg log -r 0 expected: abort: unknown revision '0'! 2. hg log -r unknown expected: abort: unknown revision 'unknown'! 3. hg log -r null -q expected: -1:000000000000 But all above commands procude no output and exit code 0.
The code to blame is here: http://www.selenic.com/hg/file/622aa57a90b1/mercurial/cmdutil.py#l992 Introduced here: http://www.selenic.com/hg/rev/d4b25df77a9e We silently exit log on empty repos.
Starting working on it.
Fixed by http://selenic.com/repo/hg/rev/c1af1fb314bc Alexander Plavin <me@aplavin.ru> log: fix behavior with empty repositories (issue3497) Make output in this special case consistent with general case one. (please test the fix)
Fixed by http://selenic.com/repo/hg/rev/c010cb6fdef7 Alexander Plavin <me@aplavin.ru> revlog: fix a regression with null revision Introduced in the patch which fixes issue3497 Part of that patch was erroneously submitted and it shouldn't be in the code (please test the fix)
Tested with 2.6.2: 2. and 3. now produce what I asked for. 1. (hg log -r 0) shows: $ hg log -r 0 changeset: -1:000000000000 tag: tip user: date: Thu Jan 01 00:00:00 1970 +0000 But this is consistent, too, because the 0 is interpreted as a very short version of the hash. If you have only one changeset with a hash starting with number (e.g. 9) you can list this changeset with "hg log -r 9", too. So I would say this issue is resolved. Maybe the matching of these very short all-numeric hashes should be prevented, but that would be a different issue.