[PATCH 2 of 2 v2] log: make --line-range and --graph options work together

Denis Laxalde denis at laxalde.org
Sun Feb 11 13:05:26 EST 2018


# HG changeset patch
# User Denis Laxalde <denis at laxalde.org>
# Date 1518369441 -3600
#      Sun Feb 11 18:17:21 2018 +0100
# Node ID ceacb9e94803aafae2f1a677ccaa63068c3c4ed7
# Parent  f994010b9f093a1645875b4e905fcf9d21a5eaa9
# EXP-Topic log/linerange-graph
log: make --line-range and --graph options work together

Thanks to recent refactorings by Yuya Nishihara
(f8ad57d24252::29b83c08afe0) we can now trivially enable --graph option
along with --line-range.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3313,8 +3313,8 @@ def log(ui, repo, *pats, **opts):
        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
-       compatible with --graph. This option is experimental.
+       it can be specified multiple times.
+       This option is experimental.
 
     .. note::
 
@@ -3421,14 +3421,12 @@ def log(ui, repo, *pats, **opts):
     repo = scmutil.unhidehashlikerevs(repo, opts.get('rev'), 'nowarn')
     revs, differ = logcmdutil.getrevs(repo, pats, opts)
 
-    if opts.get('graph'):
-        if linerange:
-            raise error.Abort(_('graph not supported with line range patterns'))
-        return logcmdutil.graphlog(ui, repo, revs, differ, opts)
-
     if linerange:
         revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
 
+    if opts.get('graph'):
+        return logcmdutil.graphlog(ui, repo, revs, differ, opts)
+
     getrenamed = None
     if opts.get('copies'):
         endrev = None
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
@@ -173,8 +173,76 @@ Add some changes with two diff hunks
   +4
   
   $ hg log -f --graph -L foo,5:7 -p
-  abort: graph not supported with line range patterns
-  [255]
+  @  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/foo b/foo
+  |  --- a/foo
+  |  +++ b/foo
+  |  @@ -4,7 +4,7 @@
+  |   0
+  |    1
+  |   2+
+  |  -3
+  |  +3+
+  |   4
+  |   5
+  |   6
+  |
+  o  changeset:   4:eaec41c1a0c9
+  :  user:        test
+  :  date:        Thu Jan 01 00:00:00 1970 +0000
+  :  summary:     11 -> 11+; leading space before "1"
+  :
+  :  diff --git a/foo b/foo
+  :  --- a/foo
+  :  +++ b/foo
+  :  @@ -2,7 +2,7 @@
+  :   0
+  :   0
+  :   0
+  :  -1
+  :  + 1
+  :   2+
+  :   3
+  :   4
+  :
+  o  changeset:   2:63a884426fd0
+  :  user:        test
+  :  date:        Thu Jan 01 00:00:00 1970 +0000
+  :  summary:     2 -> 2+; added bar
+  :
+  :  diff --git a/foo b/foo
+  :  --- a/foo
+  :  +++ b/foo
+  :  @@ -3,6 +3,6 @@
+  :   0
+  :   0
+  :   1
+  :  -2
+  :  +2+
+  :   3
+  :   4
+  :
+  o  changeset:   0:5ae1f82b9a00
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     init
+  
+     diff --git a/foo b/foo
+     new file mode 100644
+     --- /dev/null
+     +++ b/foo
+     @@ -0,0 +1,5 @@
+     +0
+     +1
+     +2
+     +3
+     +4
+  
 
 With --template.
 


More information about the Mercurial-devel mailing list