Patchwork [STABLE] revset: avoid a ValueError when 'only()' is given an empty set

login
register
mail settings
Submitter Matt Harbison
Date July 19, 2014, 12:26 a.m.
Message ID <aa0ed0dbf8bf7e69ac7e.1405729594@Envy>
Download mbox | patch
Permalink /patch/5185/
State Accepted
Commit 7142e04b438eab39685e63085503b8af0e42b31e
Headers show

Comments

Matt Harbison - July 19, 2014, 12:26 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1405727216 14400
#      Fri Jul 18 19:46:56 2014 -0400
# Branch stable
# Node ID aa0ed0dbf8bf7e69ac7e454d5d22cb58373e3d0d
# Parent  584bbfd1b50dad59871dcc7eba258491a2cb395f
revset: avoid a ValueError when 'only()' is given an empty set

This previously died in _revdescendants() taking the min() of the first set to
only(), when it was empty.  An empty second set already worked.  Likewise,
descendants() already handled an empty set.
Matt Mackall - July 19, 2014, 4:49 a.m.
On Fri, 2014-07-18 at 20:26 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1405727216 14400
> #      Fri Jul 18 19:46:56 2014 -0400
> # Branch stable
> # Node ID aa0ed0dbf8bf7e69ac7e454d5d22cb58373e3d0d
> # Parent  584bbfd1b50dad59871dcc7eba258491a2cb395f
> revset: avoid a ValueError when 'only()' is given an empty set

Queued for default (very soon to be stable), thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -399,6 +399,9 @@ 
     args = getargs(x, 1, 2, _('only takes one or two arguments'))
     include = getset(repo, spanset(repo), args[0]).set()
     if len(args) == 1:
+        if len(include) == 0:
+            return baseset([])
+
         descendants = set(_revdescendants(repo, include, False))
         exclude = [rev for rev in cl.headrevs()
             if not rev in descendants and not rev in include]
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -427,6 +427,16 @@ 
   7
   8
   9
+
+Test empty set input
+  $ log 'only(p2())'
+  $ log 'only(p1(), p2())'
+  0
+  1
+  2
+  4
+  8
+  9
   $ log 'outgoing()'
   8
   9