changeset 25925:23c4589fc678 stable

filesets: ignore unit case in size() predicate for single value When specifying one plain value in size(), e.g. size(1k), fileset tries to guess the upper bound automatically (see the comment in _sizetomax()). It didn't ignore the specified unit's case, and so size("1 GB"), for example, produced this error: hg: parse error: couldn't parse size: 1 GB Let's do the same thing that util.sizetoint() does: .lower(). The two test lines without output just check that there are no parse errors.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 08 Aug 2015 14:42:27 +0800
parents f4386cb3252e
children 4f703dcc626f
files mercurial/fileset.py tests/test-fileset.t
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/fileset.py	Thu Aug 06 22:54:28 2015 -0700
+++ b/mercurial/fileset.py	Sat Aug 08 14:42:27 2015 +0800
@@ -287,7 +287,7 @@
 
 def _sizetomax(s):
     try:
-        s = s.strip()
+        s = s.strip().lower()
         for k, v in util._sizeunits:
             if s.endswith(k):
                 # max(4k) = 5k - 1, max(4.5k) = 4.6k - 1
--- a/tests/test-fileset.t	Thu Aug 06 22:54:28 2015 -0700
+++ b/tests/test-fileset.t	Sat Aug 08 14:42:27 2015 +0800
@@ -144,6 +144,8 @@
   2k
   $ fileset '(1k or 2k) and size(".5KB - 1.5kB")'
   1k
+  $ fileset 'size("1M")'
+  $ fileset 'size("1 GB")'
 
 Test merge states