changeset 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 53800d6eed26
children 077301ac69dc
files mercurial/httppeer.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Sat Jun 30 11:33:05 2018 +0900
+++ b/mercurial/httppeer.py	Fri Jun 29 14:14:35 2018 -0700
@@ -306,6 +306,7 @@
 
         start = util.timer()
 
+    res = None
     try:
         res = opener.open(req)
     except urlerr.httperror as inst:
@@ -319,8 +320,9 @@
         raise IOError(None, inst)
     finally:
         if ui.debugflag and ui.configbool('devel', 'debug.peer-request'):
+            code = res.code if res else -1
             dbg(line % '  finished in %.4f seconds (%d)'
-                % (util.timer() - start, res.code))
+                % (util.timer() - start, code))
 
     # Insert error handlers for common I/O failures.
     _wraphttpresponse(res)