changeset 27215:5b8da5643a8a

templatekw: avoid slow creation of changectx objects in showgraphnode() This mitigates the minor perf regression introduced by the previous patch. % hg log -G -R mozilla-central -l10000 --time > /dev/null (original) real 2.200 secs (previous) real 2.590 secs (this) real 2.280 secs
author Yuya Nishihara <yuya@tcha.org>
date Sat, 14 Nov 2015 17:02:57 +0900
parents 60af96494a76
children 8117e2cd959e
files mercurial/templatekw.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Sat Nov 14 16:58:18 2015 +0900
+++ b/mercurial/templatekw.py	Sat Nov 14 17:02:57 2015 +0900
@@ -7,7 +7,7 @@
 
 from __future__ import absolute_import
 
-from .node import hex
+from .node import hex, nullid
 from . import (
     error,
     hbisect,
@@ -343,7 +343,9 @@
 def showgraphnode(repo, ctx, **args):
     """:graphnode: String. The character representing the changeset node in
     an ASCII revision graph"""
-    wpnodes = [pctx.node() for pctx in repo[None].parents()]
+    wpnodes = repo.dirstate.parents()
+    if wpnodes[1] == nullid:
+        wpnodes = wpnodes[:1]
     if ctx.node() in wpnodes:
         return '@'
     elif ctx.obsolete():