Patchwork [STABLE] log: do not use exact matcher for --patch --follow without file (issue4319)

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 1, 2014, 1:08 p.m.
Message ID <be94ed4baa5d807c3c93.1406898482@mimosa>
Download mbox | patch
Permalink /patch/5216/
State Accepted
Commit be94ed4baa5d807c3c934317d99912c2ab0d86bf
Headers show

Comments

Yuya Nishihara - Aug. 1, 2014, 1:08 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1406896616 -32400
#      Fri Aug 01 21:36:56 2014 +0900
# Branch stable
# Node ID be94ed4baa5d807c3c934317d99912c2ab0d86bf
# Parent  fd7839d1107dbc5523222fac5d5971da4939cfe7
log: do not use exact matcher for --patch --follow without file (issue4319)

e2530d4a47c1 is valid only if file argument is specified.  If no pattern
specified, it can simply fall back to the original matcher.
Siddharth Agarwal - Aug. 1, 2014, 4:38 p.m.
On 08/01/2014 06:08 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1406896616 -32400
> #      Fri Aug 01 21:36:56 2014 +0900
> # Branch stable
> # Node ID be94ed4baa5d807c3c934317d99912c2ab0d86bf
> # Parent  fd7839d1107dbc5523222fac5d5971da4939cfe7
> log: do not use exact matcher for --patch --follow without file (issue4319)

LGTM. Thanks for fixing this!

