[PATCH 1 of 4] revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara
yuya at tcha.org
Thu Jan 5 14:48:45 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1432346651 -32400
# Sat May 23 11:04:11 2015 +0900
# Node ID 77cde77a8f4c9717e36b8b5d62b9518e68c1ac27
# Parent c3db3bb4699fdd03df5696f7a0bddfbbe10cf23c
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.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -723,12 +723,15 @@ def _children(repo, subset, parentset):
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)
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -881,6 +881,13 @@ test ancestors
$ log 'children(ancestor(4,5))'
2
3
+
+ $ log 'children(4)'
+ 6
+ 8
+ $ log 'children(null)'
+ 0
+
$ log 'closed()'
$ log 'contains(a)'
0
More information about the Mercurial-devel
mailing list