Patchwork [5,of,7] py3: make scmutil.rcpath() return bytes

login
register
mail settings
Submitter Pulkit Goyal
Date Nov. 2, 2016, 10:23 p.m.
Message ID <9e259e7b59b6358eb842.1478125390@pulkit-goyal>
Download mbox | patch
Permalink /patch/17302/
State Accepted
Headers show

Comments

Pulkit Goyal - Nov. 2, 2016, 10:23 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1478120266 -19800
#      Thu Nov 03 02:27:46 2016 +0530
# Node ID 9e259e7b59b6358eb842eabbc99f4c18a4cc5009
# Parent  e0e794c3b580b1f64d37ccdd6d8bd606eb87880e
py3: make scmutil.rcpath() return bytes

In the whole series we are dealing with path varaibles which must be bytes
on UNIX. This patch make sure scmutil.rcpath() returns bytes independent of
which platform is used on Python 3. If we want to change type for windows we
can just conditionalize the return variable.
Yuya Nishihara - Nov. 4, 2016, 3:43 a.m.
On Thu, 03 Nov 2016 03:53:10 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1478120266 -19800
> #      Thu Nov 03 02:27:46 2016 +0530
> # Node ID 9e259e7b59b6358eb842eabbc99f4c18a4cc5009
> # Parent  e0e794c3b580b1f64d37ccdd6d8bd606eb87880e
> py3: make scmutil.rcpath() return bytes
> 
> In the whole series we are dealing with path varaibles which must be bytes
> on UNIX. This patch make sure scmutil.rcpath() returns bytes independent of
> which platform is used on Python 3. If we want to change type for windows we
> can just conditionalize the return variable.
> 
> diff -r e0e794c3b580 -r 9e259e7b59b6 mercurial/scmutil.py
> --- a/mercurial/scmutil.py	Thu Nov 03 02:17:01 2016 +0530
> +++ b/mercurial/scmutil.py	Thu Nov 03 02:27:46 2016 +0530
> @@ -755,7 +755,8 @@
>      if _rcpath is None:
>          if 'HGRCPATH' in encoding.environ:
>              _rcpath = []
> -            for p in os.environ['HGRCPATH'].split(os.pathsep):
> +            pathsep = os.pathsep.encode('ascii')
> +            for p in encoding.environ['HGRCPATH'].split(pathsep):

Same here. We would probably want pycompat.pathsep?

Patch

diff -r e0e794c3b580 -r 9e259e7b59b6 mercurial/scmutil.py
--- a/mercurial/scmutil.py	Thu Nov 03 02:17:01 2016 +0530
+++ b/mercurial/scmutil.py	Thu Nov 03 02:27:46 2016 +0530
@@ -755,7 +755,8 @@ 
     if _rcpath is None:
         if 'HGRCPATH' in encoding.environ:
             _rcpath = []
-            for p in os.environ['HGRCPATH'].split(os.pathsep):
+            pathsep = os.pathsep.encode('ascii')
+            for p in encoding.environ['HGRCPATH'].split(pathsep):
                 if not p:
                     continue
                 p = util.expandpath(p)