>
> e2530d4a47c1 is valid only if file argument is specified.  If no pattern
> specified, it can simply fall back to the original matcher.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1629,7 +1629,7 @@ def _makelogrevset(repo, pats, opts, rev
>   
>       filematcher = None
>       if opts.get('patch') or opts.get('stat'):
> -        if follow:
> +        if follow and not match.always():
>               # _makelogfilematcher expects its files argument to be relative to
>               # the repo root, so use match.files(), not pats.
>               filematcher = _makelogfilematcher(repo, match.files(), followfirst)
> diff --git a/tests/test-log.t b/tests/test-log.t
> --- a/tests/test-log.t
> +++ b/tests/test-log.t
> @@ -260,6 +260,98 @@ log -pf b inside dir
>     +a
>     
>   
> +log -pf, but no args
> +
> +  $ hg log -pf
> +  changeset:   3:2ca5ba701980
> +  user:        test
> +  date:        Thu Jan 01 00:00:04 1970 +0000
> +  summary:     d
> +
> +  diff -r f8954cd4dc1f -r 2ca5ba701980 a
> +  --- a/a	Thu Jan 01 00:00:03 1970 +0000
> +  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  @@ -1,1 +0,0 @@
> +  -a
> +  diff -r f8954cd4dc1f -r 2ca5ba701980 b
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/b	Thu Jan 01 00:00:04 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +a
> +  diff -r f8954cd4dc1f -r 2ca5ba701980 d
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/d	Thu Jan 01 00:00:04 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +a
> +  diff -r f8954cd4dc1f -r 2ca5ba701980 g
> +  --- a/g	Thu Jan 01 00:00:03 1970 +0000
> +  +++ b/g	Thu Jan 01 00:00:04 1970 +0000
> +  @@ -1,2 +1,2 @@
> +   f
> +  -g
> +  +f
> +
> +  changeset:   2:f8954cd4dc1f
> +  user:        test
> +  date:        Thu Jan 01 00:00:03 1970 +0000
> +  summary:     c
> +
> +  diff -r d89b0a12d229 -r f8954cd4dc1f b
> +  --- a/b	Thu Jan 01 00:00:02 1970 +0000
> +  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  @@ -1,1 +0,0 @@
> +  -a
> +  diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/dir/b	Thu Jan 01 00:00:03 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +a
> +  diff -r d89b0a12d229 -r f8954cd4dc1f f
> +  --- a/f	Thu Jan 01 00:00:02 1970 +0000
> +  +++ b/f	Thu Jan 01 00:00:03 1970 +0000
> +  @@ -1,1 +1,2 @@
> +   f
> +  +f
> +  diff -r d89b0a12d229 -r f8954cd4dc1f g
> +  --- a/g	Thu Jan 01 00:00:02 1970 +0000
> +  +++ b/g	Thu Jan 01 00:00:03 1970 +0000
> +  @@ -1,1 +1,2 @@
> +   f
> +  +g
> +
> +  changeset:   1:d89b0a12d229
> +  user:        test
> +  date:        Thu Jan 01 00:00:02 1970 +0000
> +  summary:     b
> +
> +  diff -r 9161b9aeaf16 -r d89b0a12d229 b
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/b	Thu Jan 01 00:00:02 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +a
> +  diff -r 9161b9aeaf16 -r d89b0a12d229 g
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/g	Thu Jan 01 00:00:02 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +f
> +
> +  changeset:   0:9161b9aeaf16
> +  user:        test
> +  date:        Thu Jan 01 00:00:01 1970 +0000
> +  summary:     a
> +
> +  diff -r 000000000000 -r 9161b9aeaf16 a
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/a	Thu Jan 01 00:00:01 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +a
> +  diff -r 000000000000 -r 9161b9aeaf16 f
> +  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/f	Thu Jan 01 00:00:01 1970 +0000
> +  @@ -0,0 +1,1 @@
> +  +f
> +
> +
>   log -vf dir/b
>   
>     $ hg log -vf dir/b
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - Aug. 1, 2014, 4:48 p.m.
On Fri, 2014-08-01 at 22:08 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1406896616 -32400
> #      Fri Aug 01 21:36:56 2014 +0900
> # Branch stable
> # Node ID be94ed4baa5d807c3c934317d99912c2ab0d86bf
> # Parent  fd7839d1107dbc5523222fac5d5971da4939cfe7
> log: do not use exact matcher for --patch --follow without file (issue4319)

Queued for stable, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1629,7 +1629,7 @@  def _makelogrevset(repo, pats, opts, rev
 
     filematcher = None
     if opts.get('patch') or opts.get('stat'):
-        if follow:
+        if follow and not match.always():
             # _makelogfilematcher expects its files argument to be relative to
             # the repo root, so use match.files(), not pats.
             filematcher = _makelogfilematcher(repo, match.files(), followfirst)
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -260,6 +260,98 @@  log -pf b inside dir
   +a
   
 
+log -pf, but no args
+
+  $ hg log -pf
+  changeset:   3:2ca5ba701980
+  user:        test
+  date:        Thu Jan 01 00:00:04 1970 +0000
+  summary:     d
+  
+  diff -r f8954cd4dc1f -r 2ca5ba701980 a
+  --- a/a	Thu Jan 01 00:00:03 1970 +0000
+  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +0,0 @@
+  -a
+  diff -r f8954cd4dc1f -r 2ca5ba701980 b
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/b	Thu Jan 01 00:00:04 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  diff -r f8954cd4dc1f -r 2ca5ba701980 d
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/d	Thu Jan 01 00:00:04 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  diff -r f8954cd4dc1f -r 2ca5ba701980 g
+  --- a/g	Thu Jan 01 00:00:03 1970 +0000
+  +++ b/g	Thu Jan 01 00:00:04 1970 +0000
+  @@ -1,2 +1,2 @@
+   f
+  -g
+  +f
+  
+  changeset:   2:f8954cd4dc1f
+  user:        test
+  date:        Thu Jan 01 00:00:03 1970 +0000
+  summary:     c
+  
+  diff -r d89b0a12d229 -r f8954cd4dc1f b
+  --- a/b	Thu Jan 01 00:00:02 1970 +0000
+  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +0,0 @@
+  -a
+  diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/dir/b	Thu Jan 01 00:00:03 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  diff -r d89b0a12d229 -r f8954cd4dc1f f
+  --- a/f	Thu Jan 01 00:00:02 1970 +0000
+  +++ b/f	Thu Jan 01 00:00:03 1970 +0000
+  @@ -1,1 +1,2 @@
+   f
+  +f
+  diff -r d89b0a12d229 -r f8954cd4dc1f g
+  --- a/g	Thu Jan 01 00:00:02 1970 +0000
+  +++ b/g	Thu Jan 01 00:00:03 1970 +0000
+  @@ -1,1 +1,2 @@
+   f
+  +g
+  
+  changeset:   1:d89b0a12d229
+  user:        test
+  date:        Thu Jan 01 00:00:02 1970 +0000
+  summary:     b
+  
+  diff -r 9161b9aeaf16 -r d89b0a12d229 b
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/b	Thu Jan 01 00:00:02 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  diff -r 9161b9aeaf16 -r d89b0a12d229 g
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/g	Thu Jan 01 00:00:02 1970 +0000
+  @@ -0,0 +1,1 @@
+  +f
+  
+  changeset:   0:9161b9aeaf16
+  user:        test
+  date:        Thu Jan 01 00:00:01 1970 +0000
+  summary:     a
+  
+  diff -r 000000000000 -r 9161b9aeaf16 a
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:01 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  diff -r 000000000000 -r 9161b9aeaf16 f
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/f	Thu Jan 01 00:00:01 1970 +0000
+  @@ -0,0 +1,1 @@
+  +f
+  
+
 log -vf dir/b
 
   $ hg log -vf dir/b