Patchwork [3,of,7] fileset: reject 'negate' node early while transforming parsed tree

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 3, 2018, 3:01 p.m.
Message ID <1598c4146f74757fef4e.1533308500@mimosa>
Download mbox | patch
Permalink /patch/33153/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 3, 2018, 3:01 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1532157404 -32400
#      Sat Jul 21 16:16:44 2018 +0900
# Node ID 1598c4146f74757fef4e2db244b03188d197df52
# Parent  9321d75764446672280a850db18ef335e4d3ee92
fileset: reject 'negate' node early while transforming parsed tree

That's how a 'negate' node is processed in revset.

Patch

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -62,9 +62,6 @@  def minusmatch(mctx, x, y):
     ym = getmatch(mctx, y)
     return matchmod.differencematcher(xm, ym)
 
-def negatematch(mctx, x):
-    raise error.ParseError(_("can't use negate operator in this context"))
-
 def listmatch(mctx, *xs):
     raise error.ParseError(_("can't use a list in this context"),
                            hint=_('see \'hg help "filesets.x or y"\''))
@@ -436,7 +433,6 @@  methods = {
     'and': andmatch,
     'or': ormatch,
     'minus': minusmatch,
-    'negate': negatematch,
     'list': listmatch,
     'not': notmatch,
     'func': func,
diff --git a/mercurial/filesetlang.py b/mercurial/filesetlang.py
--- a/mercurial/filesetlang.py
+++ b/mercurial/filesetlang.py
@@ -144,7 +144,9 @@  def _analyze(x):
         return (op, x[1], t)
     if op == 'group':
         return _analyze(x[1])
-    if op in {'not', 'negate'}:
+    if op == 'negate':
+        raise error.ParseError(_("can't use negate operator in this context"))
+    if op == 'not':
         t = _analyze(x[1])
         return (op, t)
     if op in {'and', 'minus'}:
diff --git a/mercurial/minifileset.py b/mercurial/minifileset.py
--- a/mercurial/minifileset.py
+++ b/mercurial/minifileset.py
@@ -65,8 +65,6 @@  def _compile(tree):
         func1 = _compile(tree[1])
         func2 = _compile(tree[2])
         return lambda n, s: func1(n, s) and not func2(n, s)
-    elif op == 'negate':
-        raise error.ParseError(_("can't use negate operator in this context"))
     elif op == 'list':
         raise error.ParseError(_("can't use a list in this context"),
                                hint=_('see \'hg help "filesets.x or y"\''))