Patchwork [1,of,2,STABLE] httppeer: properly gate debug usage behind debug flag check

login
register
mail settings
Submitter Boris Feld
Date May 21, 2018, 2:40 p.m.
Message ID <413f444c264455169af8.1526913606@FB>
Download mbox | patch
Permalink /patch/31776/
State Accepted
Headers show

Comments

Boris Feld - May 21, 2018, 2:40 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1525453606 -7200
#      Fri May 04 19:06:46 2018 +0200
# Branch stable
# Node ID 413f444c264455169af8ff0431a36f9901afc36a
# Parent  273ea09f65500ea7936afe2983bf6a126c5bf4e6
# EXP-Topic stable-dbg-bug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 413f444c2644
httppeer: properly gate debug usage behind debug flag check

The "dbg" local variable is only defined if the 'debugflag' is set to True.
However, it was used indiscriminately later in the function. We hide its usage
behind the 'debugflag' value to avoid raising a NameError.

Patch

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -319,7 +319,7 @@  def sendrequest(ui, opener, req):
         ui.traceback()
         raise IOError(None, inst)
     finally:
-        if ui.configbool('devel', 'debug.peer-request'):
+        if ui.debugflag and ui.configbool('devel', 'debug.peer-request'):
             dbg(line % '  finished in %.4f seconds (%d)'
                 % (util.timer() - start, res.code))