Patchwork py3: use codecs.decode() to decode a hex string in wireprotov1server

login
register
mail settings
Submitter Matt Harbison
Date Jan. 30, 2019, 8:46 p.m.
Message ID <22b3fe02a9646329df57.1548881189@Envy>
Download mbox | patch
Permalink /patch/38186/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 30, 2019, 8:46 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1548875230 18000
#      Wed Jan 30 14:07:10 2019 -0500
# Node ID 22b3fe02a9646329df57ede04abaa23490970131
# Parent  1a4a41d39dfc154a2df8accdf1760e04244628e4
py3: use codecs.decode() to decode a hex string in wireprotov1server

Previously, a clone was failing with

  LookupError: 'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs
Augie Fackler - Jan. 30, 2019, 9:24 p.m.
> On Jan 30, 2019, at 15:46, Matt Harbison <mharbison72@gmail.com> wrote:
> 
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1548875230 18000
> #      Wed Jan 30 14:07:10 2019 -0500
> # Node ID 22b3fe02a9646329df57ede04abaa23490970131
> # Parent  1a4a41d39dfc154a2df8accdf1760e04244628e4
> py3: use codecs.decode() to decode a hex string in wireprotov1server

I saw https://phab.mercurial-scm.org/D5755 before this, so this is effectively queued. Thanks!

> 
> Previously, a clone was failing with
> 
>  LookupError: 'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs
> 
> diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
> --- a/contrib/python3-whitelist
> +++ b/contrib/python3-whitelist
> @@ -503,6 +503,7 @@ test-profile.t
> test-progress.t
> test-propertycache.py
> test-pull-branch.t
> +test-pull-bundle.t
> test-pull-http.t
> test-pull-permission.t
> test-pull-pull-corruption.t
> diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
> --- a/mercurial/wireprotov1server.py
> +++ b/mercurial/wireprotov1server.py
> @@ -7,6 +7,7 @@
> 
> from __future__ import absolute_import
> 
> +import codecs
> import os
> 
> from .i18n import _
> @@ -344,7 +345,7 @@ def find_pullbundle(repo, proto, opts, c
>       one specific branch of many.
>     """
>     def decodehexstring(s):
> -        return set([h.decode('hex') for h in s.split(';')])
> +        return set([codecs.decode(h, 'hex') for h in s.split(';')])
> 
>     manifest = repo.vfs.tryread('pullbundles.manifest')
>     if not manifest:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - Jan. 30, 2019, 10:45 p.m.
On Wed, 30 Jan 2019 15:46:29 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1548875230 18000
> #      Wed Jan 30 14:07:10 2019 -0500
> # Node ID 22b3fe02a9646329df57ede04abaa23490970131
> # Parent  1a4a41d39dfc154a2df8accdf1760e04244628e4
> py3: use codecs.decode() to decode a hex string in wireprotov1server

> --- a/mercurial/wireprotov1server.py
> +++ b/mercurial/wireprotov1server.py
> @@ -7,6 +7,7 @@
>  
>  from __future__ import absolute_import
>  
> +import codecs
>  import os
>  
>  from .i18n import _
> @@ -344,7 +345,7 @@ def find_pullbundle(repo, proto, opts, c
>        one specific branch of many.
>      """
>      def decodehexstring(s):
> -        return set([h.decode('hex') for h in s.split(';')])
> +        return set([codecs.decode(h, 'hex') for h in s.split(';')])

I think binascii.unhexlify() (or node.bin()) is higher-level interface.

Patch

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -503,6 +503,7 @@  test-profile.t
 test-progress.t
 test-propertycache.py
 test-pull-branch.t
+test-pull-bundle.t
 test-pull-http.t
 test-pull-permission.t
 test-pull-pull-corruption.t
diff --git a/mercurial/wireprotov1server.py b/mercurial/wireprotov1server.py
--- a/mercurial/wireprotov1server.py
+++ b/mercurial/wireprotov1server.py
@@ -7,6 +7,7 @@ 
 
 from __future__ import absolute_import
 
+import codecs
 import os
 
 from .i18n import _
@@ -344,7 +345,7 @@  def find_pullbundle(repo, proto, opts, c
       one specific branch of many.
     """
     def decodehexstring(s):
-        return set([h.decode('hex') for h in s.split(';')])
+        return set([codecs.decode(h, 'hex') for h in s.split(';')])
 
     manifest = repo.vfs.tryread('pullbundles.manifest')
     if not manifest: