comparison mercurial/hgweb/protocol.py @ 6265:be76e54570f0

Issue937: error messages from hooks not sent over HTTP. Turns out that stderr - where ui.warn would send messages - was not being proxied over the HTTP connection. stdout was, and it seems you need both. (The streams are interleaved for readability.) Tested on Ubuntu 7.10 with lighttpd on hgweb.cgi with HTTP Basic auth, no SSL, using a changeset failing win32text.forbidcrlf.
author Jesse Glick <jesse.glick@sun.com>
date Mon, 25 Feb 2008 09:55:57 -0500
parents e75aab656f46
children e29557d687c9
comparison
equal deleted inserted replaced
6264:3a775af0bc9f 6265:be76e54570f0
173 raise ValueError('unknown bundle compression type') 173 raise ValueError('unknown bundle compression type')
174 gen = changegroupmod.unbundle(header, fp) 174 gen = changegroupmod.unbundle(header, fp)
175 175
176 # send addchangegroup output to client 176 # send addchangegroup output to client
177 177
178 old_stdout = sys.stdout 178 oldio = sys.stdout, sys.stderr
179 sys.stdout = cStringIO.StringIO() 179 sys.stderr = sys.stdout = cStringIO.StringIO()
180 180
181 try: 181 try:
182 url = 'remote:%s:%s' % (proto, 182 url = 'remote:%s:%s' % (proto,
183 req.env.get('REMOTE_HOST', '')) 183 req.env.get('REMOTE_HOST', ''))
184 try: 184 try:
186 except util.Abort, inst: 186 except util.Abort, inst:
187 sys.stdout.write("abort: %s\n" % inst) 187 sys.stdout.write("abort: %s\n" % inst)
188 ret = 0 188 ret = 0
189 finally: 189 finally:
190 val = sys.stdout.getvalue() 190 val = sys.stdout.getvalue()
191 sys.stdout = old_stdout 191 sys.stdout, sys.stderr = oldio
192 req.write('%d\n' % ret) 192 req.write('%d\n' % ret)
193 req.write(val) 193 req.write(val)
194 finally: 194 finally:
195 del lock 195 del lock
196 except ValueError, inst: 196 except ValueError, inst: