Patchwork [STABLE] match: fix assertion for fileset with no context (issue6046)

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 5, 2019, 6:55 a.m.
Message ID <b576b9960390abbf29b2.1546671324@mimosa>
Download mbox | patch
Permalink /patch/37484/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 5, 2019, 6:55 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1546670695 -32400
#      Sat Jan 05 15:44:55 2019 +0900
# Branch stable
# Node ID b576b9960390abbf29b2d103d7578938fdb65e4a
# Parent  fbd5e2f0bba7661f6f09e6cfd2bc2ffd07559a41
match: fix assertion for fileset with no context (issue6046)

A falsy changectx should be allowed.
Pulkit Goyal - Jan. 5, 2019, 8:49 a.m.
On Sat, Jan 5, 2019 at 12:26 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1546670695 -32400
> #      Sat Jan 05 15:44:55 2019 +0900
> # Branch stable
> # Node ID b576b9960390abbf29b2d103d7578938fdb65e4a
> # Parent  fbd5e2f0bba7661f6f09e6cfd2bc2ffd07559a41
> match: fix assertion for fileset with no context (issue6046)
>
> A falsy changectx should be allowed.
>

Queued this for stable, many thanks!

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -48,7 +48,7 @@  def _expandsets(root, cwd, kindpats, ctx
 
     for kind, pat, source in kindpats:
         if kind == 'set':
-            if not ctx:
+            if ctx is None:
                 raise error.ProgrammingError("fileset expression with no "
                                              "context")
             matchers.append(ctx.matchfileset(pat, badfn=badfn))
diff --git a/tests/test-locate.t b/tests/test-locate.t
--- a/tests/test-locate.t
+++ b/tests/test-locate.t
@@ -156,6 +156,11 @@  Issue294: hg remove --after dir fails wh
   $ hg files .
   [1]
 
+Fileset at null (i.e. a falsy context) shouldn't crash (issue6046)
+
+  $ hg files -r null 'set:tracked()'
+  [1]
+
 Convert native path separator to slash (issue5572)
 
   $ hg files -T '{path|relpath|slashpath}\n'