Re: [PATCH v2] i18n: make the locale directory name the same string type as the datapath

2016-10-08 Thread Martijn Pieters
On 8 October 2016 at 14:20, Augie Fackler  wrote:

> # HG changeset patch
> # User Augie Fackler 
> # Date 1475918778 14400
> #  Sat Oct 08 05:26:18 2016 -0400
> # Node ID 392dc40e200e6fdc3ee5172c949b81cc56163e62
> # Parent  87b8e40eb8125d5ddc848d972b117989346057dd
> i18n: make the locale directory name the same string type as the datapath
>
> diff --git a/mercurial/i18n.py b/mercurial/i18n.py
> --- a/mercurial/i18n.py
> +++ b/mercurial/i18n.py
> @@ -49,7 +49,11 @@ if (os.name == 'nt'
>  _ugettext = None
>
>  def setdatapath(datapath):
> -localedir = os.path.join(datapath, 'locale')
> +if isinstance(datapath, unicode):
> +locpart = u'locale'
> +else:
> +locpart = 'locale'
> +localedir = os.path.join(datapath, locpart)
>

Since datapath is basically always sysstr (either __file__ or
sys.executable), just use sysstr('locale') here.


>  t = gettextmod.translation('hg', localedir, _languages, fallback=True)
>  global _ugettext
>  try:
> diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
> --- a/tests/test-check-py3-compat.t
> +++ b/tests/test-check-py3-compat.t
> @@ -16,96 +16,83 @@
>$ hg files 'set:(**.py) - grep(pygments)' | sed 's|\\|/|g' \
>> | xargs $PYTHON3 contrib/check-py3-compat.py \
>> | sed 's/[0-9][0-9]*)$/*)/'
> -  hgext/acl.py: error importing:  Can't mix strings and bytes
> in path components (error at i18n.py:*)
> -  hgext/automv.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/blackbox.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/bugzilla.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/censor.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/chgserver.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/children.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/churn.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> -  hgext/clonebundles.py: error importing:  Can't mix strings
> and bytes in path components (error at i18n.py:*)
> -  hgext/color.py: error importing:  Can't mix strings and
> bytes in path components (error at i18n.py:*)
> +  hgext/automv.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/blackbox.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/bugzilla.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/censor.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/chgserver.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/children.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/churn.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/clonebundles.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/color.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
>hgext/convert/bzr.py: error importing module:  Parent
> module 'hgext.convert' not loaded, cannot perform relative import (line *)
> -  hgext/convert/common.py: error importing:  Can't mix strings
> and bytes in path components (error at i18n.py:*)
> -  hgext/convert/convcmd.py: error importing:  Can't mix
> strings and bytes in path components (error at i18n.py:*)
> -  hgext/convert/cvs.py: error importing:  Can't mix strings
> and bytes in path components (error at i18n.py:*)
> -  hgext/convert/cvsps.py: error importing:  Can't mix strings
> and bytes in path components (error at i18n.py:*)
> -  hgext/convert/darcs.py: error importing:  Can't mix strings
> and bytes in path components (error at i18n.py:*)
> +  hgext/convert/common.py: error importing module: 
> module 'mercurial.util' has no attribute 'pickle' (line *)
> +  hgext/convert/convcmd.py: error importing:  module
> 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> +  hgext/convert/cvs.py: error importing module:  Parent
> module 'hgext.convert' not loaded, cannot perform relative import (line *)
> +  hgext/convert/cvsps.py: error importing:  module
> 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/convert/darcs.py: error importing module:  Parent
> module 'hgext.convert' not loaded, cannot perform relative import (line *)
>hgext/convert/filemap.py: error importing module:  Parent
> module 'hgext.convert' not loaded, 

[PATCH v2] i18n: make the locale directory name the same string type as the datapath

2016-10-08 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1475918778 14400
#  Sat Oct 08 05:26:18 2016 -0400
# Node ID 392dc40e200e6fdc3ee5172c949b81cc56163e62
# Parent  87b8e40eb8125d5ddc848d972b117989346057dd
i18n: make the locale directory name the same string type as the datapath

diff --git a/mercurial/i18n.py b/mercurial/i18n.py
--- a/mercurial/i18n.py
+++ b/mercurial/i18n.py
@@ -49,7 +49,11 @@ if (os.name == 'nt'
 _ugettext = None
 
 def setdatapath(datapath):
-localedir = os.path.join(datapath, 'locale')
+if isinstance(datapath, unicode):
+locpart = u'locale'
+else:
+locpart = 'locale'
+localedir = os.path.join(datapath, locpart)
 t = gettextmod.translation('hg', localedir, _languages, fallback=True)
 global _ugettext
 try:
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -16,96 +16,83 @@
   $ hg files 'set:(**.py) - grep(pygments)' | sed 's|\\|/|g' \
   > | xargs $PYTHON3 contrib/check-py3-compat.py \
   > | sed 's/[0-9][0-9]*)$/*)/'
-  hgext/acl.py: error importing:  Can't mix strings and bytes in 
path components (error at i18n.py:*)
-  hgext/automv.py: error importing:  Can't mix strings and bytes in 
path components (error at i18n.py:*)
-  hgext/blackbox.py: error importing:  Can't mix strings and bytes 
in path components (error at i18n.py:*)
-  hgext/bugzilla.py: error importing:  Can't mix strings and bytes 
in path components (error at i18n.py:*)
-  hgext/censor.py: error importing:  Can't mix strings and bytes in 
path components (error at i18n.py:*)
-  hgext/chgserver.py: error importing:  Can't mix strings and bytes 
in path components (error at i18n.py:*)
-  hgext/children.py: error importing:  Can't mix strings and bytes 
in path components (error at i18n.py:*)
-  hgext/churn.py: error importing:  Can't mix strings and bytes in 
path components (error at i18n.py:*)
-  hgext/clonebundles.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/color.py: error importing:  Can't mix strings and bytes in 
path components (error at i18n.py:*)
+  hgext/automv.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
+  hgext/blackbox.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
+  hgext/bugzilla.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
+  hgext/censor.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
+  hgext/chgserver.py: error importing:  module 
'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
+  hgext/children.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
+  hgext/churn.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
+  hgext/clonebundles.py: error importing:  module 
'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
+  hgext/color.py: error importing:  module 'mercurial.util' 
has no attribute 'stringio' (error at patch.py:*)
   hgext/convert/bzr.py: error importing module:  Parent module 
'hgext.convert' not loaded, cannot perform relative import (line *)
-  hgext/convert/common.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/convert/convcmd.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/convert/cvs.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/convert/cvsps.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/convert/darcs.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
+  hgext/convert/common.py: error importing module:  module 
'mercurial.util' has no attribute 'pickle' (line *)
+  hgext/convert/convcmd.py: error importing:  module 
'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
+  hgext/convert/cvs.py: error importing module:  Parent module 
'hgext.convert' not loaded, cannot perform relative import (line *)
+  hgext/convert/cvsps.py: error importing:  module 
'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
+  hgext/convert/darcs.py: error importing module:  Parent module 
'hgext.convert' not loaded, cannot perform relative import (line *)
   hgext/convert/filemap.py: error importing module:  Parent 
module 'hgext.convert' not loaded, cannot perform relative import (line *)
-  hgext/convert/git.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/convert/gnuarch.py: error importing:  Can't mix strings and 
bytes in path components (error at i18n.py:*)
-  hgext/convert/hg.py: error importing:  Can't mix strings and 
bytes in