[PATCH 1 of 6] fileset: move helper functions to top

Yuya Nishihara yuya at tcha.org
Sat Jul 7 08:38:45 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1528534826 -32400
#      Sat Jun 09 18:00:26 2018 +0900
# Node ID 45a4b2282eb3b0b57168d3949e3ab3cae1fbd989
# Parent  f068495a1c28358c22695545ed15a00b54da0d45
fileset: move helper functions to top

diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -126,6 +126,19 @@ def getpattern(x, allkinds, err):
         return _getkindpat(x[1], x[2], allkinds, err)
     return getstring(x, err)
 
+def getlist(x):
+    if not x:
+        return []
+    if x[0] == 'list':
+        return getlist(x[1]) + [x[2]]
+    return [x]
+
+def getargs(x, min, max, err):
+    l = getlist(x)
+    if len(l) < min or len(l) > max:
+        raise error.ParseError(err)
+    return l
+
 def getset(mctx, x):
     if not x:
         raise error.ParseError(_("missing argument"))
@@ -164,6 +177,21 @@ def listset(mctx, a, b):
     raise error.ParseError(_("can't use a list in this context"),
                            hint=_('see hg help "filesets.x or y"'))
 
+def func(mctx, a, b):
+    funcname = getsymbol(a)
+    if funcname in symbols:
+        enabled = mctx._existingenabled
+        mctx._existingenabled = funcname in _existingcallers
+        try:
+            return symbols[funcname](mctx, b)
+        finally:
+            mctx._existingenabled = enabled
+
+    keep = lambda fn: getattr(fn, '__doc__', None) is not None
+
+    syms = [s for (s, fn) in symbols.items() if keep(fn)]
+    raise error.UnknownIdentifier(funcname, syms)
+
 # symbols are callable like:
 #  fun(mctx, x)
 # with:
@@ -253,34 +281,6 @@ def clean(mctx, x):
     s = set(mctx.status().clean)
     return [f for f in mctx.subset if f in s]
 
-def func(mctx, a, b):
-    funcname = getsymbol(a)
-    if funcname in symbols:
-        enabled = mctx._existingenabled
-        mctx._existingenabled = funcname in _existingcallers
-        try:
-            return symbols[funcname](mctx, b)
-        finally:
-            mctx._existingenabled = enabled
-
-    keep = lambda fn: getattr(fn, '__doc__', None) is not None
-
-    syms = [s for (s, fn) in symbols.items() if keep(fn)]
-    raise error.UnknownIdentifier(funcname, syms)
-
-def getlist(x):
-    if not x:
-        return []
-    if x[0] == 'list':
-        return getlist(x[1]) + [x[2]]
-    return [x]
-
-def getargs(x, min, max, err):
-    l = getlist(x)
-    if len(l) < min or len(l) > max:
-        raise error.ParseError(err)
-    return l
-
 @predicate('binary()', callexisting=True)
 def binary(mctx, x):
     """File that appears to be binary (contains NUL bytes).


More information about the Mercurial-devel mailing list