Patchwork [2,of,2,STABLE] httppeer: declare 'dgb' at the function level

login
register
mail settings
Submitter Boris Feld
Date May 21, 2018, 2:40 p.m.
Message ID <06458d4a1ca84506d042.1526913607@FB>
Download mbox | patch
Permalink /patch/31777/
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 1526908486 -7200
#      Mon May 21 15:14:46 2018 +0200
# Branch stable
# Node ID 06458d4a1ca84506d04280052d0288221b2701f0
# Parent  413f444c264455169af8ff0431a36f9901afc36a
# EXP-Topic stable-dbg-bug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 06458d4a1ca8
httppeer: declare 'dgb' at the function level

As we just saw in the previous changeset, having the variable defined into a
branch creates bug. This is a cheap to move it at the function level.
Yuya Nishihara - May 22, 2018, 11:51 a.m.
On Mon, 21 May 2018 16:40:07 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1526908486 -7200
> #      Mon May 21 15:14:46 2018 +0200
> # Branch stable
> # Node ID 06458d4a1ca84506d04280052d0288221b2701f0
> # Parent  413f444c264455169af8ff0431a36f9901afc36a
> # EXP-Topic stable-dbg-bug
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 06458d4a1ca8
> httppeer: declare 'dgb' at the function level

Queued for stable, thanks.

FWIW, I slight prefer not aliasing ui.debug at all as there are just a few
users.

Patch

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -277,9 +277,9 @@  def sendrequest(ui, opener, req):
 
     Returns the response object.
     """
+    dbg = ui.debug
     if (ui.debugflag
         and ui.configbool('devel', 'debug.peer-request')):
-        dbg = ui.debug
         line = 'devel-peer-request: %s\n'
         dbg(line % '%s %s' % (pycompat.bytesurl(req.get_method()),
                               pycompat.bytesurl(req.get_full_url())))