Patchwork [stable?,V2] match: let 'path:.' and 'path:' match everything (issue4687)

login
register
mail settings
Submitter Matt Harbison
Date June 21, 2015, 3:21 p.m.
Message ID <55c0d9db1542351d819f.1434900100@Envy>
Download mbox | patch
Permalink /patch/9744/
State Accepted
Headers show

Comments

Matt Harbison - June 21, 2015, 3:21 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1434844766 14400
#      Sat Jun 20 19:59:26 2015 -0400
# Node ID 55c0d9db1542351d819f9ceb9997fdfc6b8430a7
# Parent  4359485eb420d7474c22e492dcf6d9596f50fc9a
match: let 'path:.' and 'path:' match everything (issue4687)

Previously, both queries exited with code 1, printing nothing.  The pattern in
the latter query is normalized to '.', so it is really the same case.
Yuya Nishihara - June 22, 2015, 2:01 p.m.
On Sun, 21 Jun 2015 11:21:40 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1434844766 14400
> #      Sat Jun 20 19:59:26 2015 -0400
> # Node ID 55c0d9db1542351d819f9ceb9997fdfc6b8430a7
> # Parent  4359485eb420d7474c22e492dcf6d9596f50fc9a
> match: let 'path:.' and 'path:' match everything (issue4687)
> 
> Previously, both queries exited with code 1, printing nothing.  The pattern in
> the latter query is normalized to '.', so it is really the same case.
> 
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -505,6 +505,8 @@
>      if kind == 're':
>          return pat
>      if kind == 'path':
> +        if pat == '.':
> +            return ''
>          return '^' + util.re.escape(pat) + '(?:/|$)'

This version looks good to me, thanks.
Augie Fackler - June 22, 2015, 2:52 p.m.
On Sun, Jun 21, 2015 at 11:21:40AM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1434844766 14400
> #      Sat Jun 20 19:59:26 2015 -0400
> # Node ID 55c0d9db1542351d819f9ceb9997fdfc6b8430a7
> # Parent  4359485eb420d7474c22e492dcf6d9596f50fc9a
> match: let 'path:.' and 'path:' match everything (issue4687)

Queued for stable, thanks.

>
> Previously, both queries exited with code 1, printing nothing.  The pattern in
> the latter query is normalized to '.', so it is really the same case.
>
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -505,6 +505,8 @@
>      if kind == 're':
>          return pat
>      if kind == 'path':
> +        if pat == '.':
> +            return ''
>          return '^' + util.re.escape(pat) + '(?:/|$)'
>      if kind == 'relglob':
>          return '(?:|.*/)' + _globre(pat) + globsuffix
> diff --git a/tests/test-locate.t b/tests/test-locate.t
> --- a/tests/test-locate.t
> +++ b/tests/test-locate.t
> @@ -106,6 +106,19 @@
>    $ mkdir otherdir
>    $ cd otherdir
>
> +  $ hg files path:
> +  ../b (glob)
> +  ../dir.h/foo (glob)
> +  ../t.h (glob)
> +  ../t/e.h (glob)
> +  ../t/x (glob)
> +  $ hg files path:.
> +  ../b (glob)
> +  ../dir.h/foo (glob)
> +  ../t.h (glob)
> +  ../t/e.h (glob)
> +  ../t/x (glob)
> +
>    $ hg locate b
>    ../b (glob)
>    ../t/b (glob)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://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
@@ -505,6 +505,8 @@ 
     if kind == 're':
         return pat
     if kind == 'path':
+        if pat == '.':
+            return ''
         return '^' + util.re.escape(pat) + '(?:/|$)'
     if kind == 'relglob':
         return '(?:|.*/)' + _globre(pat) + globsuffix
diff --git a/tests/test-locate.t b/tests/test-locate.t
--- a/tests/test-locate.t
+++ b/tests/test-locate.t
@@ -106,6 +106,19 @@ 
   $ mkdir otherdir
   $ cd otherdir
 
+  $ hg files path:
+  ../b (glob)
+  ../dir.h/foo (glob)
+  ../t.h (glob)
+  ../t/e.h (glob)
+  ../t/x (glob)
+  $ hg files path:.
+  ../b (glob)
+  ../dir.h/foo (glob)
+  ../t.h (glob)
+  ../t/e.h (glob)
+  ../t/x (glob)
+
   $ hg locate b
   ../b (glob)
   ../t/b (glob)