[PATCH V2] log: fix behavior with empty repositories (issue3497)

Alexander Plavin me at aplavin.ru
Thu Apr 18 07:18:03 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1366285717 -14400
#      Thu Apr 18 15:48:37 2013 +0400
# Node ID 06365450e30516f2d04bdfe98474cf6bdd9c0641
# Parent  99af3526d2f67a47d2287d3e6f93baa66e9b0714
log: fix behavior with empty repositories (issue3497)

Make output in this special case consistent with general case one.

diff -r 99af3526d2f6 -r 06365450e305 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Wed Apr 17 17:27:39 2013 +0400
+++ b/mercurial/cmdutil.py	Thu Apr 18 15:48:37 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 99af3526d2f6 -r 06365450e305 mercurial/revset.py
--- a/mercurial/revset.py	Wed Apr 17 17:27:39 2013 +0400
+++ b/mercurial/revset.py	Thu Apr 18 15:48:37 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 99af3526d2f6 -r 06365450e305 tests/test-alias.t
--- a/tests/test-alias.t	Wed Apr 17 17:27:39 2013 +0400
+++ b/tests/test-alias.t	Thu Apr 18 15:48:37 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 99af3526d2f6 -r 06365450e305 tests/test-log.t
--- a/tests/test-log.t	Wed Apr 17 17:27:39 2013 +0400
+++ b/tests/test-log.t	Thu Apr 18 15:48:37 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
 


More information about the Mercurial-devel mailing list