Patchwork [1,of,2] templates: split getgraphnode() body into two functions

login
register
mail settings
Submitter Anton Shestakov
Date May 9, 2018, 4:20 a.m.
Message ID <223f04ec87e4d17492a7.1525839609@neuro>
Download mbox | patch
Permalink /patch/31425/
State Accepted
Headers show

Comments

Anton Shestakov - May 9, 2018, 4:20 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1525773297 -28800
#      Tue May 08 17:54:57 2018 +0800
# Node ID 223f04ec87e4d17492a7ea7dc4bab1d9bd5c9fdf
# Parent  92213f6745ed6f2c50feca9a2261b6f33a9a32fa
templates: split getgraphnode() body into two functions

getgraphnodecurrent() is checking if the node is currently checked out and
getgraphnodesymbol() is checking properties that have more to do with the
stored data and the DAG.
Yuya Nishihara - May 9, 2018, 11:51 a.m.
On Wed, 09 May 2018 12:20:09 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1525773297 -28800
> #      Tue May 08 17:54:57 2018 +0800
> # Node ID 223f04ec87e4d17492a7ea7dc4bab1d9bd5c9fdf
> # Parent  92213f6745ed6f2c50feca9a2261b6f33a9a32fa
> templates: split getgraphnode() body into two functions

Queued, thanks.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -392,12 +392,19 @@  def showgraphnode(context, mapping):
     return getgraphnode(repo, ctx)
 
 def getgraphnode(repo, ctx):
+    return getgraphnodecurrent(repo, ctx) or getgraphnodesymbol(ctx)
+
+def getgraphnodecurrent(repo, ctx):
     wpnodes = repo.dirstate.parents()
     if wpnodes[1] == nullid:
         wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return '@'
-    elif ctx.obsolete():
+    else:
+        return ''
+
+def getgraphnodesymbol(ctx):
+    if ctx.obsolete():
         return 'x'
     elif ctx.isunstable():
         return '*'