[PATCH 3 of 5] log: disable bare file patterns with --line-range
Denis Laxalde
denis at laxalde.org
Thu Oct 19 09:51:48 EDT 2017
# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1508415169 -7200
# Thu Oct 19 14:12:49 2017 +0200
# Node ID ce22c9db68b10ac17086a4f213b22d3304f09bad
# Parent 252117224ee9e8c3ab488575203ed27c292752bd
# EXP-Topic followlines-cli
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.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3383,6 +3383,11 @@ def log(ui, repo, *pats, **opts):
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']
diff --git a/tests/test-log-linerange.t b/tests/test-log-linerange.t
--- a/tests/test-log-linerange.t
+++ b/tests/test-log-linerange.t
@@ -288,64 +288,11 @@ With some white-space diff option, respe
+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.
More information about the Mercurial-devel
mailing list