Show More
@@ -384,11 +384,9 def _sizetomax(s): | |||
|
384 | 384 | except ValueError: |
|
385 | 385 | raise error.ParseError(_("couldn't parse size: %s") % s) |
|
386 | 386 | |
|
387 | def sizematcher(x): | |
|
387 | def sizematcher(expr): | |
|
388 | 388 | """Return a function(size) -> bool from the ``size()`` expression""" |
|
389 | ||
|
390 | # i18n: "size" is a keyword | |
|
391 | expr = getstring(x, _("size requires an expression")).strip() | |
|
389 | expr = expr.strip() | |
|
392 | 390 | if '-' in expr: # do we have a range? |
|
393 | 391 | a, b = expr.split('-', 1) |
|
394 | 392 | a = util.sizetoint(a) |
@@ -420,7 +418,9 def size(mctx, x): | |||
|
420 | 418 | - size('>= .5MB') - files at least 524288 bytes |
|
421 | 419 | - size('4k - 1MB') - files from 4096 bytes to 1048576 bytes |
|
422 | 420 | """ |
|
423 | m = sizematcher(x) | |
|
421 | # i18n: "size" is a keyword | |
|
422 | expr = getstring(x, _("size requires an expression")) | |
|
423 | m = sizematcher(expr) | |
|
424 | 424 | return [f for f in mctx.existing() if m(mctx.ctx[f].size())] |
|
425 | 425 | |
|
426 | 426 | @predicate('encoding(name)', callexisting=True) |
@@ -14,6 +14,11 from . import ( | |||
|
14 | 14 | pycompat, |
|
15 | 15 | ) |
|
16 | 16 | |
|
17 | def _sizep(x): | |
|
18 | # i18n: "size" is a keyword | |
|
19 | expr = fileset.getstring(x, _("size requires an expression")) | |
|
20 | return fileset.sizematcher(expr) | |
|
21 | ||
|
17 | 22 | def _compile(tree): |
|
18 | 23 | if not tree: |
|
19 | 24 | raise error.ParseError(_("missing argument")) |
@@ -50,7 +55,7 def _compile(tree): | |||
|
50 | 55 | symbols = { |
|
51 | 56 | 'all': lambda n, s: True, |
|
52 | 57 | 'none': lambda n, s: False, |
|
53 |
'size': lambda n, s: |
|
|
58 | 'size': lambda n, s: _sizep(tree[2])(s), | |
|
54 | 59 | } |
|
55 | 60 | |
|
56 | 61 | name = fileset.getsymbol(tree[1]) |
General Comments 0
You need to be logged in to leave comments.
Login now