Patchwork [1,of,2,STABLE] revset: make children() not look at null parents (issue4682)

login
register
mail settings
Submitter Yuya Nishihara
Date May 23, 2015, 7:58 a.m.
Message ID <34e51d3d198185a395c8.1432367917@mimosa>
Download mbox | patch
Permalink /patch/9250/
State Superseded
Delegated to: Pierre-Yves David
Headers show

Comments

Yuya Nishihara - May 23, 2015, 7:58 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1432353720 -32400
#      Sat May 23 13:02:00 2015 +0900
# Branch stable
# Node ID 34e51d3d198185a395c88ce569de2a4aafa6316b
# Parent  2664f536a97e9893f44539b71ada43b87ca79e6d
revset: make children() not look at null parents (issue4682)

This is the simplest workaround for the issue of "children(branch(default))",
where "branch(default)" is evaluated to "<filteredset <fullreposet>>".

The next patch will fix the crash caused by "branch(null)", but it will make
"nullrev in <branch(default)>" be True because of d2de20e1451f. Therefore,
without this patch, "children(branch(default))" would return everything but
merge revisions.

I believe the right fix is to stop propagating the fullreposet magic to
filteredsets, and omit p2 if null, but they wouldn't fit to the stable branch.

"children(null)" seems still wrong, but it is consistent with "parents(0)"
that returns nothing.

  revision      result of "children(null)"
  ------------  -------------------------------------------
  2664f536a97e  everything but merge revisions (p2 == null)
  this patch    empty
  expected?     revisions which p1 == null
Yuya Nishihara - May 23, 2015, 11:57 p.m.
On Sat, 23 May 2015 16:58:37 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1432353720 -32400
> #      Sat May 23 13:02:00 2015 +0900
> # Branch stable
> # Node ID 34e51d3d198185a395c88ce569de2a4aafa6316b
> # Parent  2664f536a97e9893f44539b71ada43b87ca79e6d
> revset: make children() not look at null parents (issue4682)
> 
> This is the simplest workaround for the issue of "children(branch(default))",
> where "branch(default)" is evaluated to "<filteredset <fullreposet>>".
> 
> The next patch will fix the crash caused by "branch(null)", but it will make
> "nullrev in <branch(default)>" be True because of d2de20e1451f. Therefore,
> without this patch, "children(branch(default))" would return everything but
> merge revisions.

Please disregard this patch.
I found the same issue by "hg log -Gr branch(default)".

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -614,11 +614,12 @@  def _children(repo, narrow, parentset):
         return baseset(cs)
     pr = repo.changelog.parentrevs
     minrev = min(parentset)
+    nullrev = node.nullrev
     for r in narrow:
         if r <= minrev:
             continue
         for p in pr(r):
-            if p in parentset:
+            if p != nullrev and p in parentset:
                 cs.add(r)
     return baseset(cs)
 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1580,6 +1580,38 @@  tests for concatenation of strings/symbo
 
   $ cd ..
 
+prepare repository that has "default" branches of multiple roots
+
+  $ hg init namedbranch
+  $ cd namedbranch
+
+  $ echo default0 >> a
+  $ hg ci -Aqm0
+  $ echo default1 >> a
+  $ hg ci -m1
+
+  $ hg branch -q stable
+  $ echo stable2 >> a
+  $ hg ci -m2
+  $ echo stable3 >> a
+  $ hg ci -m3
+
+  $ hg update -q null
+  $ echo default4 >> a
+  $ hg ci -Aqm4
+  $ echo default5 >> a
+  $ hg ci -m5
+
+"null" revision belongs to "default" branch, but it shouldn't appear in set
+unless explicitly specified (issue4682)
+
+  $ log 'children(branch(default))'
+  1
+  2
+  5
+
+  $ cd ..
+
 test author/desc/keyword in problematic encoding
 # unicode: cp932:
 # u30A2    0x83 0x41(= 'A')