diff 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
line wrap: on
line diff
--- a/mercurial/templatefilters.py	Sun Mar 15 15:12:44 2020 +0900
+++ b/mercurial/templatefilters.py	Sun Mar 15 22:01:38 2020 +0900
@@ -18,6 +18,7 @@
     node,
     pycompat,
     registrar,
+    smartset,
     templateutil,
     url,
     util,
@@ -108,6 +109,9 @@
 @templatefilter(b'cbor')
 def cbor(obj):
     """Any object. Serializes the object to CBOR bytes."""
+    if isinstance(obj, smartset.abstractsmartset):
+        # cborutil is stricter about type than json() filter
+        obj = list(obj)
     return b''.join(cborutil.streamencode(obj))