comparison mercurial/templatefilters.py @ 44590:e3e44e6e7245

templater: fix cbor() filter to accept smartset So the wrapper type can return a bare smartset.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 15 Mar 2020 22:01:38 +0900
parents fa246ada356b
children 7333e8bb9781
comparison
equal deleted inserted replaced
44589:fc1fa3a07af6 44590:e3e44e6e7245
16 encoding, 16 encoding,
17 error, 17 error,
18 node, 18 node,
19 pycompat, 19 pycompat,
20 registrar, 20 registrar,
21 smartset,
21 templateutil, 22 templateutil,
22 url, 23 url,
23 util, 24 util,
24 ) 25 )
25 from .utils import ( 26 from .utils import (
106 107
107 108
108 @templatefilter(b'cbor') 109 @templatefilter(b'cbor')
109 def cbor(obj): 110 def cbor(obj):
110 """Any object. Serializes the object to CBOR bytes.""" 111 """Any object. Serializes the object to CBOR bytes."""
112 if isinstance(obj, smartset.abstractsmartset):
113 # cborutil is stricter about type than json() filter
114 obj = list(obj)
111 return b''.join(cborutil.streamencode(obj)) 115 return b''.join(cborutil.streamencode(obj))
112 116
113 117
114 @templatefilter(b'commondir') 118 @templatefilter(b'commondir')
115 def commondir(filelist): 119 def commondir(filelist):