comparison mercurial/hgweb/hgweb_mod.py @ 4095:6fa7a2d0fc2e

hgweb: catch util.Abort raised by addchangegroup Right now, if a pretxnchangegroup hook fails, we send some HTML error message to the client and the transaction is not rolled back (issue499). Catching util.Abort allows us to send a decent message to the client and for some reason makes the rollback complete. This patch is not perfect since it doesn't fix the reason why the transaction wasn't rolled back (maybe some circular references?). Also, the transaction is aborted only after we've sent the response back to the client and the "transaction aborted" message ends up in the logs of the web server.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 16 Feb 2007 05:10:43 -0200
parents 9c8488490724
children 49237d6ae97d f5b9edf3390b
comparison
equal deleted inserted replaced
4094:fbf0e9acfd83 4095:6fa7a2d0fc2e
1145 sys.stdout = cStringIO.StringIO() 1145 sys.stdout = cStringIO.StringIO()
1146 1146
1147 try: 1147 try:
1148 url = 'remote:%s:%s' % (proto, 1148 url = 'remote:%s:%s' % (proto,
1149 req.env.get('REMOTE_HOST', '')) 1149 req.env.get('REMOTE_HOST', ''))
1150 ret = self.repo.addchangegroup(util.chunkbuffer(gen), 1150 try:
1151 'serve', url) 1151 ret = self.repo.addchangegroup(util.chunkbuffer(gen),
1152 'serve', url)
1153 except util.Abort, inst:
1154 sys.stdout.write("abort: %s\n" % inst)
1155 ret = 0
1152 finally: 1156 finally:
1153 val = sys.stdout.getvalue() 1157 val = sys.stdout.getvalue()
1154 sys.stdout = old_stdout 1158 sys.stdout = old_stdout
1155 req.write('%d\n' % ret) 1159 req.write('%d\n' % ret)
1156 req.write(val) 1160 req.write(val)