mercurial/fileset.py
branchstable
changeset 14689 25e4d2f35965
parent 14685 394121d9f4fc
child 14690 15faf0e66909
equal deleted inserted replaced
14688:e2da6eee7950 14689:25e4d2f35965
   242     pat = getstring(x, _("grep requires a pattern"))
   242     pat = getstring(x, _("grep requires a pattern"))
   243     r = re.compile(pat)
   243     r = re.compile(pat)
   244     return [f for f in mctx.subset if r.search(mctx.ctx[f].data())]
   244     return [f for f in mctx.subset if r.search(mctx.ctx[f].data())]
   245 
   245 
   246 _units = dict(k=2**10, K=2**10, kB=2**10, KB=2**10,
   246 _units = dict(k=2**10, K=2**10, kB=2**10, KB=2**10,
   247               M=2**20, MB=2**20, G=2**30, GB=2**30,
   247               M=2**20, MB=2**20, G=2**30, GB=2**30)
   248               kiB=10**3, MiB=10**6, GiB=10**9)
       
   249 
   248 
   250 def _sizetoint(s):
   249 def _sizetoint(s):
   251     try:
   250     try:
   252         s = s.strip()
   251         s = s.strip()
   253         for k, v in _units.items():
   252         for k, v in _units.items():
   278 def size(mctx, x):
   277 def size(mctx, x):
   279     """``size(expression)``
   278     """``size(expression)``
   280     File size matches the given expression. Examples:
   279     File size matches the given expression. Examples:
   281 
   280 
   282     - 1k (files from 1024 to 2047 bytes)
   281     - 1k (files from 1024 to 2047 bytes)
   283     - 1.0kiB (files from 1000 to 1100 bytes)
       
   284     - < 20k (files less than 20480 bytes)
   282     - < 20k (files less than 20480 bytes)
   285     - >= .5MiB (files at least 500000 bytes)
   283     - >= .5MB (files at least 524288 bytes)
   286     - 4k - 1MB (files from 4096 bytes to 1048576 bytes)
   284     - 4k - 1MB (files from 4096 bytes to 1048576 bytes)
   287     """
   285     """
   288 
   286 
   289     expr = getstring(x, _("grep requires a pattern")).strip()
   287     expr = getstring(x, _("grep requires a pattern")).strip()
   290     if '-' in expr: # do we have a range?
   288     if '-' in expr: # do we have a range?