mercurial/templatefilters.py
changeset 41997 4df7c4b70e03
parent 40029 e2697acd9381
child 43076 2372284d9457
--- a/mercurial/templatefilters.py	Sun Mar 10 12:57:24 2019 +0900
+++ b/mercurial/templatefilters.py	Sun Mar 10 13:07:36 2019 +0900
@@ -23,6 +23,7 @@
     util,
 )
 from .utils import (
+    cborutil,
     dateutil,
     stringutil,
 )
@@ -99,6 +100,11 @@
     """
     return os.path.basename(path)
 
+@templatefilter('cbor')
+def cbor(obj):
+    """Any object. Serializes the object to CBOR bytes."""
+    return b''.join(cborutil.streamencode(obj))
+
 @templatefilter('commondir')
 def commondir(filelist):
     """List of text. Treats each list item as file name with /