changeset 36196:1abf089a1d70

graphlog: deduplicate preprocessing of log command
author Yuya Nishihara <yuya@tcha.org>
date Sun, 21 Jan 2018 16:03:14 +0900
parents 513d268eddfe
children db26e6a0a677
files mercurial/commands.py mercurial/logcmdutil.py
diffstat 2 files changed, 5 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Feb 14 20:32:32 2018 +0800
+++ b/mercurial/commands.py	Sun Jan 21 16:03:14 2018 +0900
@@ -3424,7 +3424,6 @@
     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)
@@ -3439,6 +3438,10 @@
     ui.pager('log')
     displayer = logcmdutil.changesetdisplayer(ui, repo, opts, differ,
                                               buffered=True)
+    if opts.get('graph'):
+        logcmdutil.graphlog(ui, repo, revs, displayer, getrenamed)
+        return
+
     for rev in revs:
         ctx = repo[rev]
         copies = None
--- a/mercurial/logcmdutil.py	Wed Feb 14 20:32:32 2018 +0800
+++ b/mercurial/logcmdutil.py	Sun Jan 21 16:03:14 2018 +0900
@@ -899,19 +899,8 @@
             lines = []
     displayer.close()
 
-def graphlog(ui, repo, revs, differ, opts):
-    # Parameters are identical to log command ones
+def graphlog(ui, repo, revs, displayer, getrenamed):
     revdag = graphmod.dagwalker(repo, revs)
-
-    getrenamed = None
-    if opts.get('copies'):
-        endrev = None
-        if opts.get('rev'):
-            endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
-        getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
-
-    ui.pager('log')
-    displayer = changesetdisplayer(ui, repo, opts, differ, buffered=True)
     displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges, getrenamed)
 
 def checkunsupportedgraphflags(pats, opts):