From 447fc0728512ffaf40f02d7d803b395328acafda Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 28 Jun 2016 20:10:56 -0700 Subject: [PATCH] hg-fast-export.py: do not mangle UTF-8 characters Set the proper values so that UTF-8 characters in the source repository are exported without mangling them to '?' characters. With this change, the current value of LANG and LC_XXX environment variables have absolutely NO effect on the fast-export result which is how it should be. Signed-off-by: Kyle J. McKay --- hg-fast-export.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index 054d521..2c7a0b5 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -3,13 +3,19 @@ # Copyright (c) 2007, 2008 Rocco Rutte and others. # License: MIT +import sys +import os + +sys = reload(sys) +sys.setdefaultencoding("utf-8") +os.environ["HGENCODING"] = "UTF-8" +os.environ["HGENCODINGMODE"] = "replace" + from mercurial import node from hg2git import setup_repo,fixup_user,get_branch,get_changeset from hg2git import load_cache,save_cache,get_git_sha1,set_default_branch,set_origin_name,set_unknown_addr from optparse import OptionParser import re -import sys -import os if sys.platform == "win32": # On Windows, sys.stdout is initially opened in text mode, which means that -- 2.11.4.GIT