Mercurial > kallithea
changeset 7274:0188f3e33c54
hg: support introduction of wsgiresponse in Mercurial 4.6
Lock tests would fail without this.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 11 May 2018 14:26:48 +0200 |
parents | 52983fa97f49 |
children | 0efbf3f48bdd |
files | kallithea/lib/middleware/simplehg.py |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/middleware/simplehg.py Fri May 11 14:26:48 2018 +0200 +++ b/kallithea/lib/middleware/simplehg.py Fri May 11 14:26:48 2018 +0200 @@ -172,13 +172,21 @@ class HgWebWrapper(hgweb_mod.hgweb): # Work-around for Mercurial 3.6+ causing lock exceptions to be # thrown late - def _runwsgi(self, req, repo): + def _runwsgi(self, *args): try: - return super(HgWebWrapper, self)._runwsgi(req, repo) + return super(HgWebWrapper, self)._runwsgi(*args) except HTTPLockedRC as e: log.debug('Locked, response %s: %s', e.code, e.title) - req.respond(e.status, 'text/plain') - return '' + try: + req, res, repo = args + res.status = e.status + res.headers['Content-Type'] = 'text/plain' + res.setbodybytes('') + return res.sendresponse() + except ValueError: # wsgiresponse was introduced in Mercurial 4.6 (a88d68dc3ee8) + req, repo = args + req.respond(e.status, 'text/plain') + return '' return HgWebWrapper(repo_name, name=repo_name, baseui=baseui)