[PATCH 2 of 4 nullrev] revset: have all() filter out null revision

Yuya Nishihara yuya at tcha.org
Wed Mar 4 09:19:34 CST 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1420868990 -32400
#      Sat Jan 10 14:49:50 2015 +0900
# Node ID 3cc24fd0d1fa746217013a256b287d5050cf1135
# Parent  a72a044114ebbbd63b6128b4784c34bddd0b7b4d
revset: have all() filter out null revision

I'm not sure if "all()" should filter out "null", but "all()" is stated as
'the same as "0:tip"' (except that it doesn't reorder the subset, I think.)

This patch is intended to avoid exposing a fullreposet to graphmod.dagwalker(),
which would result in strange drawing in future version:

  |
  o  changeset:   0:f8035bb17114
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     add a

caused by:

    parents = sorted(set([p.rev() for p in ctx.parents()
                          if p.rev() in revs]))

We cannot add "and p.rev() != nullrev" here because revs may actually include
"null" revision.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -994,7 +994,7 @@ def getall(repo, subset, x):
     """
     # i18n: "all" is a keyword
     getargs(x, 0, 0, _("all takes no arguments"))
-    return subset
+    return subset & spanset(repo)  # drop "null" if any
 
 def grep(repo, subset, x):
     """``grep(regex)``
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -2365,4 +2365,14 @@ issue3772
      date:        Thu Jan 01 00:00:00 1970 +0000
   
 
+should not draw line down to null due to the magic of fullreposet
+
+  $ hg log -G -r 'all()' | tail -6
+  |
+  o  changeset:   0:f8035bb17114
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     add a
+  
+
   $ cd ..
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -480,6 +480,9 @@ Test explicit numeric revision
 Test null revision
   $ log 'ancestors(null)'
   -1
+  $ log 'tip:null and all()' | tail -2
+  1
+  0
 
   $ log 'outgoing()'
   8


More information about the Mercurial-devel mailing list