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

login
register
mail settings
Submitter Yuya Nishihara
Date July 7, 2018, 8:38 a.m.
Message ID <45a4b2282eb3b0b57168.1530952725@mimosa>
Download mbox | patch
Permalink /patch/32676/
State New
Headers show

Comments

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

Patch

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).