Patchwork util: fix %-formatting on docstring by moving a closing parenthesis

login
register
mail settings
Submitter Augie Fackler
Date April 3, 2017, 11:04 p.m.
Message ID <8fae383fd416907579de.1491260642@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19943/
State Accepted
Headers show

Comments

Augie Fackler - April 3, 2017, 11:04 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1491260614 14400
#      Mon Apr 03 19:03:34 2017 -0400
# Node ID 8fae383fd416907579de2066e084219a53339dc3
# Parent  81abd0d12c8641df666d356f6033d84cd55977a8
util: fix %-formatting on docstring by moving a closing parenthesis

We have to do the % formatting over the sysstr, since the things we're
going to splat into it are themselves sysstrs. This is probably
technically wrong-ish, since bt is probably actually a bytestr here,
but this fixes the immediate issue, which was that hg was broken on
Python 3.
Yuya Nishihara - April 4, 2017, 2:33 p.m.
On Mon, 03 Apr 2017 19:04:02 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1491260614 14400
> #      Mon Apr 03 19:03:34 2017 -0400
> # Node ID 8fae383fd416907579de2066e084219a53339dc3
> # Parent  81abd0d12c8641df666d356f6033d84cd55977a8
> util: fix %-formatting on docstring by moving a closing parenthesis

Queued, thanks.

> We have to do the % formatting over the sysstr, since the things we're
> going to splat into it are themselves sysstrs. This is probably
> technically wrong-ish, since bt is probably actually a bytestr here,
> but this fixes the immediate issue, which was that hg was broken on
> Python 3.
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -3705,8 +3705,8 @@ def bundlecompressiontopics():
>          if not bt or not bt[0]:
>              continue
>  
> -        doc = pycompat.sysstr('``%s``\n    %s' % (
> -            bt[0], engine.bundletype.__doc__))
> +        doc = pycompat.sysstr('``%s``\n    %s') % (
> +            bt[0], engine.bundletype.__doc__)

Perhaps bt[0] could be sysstr() too.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -3705,8 +3705,8 @@  def bundlecompressiontopics():
         if not bt or not bt[0]:
             continue
 
-        doc = pycompat.sysstr('``%s``\n    %s' % (
-            bt[0], engine.bundletype.__doc__))
+        doc = pycompat.sysstr('``%s``\n    %s') % (
+            bt[0], engine.bundletype.__doc__)
 
         value = docobject()
         value.__doc__ = doc