Denis Laxalde a écrit :
# HG changeset patch
# User Denis Laxalde <de...@laxalde.org>
# Date 1518356534 -3600
#      Sun Feb 11 14:42:14 2018 +0100
# Node ID 72ad5a53d41102d5e67a925cabc1aa9635d1fda8
# Parent  50e9309bc899d5366811e8da9fe4dcc303aa4796
# EXP-Topic log/linerange-graph
log: make --line-range and --graph options work together

Please ignore this. This conflicts with Yuya's recent changes that got queued in the meantime.

Pass "hunksfilter" (computed in "if linerange:" block) down through
logcmdutil.graphlog() and logcmdutil.displaygraph() so that the
revhunksfilter function can be built and used by displayer.show(). The
logic is similar to the non-graph log case.

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:: @@ -3422,11 +3422,6 @@ def log(ui, repo, *pats, **opts):
      revs, filematcher = logcmdutil.getrevs(repo, pats, opts)
      hunksfilter = None
- if opts.get('graph'):
-        if linerange:
-            raise error.Abort(_('graph not supported with line range 
patterns'))
-        return logcmdutil.graphlog(ui, repo, revs, filematcher, opts)
-
      if linerange:
          revs, lrfilematcher, hunksfilter = logcmdutil.getlinerangerevs(
              repo, revs, opts)
@@ -3442,6 +3437,10 @@ def log(ui, repo, *pats, **opts):
          elif filematcher is None:
              filematcher = lrfilematcher
+ if opts.get('graph'):
+        return logcmdutil.graphlog(ui, repo, revs, filematcher, hunksfilter,
+                                   opts)
+
      getrenamed = None
      if opts.get('copies'):
          endrev = None
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -862,7 +862,7 @@ def _graphnodeformatter(ui, displayer):
      return formatnode
def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None,
-                 filematcher=None, props=None):
+                 filematcher=None, hunksfilter=None, props=None):
      props = props or {}
      formatnode = _graphnodeformatter(ui, displayer)
      state = graphmod.asciistate()
@@ -900,10 +900,14 @@ def displaygraph(ui, repo, dag, displaye
          revmatchfn = None
          if filematcher is not None:
              revmatchfn = filematcher(ctx.rev())
+        revhunksfilter = None
+        if hunksfilter:
+            revhunksfilter = hunksfilter(ctx.rev())
          edges = edgefn(type, char, state, rev, parents)
          firstedge = next(edges)
          width = firstedge[2]
          displayer.show(ctx, copies=copies, matchfn=revmatchfn,
+                       hunksfilterfn=revhunksfilter,
                         _graphwidth=width, **pycompat.strkwargs(props))
          lines = displayer.hunk.pop(rev).split('\n')
          if not lines[-1]:
@@ -914,7 +918,7 @@ def displaygraph(ui, repo, dag, displaye
              lines = []
      displayer.close()
-def graphlog(ui, repo, revs, filematcher, opts):
+def graphlog(ui, repo, revs, filematcher, hunksfilter, opts):
      # Parameters are identical to log command ones
      revdag = graphmod.dagwalker(repo, revs)
@@ -928,7 +932,7 @@ def graphlog(ui, repo, revs, filematcher
      ui.pager('log')
      displayer = changesetdisplayer(ui, repo, opts, buffered=True)
      displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges, getrenamed,
-                 filematcher)
+                 filematcher, hunksfilter)
def checkunsupportedgraphflags(pats, opts):
      for op in ["newest_first"]:
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. _______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to