diff mercurial/fileset.py @ 38687:1500cbe22d53

fileset: parse argument of size() by predicate function This change is necessary to pass in a size expression to predicatematcher. See the next patch.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 10 Jun 2018 20:58:10 +0900
parents 131aae58a316
children ff5b6fca1082
line wrap: on
line diff
--- a/mercurial/fileset.py	Sun Jun 10 22:19:56 2018 +0900
+++ b/mercurial/fileset.py	Sun Jun 10 20:58:10 2018 +0900
@@ -384,11 +384,9 @@
     except ValueError:
         raise error.ParseError(_("couldn't parse size: %s") % s)
 
-def sizematcher(x):
+def sizematcher(expr):
     """Return a function(size) -> bool from the ``size()`` expression"""
-
-    # i18n: "size" is a keyword
-    expr = getstring(x, _("size requires an expression")).strip()
+    expr = expr.strip()
     if '-' in expr: # do we have a range?
         a, b = expr.split('-', 1)
         a = util.sizetoint(a)
@@ -420,7 +418,9 @@
     - size('>= .5MB') - files at least 524288 bytes
     - size('4k - 1MB') - files from 4096 bytes to 1048576 bytes
     """
-    m = sizematcher(x)
+    # i18n: "size" is a keyword
+    expr = getstring(x, _("size requires an expression"))
+    m = sizematcher(expr)
     return [f for f in mctx.existing() if m(mctx.ctx[f].size())]
 
 @predicate('encoding(name)', callexisting=True)