# HG changeset patch # User Yuya Nishihara # Date 2020-03-15 13:01:38 # Node ID e3e44e6e72456ad244bb85449d6e6eb53c64c65e # Parent fc1fa3a07af60641c96fd3b8e2b40e1ab2eba17a templater: fix cbor() filter to accept smartset So the wrapper type can return a bare smartset. diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -18,6 +18,7 @@ from . import ( node, pycompat, registrar, + smartset, templateutil, url, util, @@ -108,6 +109,9 @@ def basename(path): @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)) diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -474,7 +474,7 @@ class revslist(wrapped): return bool(self._revs) def tovalue(self, context, mapping): - return list(self._revs) + return self._revs class _mappingsequence(wrapped):