# HG changeset patch # User Yuya Nishihara # Date 2018-04-01 14:12:37 # Node ID 9ac3e97b299bcc3fa0cfd36300e1f9543b8c1e4b # Parent 570a4426c5b850685ce03a28d9a4f0156938b5ca hgweb: lift {sessionvars} to a wrapped type Since a sessionvars object is updated in-place, we can't simply wrap it by mappinglist. diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -651,7 +651,7 @@ def diffstat(tmpl, ctx, statgen, parity) 'parity': next(parity), }) -class sessionvars(object): +class sessionvars(templateutil.wrapped): def __init__(self, vars, start='?'): self._start = start self._vars = vars @@ -665,7 +665,7 @@ class sessionvars(object): def __copy__(self): return sessionvars(copy.copy(self._vars), self._start) - def __iter__(self): + def itermaps(self, context): separator = self._start for key, value in sorted(self._vars.iteritems()): yield {'name': key, @@ -674,6 +674,16 @@ class sessionvars(object): } separator = '&' + def join(self, context, mapping, sep): + # could be '{separator}{name}={value|urlescape}' + raise error.ParseError(_('not displayable without template')) + + def show(self, context, mapping): + return self.join(context, '') + + def tovalue(self, context, mapping): + return self._vars + class wsgiui(uimod.ui): # default termwidth breaks under mod_wsgi def termwidth(self):