Patchwork [02,of,10,py3] hg: avoid sending unicode url into config infrastructure

login
register
mail settings
Submitter Augie Fackler
Date Aug. 1, 2017, 8:34 p.m.
Message ID <8b22554199879f80a13d.1501619670@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/22610/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 1, 2017, 8:34 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1500906158 14400
#      Mon Jul 24 10:22:38 2017 -0400
# Node ID 8b22554199879f80a13ddee556bc540ddcb65a94
# Parent  87ee5c3b3271ded54fe4462aa43a9d1520b8a10b
hg: avoid sending unicode url into config infrastructure

This was causing some unfortunate breakage on Python 3.
Yuya Nishihara - Aug. 2, 2017, 3:07 p.m.
On Tue, 01 Aug 2017 16:34:30 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1500906158 14400
> #      Mon Jul 24 10:22:38 2017 -0400
> # Node ID 8b22554199879f80a13ddee556bc540ddcb65a94
> # Parent  87ee5c3b3271ded54fe4462aa43a9d1520b8a10b
> hg: avoid sending unicode url into config infrastructure
> 
> This was causing some unfortunate breakage on Python 3.
> 
> diff --git a/mercurial/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -31,6 +31,7 @@ from . import (
>      merge as mergemod,
>      node,
>      phases,
> +    pycompat,
>      repoview,
>      scmutil,
>      sshpeer,
> @@ -648,7 +649,8 @@ def clone(ui, peeropts, source, dest=Non
>              fp.write(template % defaulturl)
>              fp.close()
>  
> -            destrepo.ui.setconfig('paths', 'default', defaulturl, 'clone')
> +            destrepo.ui.setconfig(
> +                'paths', 'default', pycompat.bytesurl(defaulturl), 'clone')

Perhaps both template and defaulturl should be bytes. I'll send a fix.

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -31,6 +31,7 @@  from . import (
     merge as mergemod,
     node,
     phases,
+    pycompat,
     repoview,
     scmutil,
     sshpeer,
@@ -648,7 +649,8 @@  def clone(ui, peeropts, source, dest=Non
             fp.write(template % defaulturl)
             fp.close()
 
-            destrepo.ui.setconfig('paths', 'default', defaulturl, 'clone')
+            destrepo.ui.setconfig(
+                'paths', 'default', pycompat.bytesurl(defaulturl), 'clone')
 
             if update:
                 if update is not True: