Patchwork [6,of,6,py3] commands: make sure using byteschr rather than ascii values

login
register
mail settings
Submitter Pulkit Goyal
Date March 16, 2017, 4:13 a.m.
Message ID <63aeb39b5802644ae99e.1489637601@pulkit-goyal>
Download mbox | patch
Permalink /patch/19379/
State Changes Requested
Headers show

Comments

Pulkit Goyal - March 16, 2017, 4:13 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489635793 -19800
#      Thu Mar 16 09:13:13 2017 +0530
# Node ID 63aeb39b5802644ae99eaa5cf0666f3bf5cc4e90
# Parent  b5673a08993652a92c0e20a4e24d842194872454
commands: make sure using byteschr rather than ascii values

'MAR!?IC' is converted to their ascii values when slicing through it. This
patch converts them back to bytes string.
via Mercurial-devel - March 16, 2017, 4:44 a.m.
On Wed, Mar 15, 2017 at 9:13 PM, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489635793 -19800
> #      Thu Mar 16 09:13:13 2017 +0530
> # Node ID 63aeb39b5802644ae99eaa5cf0666f3bf5cc4e90
> # Parent  b5673a08993652a92c0e20a4e24d842194872454
> commands: make sure using byteschr rather than ascii values
>
> 'MAR!?IC' is converted to their ascii values when slicing through it. This
> patch converts them back to bytes string.
>
> diff -r b5673a089936 -r 63aeb39b5802 mercurial/commands.py
> --- a/mercurial/commands.py     Thu Mar 16 09:00:27 2017 +0530
> +++ b/mercurial/commands.py     Thu Mar 16 09:13:13 2017 +0530
> @@ -4768,6 +4768,8 @@
>      showchar = not opts.get('no_status')
>
>      for state, char, files in changestates:
> +        if pycompat.ispy3:
> +            char = bytes([char])

I'd prefer to wrap 'MAR!?C' in pycompat.iterbytestr() to avoid the
conditional here. What do you think?. Would that work?

>          if state in show:
>              label = 'status.' + state
>              for f in files:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r b5673a089936 -r 63aeb39b5802 mercurial/commands.py
--- a/mercurial/commands.py	Thu Mar 16 09:00:27 2017 +0530
+++ b/mercurial/commands.py	Thu Mar 16 09:13:13 2017 +0530
@@ -4768,6 +4768,8 @@ 
     showchar = not opts.get('no_status')
 
     for state, char, files in changestates:
+        if pycompat.ispy3:
+            char = bytes([char])
         if state in show:
             label = 'status.' + state
             for f in files: