log: disable bare file patterns with --line-range
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 19 Oct 2017 14:12:49 +0200
changeset 34906 2e45bbd3db7b
parent 34905 5c7dbb730179
child 34907 0ccfc468423a
log: disable bare file patterns with --line-range Currently, specifying both a line-range pattern and a bare file pattern results in an AND operation whereas we probably want an OR so that bare file patterns are like a line-range pattern with all lines specified. So, until this works as expected, we disable this.
mercurial/commands.py
tests/test-log-linerange.t
--- a/mercurial/commands.py	Thu Oct 19 12:37:26 2017 +0200
+++ b/mercurial/commands.py	Thu Oct 19 14:12:49 2017 +0200
@@ -3383,6 +3383,11 @@
     if linerange and not opts.get('follow'):
         raise error.Abort(_('--line-range requires --follow'))
 
+    if linerange and pats:
+        raise error.Abort(
+            _('FILE arguments are not compatible with --line-range option')
+        )
+
     if opts.get('follow') and opts.get('rev'):
         opts['rev'] = [revsetlang.formatspec('reverse(::%lr)', opts.get('rev'))]
         del opts['follow']
--- a/tests/test-log-linerange.t	Thu Oct 19 12:37:26 2017 +0200
+++ b/tests/test-log-linerange.t	Thu Oct 19 14:12:49 2017 +0200
@@ -288,64 +288,11 @@
   +4
   
 
-Regular file patterns are allowed with -L and their diff shows all lines.
+Regular file patterns are not allowed.
 
   $ hg log -f -L foo,5:7 -p bar
-  changeset:   5:cfdf972b3971
-  tag:         tip
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
-  
-  diff --git a/bar b/bar
-  --- a/bar
-  +++ b/bar
-  @@ -1,4 +1,4 @@
-  -a
-  +a+
-   b
-   c
-   d
-  diff --git a/foo b/foo
-  --- a/foo
-  +++ b/foo
-  @@ -4,7 +4,7 @@
-   0
-    1
-   2+
-  -3
-  +3+
-   4
-   5
-   6
-  
-  changeset:   2:63a884426fd0
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     2 -> 2+; added bar
-  
-  diff --git a/bar b/bar
-  new file mode 100644
-  --- /dev/null
-  +++ b/bar
-  @@ -0,0 +1,5 @@
-  +a
-  +b
-  +c
-  +d
-  +e
-  diff --git a/foo b/foo
-  --- a/foo
-  +++ b/foo
-  @@ -3,6 +3,6 @@
-   0
-   0
-   1
-  -2
-  +2+
-   3
-   4
-  
+  abort: FILE arguments are not compatible with --line-range option
+  [255]
 
 Option --rev acts as a restriction.