Patchwork [01,of,12,py3] store: fix many single-byte ops to use slicing in _auxencode

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2017, 7:49 p.m.
Message ID <90b52b8ab62de4417fe1.1489348190@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/19220/
State Accepted
Headers show

Comments

Augie Fackler - March 12, 2017, 7:49 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1489297844 18000
#      Sun Mar 12 00:50:44 2017 -0500
# Node ID 90b52b8ab62de4417fe13b06e52e9ff312bb30f9
# Parent  8a17c541177f32348e248608b6a9dfd7fefdf517
store: fix many single-byte ops to use slicing in _auxencode
Gregory Szorc - March 12, 2017, 8:17 p.m.
On Sun, Mar 12, 2017 at 12:49 PM, Augie Fackler <raf@durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1489297844 18000
> #      Sun Mar 12 00:50:44 2017 -0500
> # Node ID 90b52b8ab62de4417fe13b06e52e9ff312bb30f9
> # Parent  8a17c541177f32348e248608b6a9dfd7fefdf517
> store: fix many single-byte ops to use slicing in _auxencode
>
>
This series LGTM


> diff --git a/mercurial/store.py b/mercurial/store.py
> --- a/mercurial/store.py
> +++ b/mercurial/store.py
> @@ -193,22 +193,22 @@ def _auxencode(path, dotencode):
>          if not n:
>              continue
>          if dotencode and n[0] in '. ':
> -            n = "~%02x" % ord(n[0]) + n[1:]
> +            n = "~%02x" % ord(n[0:1]) + n[1:]
>              path[i] = n
>          else:
>              l = n.find('.')
>              if l == -1:
>                  l = len(n)
>              if ((l == 3 and n[:3] in _winres3) or
> -                (l == 4 and n[3] <= '9' and n[3] >= '1'
> +                (l == 4 and n[3:4] <= '9' and n[3:4] >= '1'
>                          and n[:3] in _winres4)):
>                  # encode third letter ('aux' -> 'au~78')
> -                ec = "~%02x" % ord(n[2])
> +                ec = "~%02x" % ord(n[2:3])
>                  n = n[0:2] + ec + n[3:]
>                  path[i] = n
>          if n[-1] in '. ':
>              # encode last period or space ('foo...' -> 'foo..~2e')
> -            path[i] = n[:-1] + "~%02x" % ord(n[-1])
> +            path[i] = n[:-1] + "~%02x" % ord(n[-1:])
>      return path
>
>  _maxstorepathlen = 120
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Yuya Nishihara - March 12, 2017, 9:12 p.m.
On Sun, 12 Mar 2017 13:17:54 -0700, Gregory Szorc wrote:
> On Sun, Mar 12, 2017 at 12:49 PM, Augie Fackler <raf@durin42.com> wrote:
> 
> > # HG changeset patch
> > # User Augie Fackler <augie@google.com>
> > # Date 1489297844 18000
> > #      Sun Mar 12 00:50:44 2017 -0500
> > # Node ID 90b52b8ab62de4417fe13b06e52e9ff312bb30f9
> > # Parent  8a17c541177f32348e248608b6a9dfd7fefdf517
> > store: fix many single-byte ops to use slicing in _auxencode
> >
> >
> This series LGTM

Queued 1-7 and 12, thanks.

Patch

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -193,22 +193,22 @@  def _auxencode(path, dotencode):
         if not n:
             continue
         if dotencode and n[0] in '. ':
-            n = "~%02x" % ord(n[0]) + n[1:]
+            n = "~%02x" % ord(n[0:1]) + n[1:]
             path[i] = n
         else:
             l = n.find('.')
             if l == -1:
                 l = len(n)
             if ((l == 3 and n[:3] in _winres3) or
-                (l == 4 and n[3] <= '9' and n[3] >= '1'
+                (l == 4 and n[3:4] <= '9' and n[3:4] >= '1'
                         and n[:3] in _winres4)):
                 # encode third letter ('aux' -> 'au~78')
-                ec = "~%02x" % ord(n[2])
+                ec = "~%02x" % ord(n[2:3])
                 n = n[0:2] + ec + n[3:]
                 path[i] = n
         if n[-1] in '. ':
             # encode last period or space ('foo...' -> 'foo..~2e')
-            path[i] = n[:-1] + "~%02x" % ord(n[-1])
+            path[i] = n[:-1] + "~%02x" % ord(n[-1:])
     return path
 
 _maxstorepathlen = 120