# HG changeset patch # User Matt Mackall # Date 1161155316 18000 # Node ID 233c733e4af5391f56aa8947ee2d38937b294f33 # Parent 3505fcd5a231d0022b85fc7d1e9fe27d67e41574 httprepo: add support for passing lookup exception data diff -r 3505fcd5a231 -r 233c733e4af5 mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Sat Sep 09 18:25:06 2006 -0700 +++ b/mercurial/hgweb/hgweb_mod.py Wed Oct 18 02:08:36 2006 -0500 @@ -884,7 +884,13 @@ req.write(self.filelog(self.filectx(req))) def do_lookup(self, req): - resp = hex(self.repo.lookup(req.form['key'][0])) + "\n" + try: + r = hex(self.repo.lookup(req.form['key'][0])) + success = 1 + except Exception,inst: + r = str(inst) + success = 0 + resp = "%s %s\n" % (success, r) req.httphdr("application/mercurial-0.1", length=len(resp)) req.write(resp) diff -r 3505fcd5a231 -r 233c733e4af5 mercurial/httprepo.py --- a/mercurial/httprepo.py Sat Sep 09 18:25:06 2006 -0700 +++ b/mercurial/httprepo.py Wed Oct 18 02:08:36 2006 -0500 @@ -262,12 +262,11 @@ fp.close() def lookup(self, key): - try: - d = self.do_cmd("lookup", key = key).read() - return bin(d[:-1]) - except: - self.ui.warn('Not able to look up revision named "%s"\n' % (key,)) - raise + d = self.do_cmd("lookup", key = key).read() + success, data = d[:-1].split(' ', 1) + if int(success): + return bin(data) + raise hg.RepoError(data) def heads(self): d = self.do_read("heads")