templater: add hex filter.
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Wed, 22 Sep 2010 00:14:57 +0200
changeset 12371 48a4acd1ccf1
parent 12370 f98010f57a5e
child 12372 5163e3c8aa52
templater: add hex filter.
mercurial/help/templates.txt
mercurial/templatefilters.py
--- a/mercurial/help/templates.txt	Tue Sep 21 18:40:33 2010 +0200
+++ b/mercurial/help/templates.txt	Wed Sep 22 00:14:57 2010 +0200
@@ -106,6 +106,9 @@
 :escape: Any text. Replaces the special XML/XHTML characters "&", "<"
     and ">" with XML entities.
 
+:hex: Any text. Convert a binary Mercurial node identifier into
+    its long hexadecimal representation.
+
 :fill68: Any text. Wraps the text to fit in 68 columns.
 
 :fill76: Any text. Wraps the text to fit in 76 columns.
--- a/mercurial/templatefilters.py	Tue Sep 21 18:40:33 2010 +0200
+++ b/mercurial/templatefilters.py	Wed Sep 22 00:14:57 2010 +0200
@@ -6,7 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 import cgi, re, os, time, urllib
-import util, encoding
+import encoding, node, util
 
 def stringify(thing):
     '''turn nested template iterator into string.'''
@@ -216,6 +216,7 @@
     "person": person,
     "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"),
     "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"),
+    "hex": node.hex,
     "short": lambda x: x[:12],
     "shortdate": util.shortdate,
     "stringify": stringify,