[PATCH 1 of 9] templatekw: extract non-templatekw function as getgraphnode()

Yuya Nishihara yuya at tcha.org
Tue Feb 27 14:57:54 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1519536512 -32400
#      Sun Feb 25 14:28:32 2018 +0900
# Node ID 064d43a16f215e00bc3093733707fd7b9fa1bf56
# Parent  432b85a46717b6852b4550e210c72b21a67012ec
templatekw: extract non-templatekw function as getgraphnode()

Prepares for switching to the (context, mapping) API. We still need (repo, ctx)
function for the fast path.

diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -837,7 +837,7 @@ def getlinerangerevs(repo, userrevs, opt
 def _graphnodeformatter(ui, displayer):
     spec = ui.config('ui', 'graphnodetemplate')
     if not spec:
-        return templatekw.showgraphnode  # fast path for "{graphnode}"
+        return templatekw.getgraphnode  # fast path for "{graphnode}"
 
     spec = templater.unquotestring(spec)
     tres = formatter.templateresources(ui)
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -528,6 +528,9 @@ def showfiles(**args):
 def showgraphnode(repo, ctx, **args):
     """String. The character representing the changeset node in an ASCII
     revision graph."""
+    return getgraphnode(repo, ctx)
+
+def getgraphnode(repo, ctx):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]


More information about the Mercurial-devel mailing list