Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.py @ 38502:2279d90eed9a
httppeer: fix use of uninitialized variable with devel logging
If the request fails, "res" was uninitialized.
Differential Revision: https://phab.mercurial-scm.org/D3860
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 29 Jun 2018 14:14:35 -0700 |
parents | ead71b15efd5 |
children | e7aa113b14f7 |
comparison
equal
deleted
inserted
replaced
38501:53800d6eed26 | 38502:2279d90eed9a |
---|---|
304 length = len(data) | 304 length = len(data) |
305 dbg(line % ' %d bytes of data' % length) | 305 dbg(line % ' %d bytes of data' % length) |
306 | 306 |
307 start = util.timer() | 307 start = util.timer() |
308 | 308 |
309 res = None | |
309 try: | 310 try: |
310 res = opener.open(req) | 311 res = opener.open(req) |
311 except urlerr.httperror as inst: | 312 except urlerr.httperror as inst: |
312 if inst.code == 401: | 313 if inst.code == 401: |
313 raise error.Abort(_('authorization failed')) | 314 raise error.Abort(_('authorization failed')) |
317 util.hidepassword(req.get_full_url())) | 318 util.hidepassword(req.get_full_url())) |
318 ui.traceback() | 319 ui.traceback() |
319 raise IOError(None, inst) | 320 raise IOError(None, inst) |
320 finally: | 321 finally: |
321 if ui.debugflag and ui.configbool('devel', 'debug.peer-request'): | 322 if ui.debugflag and ui.configbool('devel', 'debug.peer-request'): |
323 code = res.code if res else -1 | |
322 dbg(line % ' finished in %.4f seconds (%d)' | 324 dbg(line % ' finished in %.4f seconds (%d)' |
323 % (util.timer() - start, res.code)) | 325 % (util.timer() - start, code)) |
324 | 326 |
325 # Insert error handlers for common I/O failures. | 327 # Insert error handlers for common I/O failures. |
326 _wraphttpresponse(res) | 328 _wraphttpresponse(res) |
327 | 329 |
328 return res | 330 return res |