log: switch to FROMLINE:TOLINE syntax for -L/--line-range
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 19 Oct 2017 12:37:26 +0200
changeset 34905 5c7dbb730179
parent 34904 4554649a6ea4
child 34906 2e45bbd3db7b
log: switch to FROMLINE:TOLINE syntax for -L/--line-range This is more consistent with the followlines() revset.
mercurial/cmdutil.py
mercurial/commands.py
tests/test-log-linerange.t
--- a/mercurial/cmdutil.py	Wed Oct 18 19:00:33 2017 +0200
+++ b/mercurial/cmdutil.py	Thu Oct 19 12:37:26 2017 +0200
@@ -2599,7 +2599,7 @@
         except ValueError:
             raise error.Abort(_('malformatted line-range pattern %s') % pat)
         try:
-            fromline, toline = map(int, linerange.split('-'))
+            fromline, toline = map(int, linerange.split(':'))
         except ValueError:
             raise error.Abort(_("invalid line range for %s") % pat)
         msg = _("line range pattern '%s' must match exactly one file") % pat
--- a/mercurial/commands.py	Wed Oct 18 19:00:33 2017 +0200
+++ b/mercurial/commands.py	Thu Oct 19 12:37:26 2017 +0200
@@ -3280,7 +3280,7 @@
 
     .. container:: verbose
 
-       Use -L/--line-range FILE,M-N options to follow the history of lines
+       Use -L/--line-range FILE,M:N options to follow the history of lines
        from M to N in FILE. With -p/--patch only diff hunks affecting
        specified line range will be shown. This option requires --follow;
        it can be specified multiple times. Currently, this option is not
@@ -3357,12 +3357,12 @@
 
       - changesets touching lines 13 to 23 for file.c::
 
-          hg log -L file.c,13-23
+          hg log -L file.c,13:23
 
       - changesets touching lines 13 to 23 for file.c and lines 2 to 6 of
         main.c with patch::
 
-          hg log -L file.c,13-23 -L main.c,2-6 -p
+          hg log -L file.c,13:23 -L main.c,2:6 -p
 
     See :hg:`help dates` for a list of formats valid for -d/--date.
 
--- a/tests/test-log-linerange.t	Wed Oct 18 19:00:33 2017 +0200
+++ b/tests/test-log-linerange.t	Thu Oct 19 12:37:26 2017 +0200
@@ -101,7 +101,7 @@
   -11+
   +11-
 
-  $ hg log -f -L foo,5-7 -p
+  $ hg log -f -L foo,5:7 -p
   changeset:   5:cfdf972b3971
   tag:         tip
   user:        test
@@ -175,12 +175,12 @@
 
 With --template.
 
-  $ hg log -f -L foo,5-7 -T '{rev}:{node|short} {desc|firstline}\n'
+  $ hg log -f -L foo,5:7 -T '{rev}:{node|short} {desc|firstline}\n'
   5:cfdf972b3971 foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+
   4:eaec41c1a0c9 11 -> 11+; leading space before "1"
   2:63a884426fd0 2 -> 2+; added bar
   0:5ae1f82b9a00 init
-  $ hg log -f -L foo,5-7 -T json
+  $ hg log -f -L foo,5:7 -T json
   [
    {
     "rev": 5,
@@ -234,7 +234,7 @@
 
 With some white-space diff option, respective revisions are skipped.
 
-  $ hg log -f -L foo,5-7 -p --config diff.ignorews=true
+  $ hg log -f -L foo,5:7 -p --config diff.ignorews=true
   changeset:   5:cfdf972b3971
   tag:         tip
   user:        test
@@ -290,7 +290,7 @@
 
 Regular file patterns are allowed with -L and their diff shows all lines.
 
-  $ hg log -f -L foo,5-7 -p bar
+  $ hg log -f -L foo,5:7 -p bar
   changeset:   5:cfdf972b3971
   tag:         tip
   user:        test
@@ -349,7 +349,7 @@
 
 Option --rev acts as a restriction.
 
-  $ hg log -f -L foo,5-7 -p -r 'desc(2)'
+  $ hg log -f -L foo,5:7 -p -r 'desc(2)'
   changeset:   2:63a884426fd0
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -387,7 +387,7 @@
 With several -L patterns, changes touching any files in their respective line
 range are show.
 
-  $ hg log -f -L foo,5-7 -L bar,1-2 -p
+  $ hg log -f -L foo,5:7 -L bar,1:2 -p
   changeset:   5:cfdf972b3971
   tag:         tip
   user:        test
@@ -481,7 +481,7 @@
 Multiple -L options with the same file yields changes touching any of
 specified line ranges.
 
-  $ hg log -f -L foo,5-7 -L foo,14-15 -p
+  $ hg log -f -L foo,5:7 -L foo,14:15 -p
   changeset:   5:cfdf972b3971
   tag:         tip
   user:        test
@@ -617,7 +617,7 @@
   > p
   > EOF
   $ hg ci -m 'azerty'
-  $ hg log -f -L ba,z,1-2 -p
+  $ hg log -f -L ba,z,1:2 -p
   changeset:   8:52373265138b
   tag:         tip
   user:        test
@@ -658,7 +658,7 @@
 
   $ mkdir dir
   $ cd dir
-  $ hg log -f -L path:foo,5-7 -p
+  $ hg log -f -L path:foo,5:7 -p
   changeset:   5:cfdf972b3971
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -758,7 +758,7 @@
   -11-
   +1+0
   +1+1-
-  $ hg log -f -L relpath:baz,5-7 -p
+  $ hg log -f -L relpath:baz,5:7 -p
   changeset:   9:6af29c3a778f
   tag:         tip
   user:        test
@@ -856,7 +856,7 @@
   >>> open('binary', 'w').write('this\nis\na\nbinary\0')
   $ hg add binary
   $ hg ci -m 'add a binary file' --quiet
-  $ hg log -f -L binary,1-2 -p
+  $ hg log -f -L binary,1:2 -p
   changeset:   10:c96381c229df
   tag:         tip
   user:        test
@@ -871,7 +871,7 @@
   Wc$_QA$SmdpqC~Ew%)G>+N(KNlNClYy
   
   
-  $ hg log -f -L binary,1-2 -p --config diff.git=false
+  $ hg log -f -L binary,1:2 -p --config diff.git=false
   changeset:   10:c96381c229df
   tag:         tip
   user:        test
@@ -884,19 +884,19 @@
 
 Option --follow is required.
 
-  $ hg log -L foo,5-7
+  $ hg log -L foo,5:7
   abort: --line-range requires --follow
   [255]
 
 Non-exact pattern kinds are not allowed.
 
   $ cd ..
-  $ hg log -f -L glob:*a*,1-2
+  $ hg log -f -L glob:*a*,1:2
   hg: parse error: line range pattern 'glob:*a*' must match exactly one file
   [255]
 
 Graph log does work yet.
 
-  $ hg log -f -L dir/baz,5-7 --graph
+  $ hg log -f -L dir/baz,5:7 --graph
   abort: graph not supported with line range patterns
   [255]