Patchwork [v3,BC,stable] convert: by default use original local encoding when converting from Perforce

login
register
mail settings
Submitter Eugene Baranov
Date July 27, 2015, 12:30 p.m.
Message ID <12e9d866aa52ecd319a2.1438000209@ADNADTX6400256.eng.citrite.net>
Download mbox | patch
Permalink /patch/10065/
State Superseded
Headers show

Comments

Eugene Baranov - July 27, 2015, 12:30 p.m.
# HG changeset patch
# User Eugene Baranov <eug.baranov@gmail.com>
# Date 1437580631 -3600
#      Wed Jul 22 16:57:11 2015 +0100
# Branch stable
# Node ID 12e9d866aa52ecd319a2286fd4088adf1fbe87bc
# Parent  a74e9806d17d777595f02bef912da25b876cb56f
convert: by default use original local encoding when converting from Perforce

On Windows Perforce command line client uses default system locale to encode
output. Using 'latin_1' causes locale-specific characters to be replaces with
question marks. With this patch we will use default locale by default whilst
allowing to specify it explicity with 'convert.p4.encoding' config option.
Matt Mackall - July 27, 2015, 5:48 p.m.
On Mon, 2015-07-27 at 13:30 +0100, Eugene Baranov wrote:
> # HG changeset patch
> # User Eugene Baranov <eug.baranov@gmail.com>
> # Date 1437580631 -3600
> #      Wed Jul 22 16:57:11 2015 +0100
> # Branch stable
> # Node ID 12e9d866aa52ecd319a2286fd4088adf1fbe87bc
> # Parent  a74e9806d17d777595f02bef912da25b876cb56f
> convert: by default use original local encoding when converting from Perforce

Queued for stable, thanks.
Matt Mackall - July 27, 2015, 7:53 p.m.
On Mon, 2015-07-27 at 13:30 +0100, Eugene Baranov wrote:
> # HG changeset patch
> # User Eugene Baranov <eug.baranov@gmail.com>
> # Date 1437580631 -3600
> #      Wed Jul 22 16:57:11 2015 +0100
> # Branch stable
> # Node ID 12e9d866aa52ecd319a2286fd4088adf1fbe87bc
> # Parent  a74e9806d17d777595f02bef912da25b876cb56f
> convert: by default use original local encoding when converting from Perforce

The (BC) needs to be in the commit description for posterity. Also still
causing two test failures, please take a look.

Patch

diff -r a74e9806d17d -r 12e9d866aa52 hgext/convert/__init__.py
--- a/hgext/convert/__init__.py	Wed Jul 22 10:19:17 2015 +0800
+++ b/hgext/convert/__init__.py	Wed Jul 22 16:57:11 2015 +0100
@@ -323,8 +323,11 @@ 
     usually should specify a target directory, because otherwise the
     target may be named ``...-hg``.
 
-    It is possible to limit the amount of source history to be
-    converted by specifying an initial Perforce revision:
+    The following options can be set with ``--config``:
+
+    :convert.p4.encoding: specify the encoding to use when decoding standard
+        output of the Perforce command line tool. The default is default system
+        encoding.
 
     :convert.p4.startrev: specify initial Perforce revision (a
         Perforce changelist number).
diff -r a74e9806d17d -r 12e9d866aa52 hgext/convert/p4.py
--- a/hgext/convert/p4.py	Wed Jul 22 10:19:17 2015 +0800
+++ b/hgext/convert/p4.py	Wed Jul 22 16:57:11 2015 +0100
@@ -9,6 +9,7 @@ 
 from mercurial.i18n import _
 
 from common import commit, converter_source, checktool, NoRepo
+import convcmd
 import marshal
 import re
 
@@ -54,7 +55,8 @@ 
         self.tags = {}
         self.lastbranch = {}
         self.parent = {}
-        self.encoding = "latin_1"
+        self.encoding = self.ui.config('convert', 'p4.encoding',
+                                       default=convcmd.orig_encoding)
         self.depotname = {}           # mapping from local name to depot name
         self.localname = {} # mapping from depot name to local name
         self.re_type = re.compile(