[PATCH] fileset: drop bad "elif:" trying to check invalid size expression

Pulkit Goyal 7895pulkit at gmail.com
Thu Mar 1 07:53:56 EST 2018


Looks good to me.

On Thu, Mar 1, 2018 at 3:45 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1519897822 18000
> #      Thu Mar 01 04:50:22 2018 -0500
> # Node ID a6867dc78e35bc2a988f62668e59bc3610087821
> # Parent  b8c2209d738009dcbbf1f7d9352ce0ad21448c04
> fileset: drop bad "elif:" trying to check invalid size expression
>
> Since str.isdigit is a function, the last "elif" was always true. An invalid
> expression is rejected by util.sizetoint(), so we don't need "elif".
>
> diff --git a/mercurial/fileset.py b/mercurial/fileset.py
> --- a/mercurial/fileset.py
> +++ b/mercurial/fileset.py
> @@ -392,11 +392,10 @@ def sizematcher(x):
>      elif expr.startswith(">"):
>          a = util.sizetoint(expr[1:])
>          return lambda x: x > a
> -    elif expr[0:1].isdigit or expr.startswith('.'):
> +    else:
>          a = util.sizetoint(expr)
>          b = _sizetomax(expr)
>          return lambda x: x >= a and x <= b
> -    raise error.ParseError(_("couldn't parse size: %s") % expr)
>
>  @predicate('size(expression)', callexisting=True)
>  def size(mctx, x):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list