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

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 27, 2018, 2:57 p.m.
Message ID <064d43a16f215e00bc30.1519743474@mimosa>
Download mbox | patch
Permalink /patch/28470/
State New
Headers show

Comments

Yuya Nishihara - Feb. 27, 2018, 2:57 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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]