[PATCH 3 of 7] hgweb: lift {sessionvars} to a wrapped type
Yuya Nishihara
yuya at tcha.org
Sat Apr 14 12:49:13 UTC 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1522591957 -32400
# Sun Apr 01 23:12:37 2018 +0900
# Node ID b7742898a29d79f01beb36c1cedd58acfdab05ab
# Parent 8bee5eca0b75333eee2c555663ae535005505991
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):
More information about the Mercurial-devel
mailing list