##// END OF EJS Templates
templater: fix cbor() filter to recursively convert smartset to list...
Yuya Nishihara -
r45087:7333e8bb default
parent child Browse files
Show More
@@ -106,12 +106,17 b' def basename(path):'
106 106 return os.path.basename(path)
107 107
108 108
109 def _tocborencodable(obj):
110 if isinstance(obj, smartset.abstractsmartset):
111 return list(obj)
112 return obj
113
114
109 115 @templatefilter(b'cbor')
110 116 def cbor(obj):
111 117 """Any object. Serializes the object to CBOR bytes."""
112 if isinstance(obj, smartset.abstractsmartset):
113 118 # cborutil is stricter about type than json() filter
114 obj = list(obj)
119 obj = pycompat.rapply(_tocborencodable, obj)
115 120 return b''.join(cborutil.streamencode(obj))
116 121
117 122
@@ -1616,6 +1616,15 b' Test cbor filter:'
1616 1616 ]
1617 1617 ]
1618 1618
1619 $ hg log -T "{dict(foo=revset('.'))|cbor}" -R a -l1 | "$PYTHON" "$TESTTMP/decodecbor.py"
1620 [
1621 {
1622 'foo': [
1623 10
1624 ]
1625 }
1626 ]
1627
1619 1628 json filter should escape HTML tags so that the output can be embedded in hgweb:
1620 1629
1621 1630 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
General Comments 0
You need to be logged in to leave comments. Login now