changeset 30699:5bda147c3139

revset: make children() not look at p2 if null (issue5439) Unlike p1 = null, p2 = null denotes the revision has only one parent, which shouldn't be considered a child of the null revision. This was spotted while fixing the issue4682 and rediscovered as issue5439.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 23 May 2015 11:04:11 +0900
parents c3db3bb4699f
children 323f0c4b43f4
files mercurial/revset.py tests/test-revset.t
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Wed Jan 04 19:17:44 2017 -0800
+++ b/mercurial/revset.py	Sat May 23 11:04:11 2015 +0900
@@ -723,12 +723,15 @@
     cs = set()
     pr = repo.changelog.parentrevs
     minrev = parentset.min()
+    nullrev = node.nullrev
     for r in subset:
         if r <= minrev:
             continue
-        for p in pr(r):
-            if p in parentset:
-                cs.add(r)
+        p1, p2 = pr(r)
+        if p1 in parentset:
+            cs.add(r)
+        if p2 != nullrev and p2 in parentset:
+            cs.add(r)
     return baseset(cs)
 
 @predicate('children(set)', safe=True)
--- a/tests/test-revset.t	Wed Jan 04 19:17:44 2017 -0800
+++ b/tests/test-revset.t	Sat May 23 11:04:11 2015 +0900
@@ -881,6 +881,13 @@
   $ log 'children(ancestor(4,5))'
   2
   3
+
+  $ log 'children(4)'
+  6
+  8
+  $ log 'children(null)'
+  0
+
   $ log 'closed()'
   $ log 'contains(a)'
   0