Patchwork [STABLE] match: fix NameError 'pat' on overflow of regex pattern length

login
register
mail settings
Submitter Yuya Nishihara
Date April 29, 2014, 4:54 a.m.
Message ID <920b654c7a16fc208fe6.1398747299@gimlet>
Download mbox | patch
Permalink /patch/4454/
State Accepted
Commit 3180ef36ca05d05e43ef9cb0b6648e08d20a95db
Headers show

Comments

Yuya Nishihara - April 29, 2014, 4:54 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1398736960 -32400
#      Tue Apr 29 11:02:40 2014 +0900
# Branch stable
# Node ID 920b654c7a16fc208fe62ca58609434ef34a0247
# Parent  6a43c60ad9af8d7524740a9ae185970759235eab
match: fix NameError 'pat' on overflow of regex pattern length

'pat' was renamed to 'regex' in 9d28fd795215.
Augie Fackler - April 29, 2014, 3:10 p.m.
On Tue, Apr 29, 2014 at 01:54:59PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1398736960 -32400
> #      Tue Apr 29 11:02:40 2014 +0900
> # Branch stable
> # Node ID 920b654c7a16fc208fe62ca58609434ef34a0247
> # Parent  6a43c60ad9af8d7524740a9ae185970759235eab
> match: fix NameError 'pat' on overflow of regex pattern length

Queued, thanks.

>
> 'pat' was renamed to 'regex' in 9d28fd795215.
>
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -343,7 +343,7 @@ def _buildregexmatch(kindpats, globsuffi
>              raise
>          regexa, a = _buildregexmatch(kindpats[:l//2], globsuffix)
>          regexb, b = _buildregexmatch(kindpats[l//2:], globsuffix)
> -        return pat, lambda s: a(s) or b(s)
> +        return regex, lambda s: a(s) or b(s)
>      except re.error:
>          for k, p in kindpats:
>              try:
> diff --git a/tests/test-walk.t b/tests/test-walk.t
> --- a/tests/test-walk.t
> +++ b/tests/test-walk.t
> @@ -331,3 +331,14 @@ Test listfile and listfile0
>    f  mammals/skunk  mammals/skunk  exact
>
>    $ cd ..
> +
> +Test split patterns on overflow
> +
> +  $ cd t
> +  $ echo fennel > overflow.list
> +  $ python -c "for i in xrange(20000 / 100): print 'x' * 100" >> overflow.list
> +  $ echo fenugreek >> overflow.list
> +  $ hg debugwalk 'listfile:overflow.list' 2>&1 | grep -v '^xxx'
> +  f  fennel     fennel     exact
> +  f  fenugreek  fenugreek  exact
> +  $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -343,7 +343,7 @@  def _buildregexmatch(kindpats, globsuffi
             raise
         regexa, a = _buildregexmatch(kindpats[:l//2], globsuffix)
         regexb, b = _buildregexmatch(kindpats[l//2:], globsuffix)
-        return pat, lambda s: a(s) or b(s)
+        return regex, lambda s: a(s) or b(s)
     except re.error:
         for k, p in kindpats:
             try:
diff --git a/tests/test-walk.t b/tests/test-walk.t
--- a/tests/test-walk.t
+++ b/tests/test-walk.t
@@ -331,3 +331,14 @@  Test listfile and listfile0
   f  mammals/skunk  mammals/skunk  exact
 
   $ cd ..
+
+Test split patterns on overflow
+
+  $ cd t
+  $ echo fennel > overflow.list
+  $ python -c "for i in xrange(20000 / 100): print 'x' * 100" >> overflow.list
+  $ echo fenugreek >> overflow.list
+  $ hg debugwalk 'listfile:overflow.list' 2>&1 | grep -v '^xxx'
+  f  fennel     fennel     exact
+  f  fenugreek  fenugreek  exact
+  $ cd ..