[PATCH 1 of 4] graphlog: deduplicate preprocessing of log command

Yuya Nishihara yuya at tcha.org
Sun Feb 11 20:04:57 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1516518194 -32400
#      Sun Jan 21 16:03:14 2018 +0900
# Node ID 4ac232e6bbda8ab3c219c9cf9e647e18db11bb35
# Parent  f3d8f61c425d8213103910da5e4a4bb414461768
graphlog: deduplicate preprocessing of log command

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3424,7 +3424,6 @@ def log(ui, 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)
@@ -3439,6 +3438,10 @@ def log(ui, repo, *pats, **opts):
     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
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -899,19 +899,8 @@ def displaygraph(ui, repo, dag, displaye
             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):


More information about the Mercurial-devel mailing list