Bug 3497 - incorrect behavior of hg log with empty repository when certain options are used
Summary: incorrect behavior of hg log with empty repository when certain options are used
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2012-06-13 06:45 UTC by Thomas Arendsen Hein
Modified: 2013-06-10 07:31 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Arendsen Hein 2012-06-13 06:45 UTC
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.
Comment 1 Matt Mackall 2012-06-15 07:30 UTC
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.
Comment 2 Alexander Plavin 2013-04-10 14:23 UTC
Starting working on it.
Comment 3 HG Bot 2013-04-16 20:15 UTC
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)
Comment 4 HG Bot 2013-04-18 18:45 UTC
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)
Comment 5 Thomas Arendsen Hein 2013-06-10 07:31 UTC
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.