Patchwork log: fix behavior with empty repositories (issue3497)

login
register
mail settings
Submitter Alexander Plavin
Date April 16, 2013, 9:13 p.m.
Message ID <75afb1573eeeba0073b6.1366146824@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1368/
State Accepted
Commit c1af1fb314bc96caf58e1dd6031ae3570008af6f
Headers show

Comments

Alexander Plavin - April 16, 2013, 9:13 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1366144194 -14400
# Node ID 75afb1573eeeba0073b65ad0287b90660363d6d5
# Parent  860e17295344a0e0b0bd88f023252fd82930fc1c
log: fix behavior with empty repositories (issue3497)

Make output in this special case consistent with general case one.
Matt Mackall - April 16, 2013, 9:18 p.m.
On Wed, 2013-04-17 at 01:13 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1366144194 -14400
> # Node ID 75afb1573eeeba0073b65ad0287b90660363d6d5
> # Parent  860e17295344a0e0b0bd88f023252fd82930fc1c
> log: fix behavior with empty repositories (issue3497)

Queued for default, thanks.
Bryan O'Sullivan - April 17, 2013, 8:54 p.m.
On Tue, Apr 16, 2013 at 2:18 PM, Matt Mackall <mpm@selenic.com> wrote:

> > log: fix behavior with empty repositories (issue3497)
>
> Queued for default, thanks.
>

This change breaks several tests when run with run-tests.py --pure, but not
normally:

test-eol-tag.t
test-issue842.t
Idan Kamara - April 18, 2013, 11:35 a.m.
On Wed, Apr 17, 2013 at 11:54 PM, Bryan O'Sullivan <bos@serpentine.com>
wrote:
> On Tue, Apr 16, 2013 at 2:18 PM, Matt Mackall <mpm@selenic.com> wrote:
>>
>> > log: fix behavior with empty repositories (issue3497)
>>
>> Queued for default, thanks.
>
>
> This change breaks several tests when run with run-tests.py --pure, but
not
> normally:

It also breaks a test in hglib which didn't expect an abort:

http://hgbuildbot.kublai.com/builders/python-hglib/builds/874/steps/default%20%28python2.4%29/logs/stdio

Alexander, can you fix the test?

Patch

diff -r 860e17295344 -r 75afb1573eee mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Apr 10 20:45:10 2013 +0400
+++ b/mercurial/cmdutil.py	Wed Apr 17 00:29:54 2013 +0400
@@ -1022,8 +1022,6 @@ 
 
     follow = opts.get('follow') or opts.get('follow_first')
 
-    if not len(repo):
-        return []
     if opts.get('rev'):
         revs = scmutil.revrange(repo, opts.get('rev'))
     elif follow:
diff -r 860e17295344 -r 75afb1573eee mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Apr 10 20:45:10 2013 +0400
+++ b/mercurial/revlog.py	Wed Apr 17 00:29:54 2013 +0400
@@ -771,6 +771,10 @@ 
                 nl = [n for n in nl if hex(n).startswith(id)]
                 if len(nl) > 0:
                     if len(nl) == 1:
+                        if nl[0] == nullid:
+                            # dummy null revision always exists,
+                            # it shouldn't be returned here
+                            return None
                         self._pcache[id] = nl[0]
                         return nl[0]
                     raise LookupError(id, self.indexfile,
diff -r 860e17295344 -r 75afb1573eee mercurial/revset.py
--- a/mercurial/revset.py	Wed Apr 10 20:45:10 2013 +0400
+++ b/mercurial/revset.py	Wed Apr 17 00:29:54 2013 +0400
@@ -238,12 +238,10 @@ 
     return [x for x in r if x in s]
 
 def dagrange(repo, subset, x, y):
-    if subset:
-        r = list(repo)
-        xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
-        s = set(subset)
-        return [r for r in xs if r in s]
-    return []
+    r = list(repo)
+    xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
+    s = set(subset)
+    return [r for r in xs if r in s]
 
 def andset(repo, subset, x, y):
     return getset(repo, getset(repo, subset, x), y)
diff -r 860e17295344 -r 75afb1573eee tests/test-alias.t
--- a/tests/test-alias.t	Wed Apr 10 20:45:10 2013 +0400
+++ b/tests/test-alias.t	Wed Apr 17 00:29:54 2013 +0400
@@ -267,10 +267,13 @@ 
   $ hg init sub
   $ cd sub
   $ hg count 'branch(default)'
+  abort: unknown revision 'default'!
   0
   $ hg -v count 'branch(default)'
+  abort: unknown revision 'default'!
   0
   $ hg -R .. count 'branch(default)'
+  abort: unknown revision 'default'!
   0
   $ hg --cwd .. count 'branch(default)'
   2
diff -r 860e17295344 -r 75afb1573eee tests/test-glog.t
--- a/tests/test-glog.t	Wed Apr 10 20:45:10 2013 +0400
+++ b/tests/test-glog.t	Wed Apr 17 00:29:54 2013 +0400
@@ -1542,6 +1542,7 @@ 
   $ testlog --follow
   []
   []
+  abort: unknown revision '0'!
   $ echo a > a
   $ echo aa > aa
   $ echo f > f
diff -r 860e17295344 -r 75afb1573eee tests/test-log.t
--- a/tests/test-log.t	Wed Apr 10 20:45:10 2013 +0400
+++ b/tests/test-log.t	Wed Apr 17 00:29:54 2013 +0400
@@ -1,3 +1,20 @@ 
+Log on empty repository: checking consistency
+
+  $ hg init empty
+  $ cd empty
+  $ hg log
+  $ hg log -r 1
+  abort: unknown revision '1'!
+  [255]
+  $ hg log -r -1:0
+  abort: unknown revision '-1'!
+  [255]
+  $ hg log -r 'branch(name)'
+  abort: unknown revision 'name'!
+  [255]
+  $ hg log -r null -q
+  -1:000000000000
+
 The g is crafted to have 2 filelog topological heads in a linear
 changeset graph