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

Eugene Baranov eug.baranov at gmail.com
Mon Jul 27 07:30:09 CDT 2015


# HG changeset patch
# User Eugene Baranov <eug.baranov at 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.

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(


More information about the Mercurial-devel mailing list