changeset 38598:d046bf37f1ba

fileset: move helper functions to top
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Jun 2018 18:00:26 +0900
parents afef1e362d65
children f9805627af1f
files mercurial/fileset.py
diffstat 1 files changed, 28 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/fileset.py	Sun Jul 08 17:45:42 2018 +0900
+++ b/mercurial/fileset.py	Sat Jun 09 18:00:26 2018 +0900
@@ -126,6 +126,19 @@
         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 @@
     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 @@
     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).