changeset 85e819acff48 in tryton-tools:default
details: https://hg.tryton.org/tryton-tools?cmd=changeset;node=85e819acff48
description:
Add Python3 support to hglookup
diffstat:
hglookup.py | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diffs (59 lines):
diff -r 61921472cad4 -r 85e819acff48 hglookup.py
--- a/hglookup.py Sun Sep 27 12:43:17 2020 +0200
+++ b/hglookup.py Sun Sep 27 14:14:37 2020 +0200
@@ -9,10 +9,10 @@
from mercurial.hgweb.hgwebdir_mod import findrepos
from mercurial import hg, ui, node as hgnode, error
-HTTP_SEE_OTHER = '303 See Other'
-HTTP_NOT_FOUND = '404 Not Found'
-TEXT_PLAIN = 'text/plain'
-SERIES = re.compile('^([0-9.]+)/')
+HTTP_SEE_OTHER = b'303 See Other'
+HTTP_NOT_FOUND = b'404 Not Found'
+TEXT_PLAIN = b'text/plain'
+SERIES = re.compile(b'^([0-9.]+)/')
class hglookup(object):
@@ -24,18 +24,18 @@
def __call__(self, env, start_response):
req = parserequestfromenv(env)
res = wsgiresponse(req, start_response)
- node = req.rawenv.get('PATH_INFO', '')[len('/lookup'):].strip('/')
+ node = req.rawenv.get(b'PATH_INFO', b'')[len(b'/lookup'):].strip(b'/')
if not node:
res.status = HTTP_NOT_FOUND
- res.headers['Content-Type'] = TEXT_PLAIN
- res.setbodygen(['Usage: /lookup/HGHEXNODE\n'])
+ res.headers[b'Content-Type'] = TEXT_PLAIN
+ res.setbodygen([b'Usage: /lookup/HGHEXNODE\n'])
return res.sendresponse()
if node in self.cache:
res.status = HTTP_SEE_OTHER
- res.headers['Location'] = self.cache[node]
+ res.headers[b'Location'] = self.cache[node]
res.setbodygen([])
return res.sendresponse()
- for name, path in findrepos(self.ui.configitems('paths')):
+ for name, path in findrepos(self.ui.configitems(b'paths')):
if SERIES.match(name):
continue
repo = hg.repository(self.ui, path)
@@ -47,12 +47,12 @@
break
else:
res.status = HTTP_NOT_FOUND
- res.headers['Content-Type'] = TEXT_PLAIN
- res.setbodygen(['Specified changeset %s not found\n' % node])
+ res.headers[b'Content-Type'] = TEXT_PLAIN
+ res.setbodygen([b'Specified changeset %s not found\n' % node])
return res.sendresponse()
- url = '/%s/rev/%s/' % (name, hgnode.hex(full)[:12])
+ url = b'/%s/rev/%s/' % (name, hgnode.hex(full)[:12])
self.cache[node] = url
res.status = HTTP_SEE_OTHER
- res.headers['Location'] = url
+ res.headers[b'Location'] = url
res.setbodygen([])
return res.sendresponse()