Patchwork crecord: fix statup crash of curses UI

login
register
mail settings
Submitter Laurent Charignon
Date March 18, 2015, 5:47 p.m.
Message ID <e236783e45df422cee4e.1426700871@dev919.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8146/
State Superseded
Headers show

Comments

Laurent Charignon - March 18, 2015, 5:47 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1426700642 25200
#      Wed Mar 18 10:44:02 2015 -0700
# Node ID e236783e45df422cee4ec7f9732d35100b05fb0d
# Parent  365b6d3e8e5046ab0e538686dd8cf25f73efa039
crecord: fix statup crash of curses UI

Introduced by 7d5f935bd705, not caught by the tests as they don't cover the UI
code
Matt Mackall - March 18, 2015, 6:36 p.m.
On Wed, 2015-03-18 at 10:47 -0700, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1426700642 25200
> #      Wed Mar 18 10:44:02 2015 -0700
> # Node ID e236783e45df422cee4ec7f9732d35100b05fb0d
> # Parent  365b6d3e8e5046ab0e538686dd8cf25f73efa039
> crecord: fix statup crash of curses UI
> 
> Introduced by 7d5f935bd705, not caught by the tests as they don't cover the UI
> code
> 
> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
> --- a/mercurial/crecord.py
> +++ b/mercurial/crecord.py
> @@ -872,7 +872,7 @@
>          width = self.xscreensize
>          # turn tabs into spaces
>          instr = instr.expandtabs(4)
> -        strwidth = encoding.ucolwidth(instr)
> +        strwidth = encoding.ucolwidth(unicode(instr))

Actually, the fix is to simply drop the u from ucolwidth, my bad. Please
avoid using unicode() wherever possible.
Laurent Charignon - March 18, 2015, 8:04 p.m.
Cool, I tested and sent a V2 for this one.

Thanks,

Laurent

On 3/18/15, 11:36 AM, "Matt Mackall" <mpm@selenic.com> wrote:

>On Wed, 2015-03-18 at 10:47 -0700, Laurent Charignon wrote:
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon@fb.com>
>> # Date 1426700642 25200
>> #      Wed Mar 18 10:44:02 2015 -0700
>> # Node ID e236783e45df422cee4ec7f9732d35100b05fb0d
>> # Parent  365b6d3e8e5046ab0e538686dd8cf25f73efa039
>> crecord: fix statup crash of curses UI
>> 
>> Introduced by 7d5f935bd705, not caught by the tests as they don't cover
>>the UI
>> code
>> 
>> diff --git a/mercurial/crecord.py b/mercurial/crecord.py
>> --- a/mercurial/crecord.py
>> +++ b/mercurial/crecord.py
>> @@ -872,7 +872,7 @@
>>          width = self.xscreensize
>>          # turn tabs into spaces
>>          instr = instr.expandtabs(4)
>> -        strwidth = encoding.ucolwidth(instr)
>> +        strwidth = encoding.ucolwidth(unicode(instr))
>
>Actually, the fix is to simply drop the u from ucolwidth, my bad. Please
>avoid using unicode() wherever possible.
>
>-- 
>Mathematics is the supreme nostalgia of our time.
>
>

Patch

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -872,7 +872,7 @@ 
         width = self.xscreensize
         # turn tabs into spaces
         instr = instr.expandtabs(4)
-        strwidth = encoding.ucolwidth(instr)
+        strwidth = encoding.ucolwidth(unicode(instr))
         numspaces = (width - ((strwidth + xstart) % width) - 1)
         return instr + " " * numspaces + "\n"