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

2018-03-01 Thread Pulkit Goyal
On Thu, Mar 1, 2018 at 6:23 PM, Pulkit Goyal <7895pul...@gmail.com> wrote:
> Looks good to me.

And queued too. Thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-03-01 Thread Pulkit Goyal
Looks good to me.

On Thu, Mar 1, 2018 at 3:45 PM, Yuya Nishihara  wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # 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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-03-01 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# 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@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel