# HG changeset patch # User Patrick Mezard # Date 2010-01-02 15:42:00 # Node ID c2e2a5e6c36b0200bad9158878482ca844f30ce4 # Parent c2168d170f057e01f74f8fadd341e629fee28836 subrepo: force en_US.UTF-8 locale when calling svn Parser only knows about en_US output. Forcing the encoding to UTF-8 might not be the best thing to do since the caller may receive some of the subversion output, but at least it should prevent conversion errors from svn client. diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -261,7 +261,10 @@ class svnsubrepo(object): cmd = ['svn'] + commands + [self._path] cmd = [util.shellquote(arg) for arg in cmd] cmd = util.quotecommand(' '.join(cmd)) - write, read, err = util.popen3(cmd, newlines=True) + env = dict(os.environ) + for k in ('LANGUAGE', 'LANG', 'LC_ALL', 'LC_MESSAGES'): + env[k] = 'en_US.UTF-8' + write, read, err = util.popen3(cmd, env=env, newlines=True) retdata = read.read() err = err.read().strip() if err: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -39,22 +39,24 @@ def _fastsha1(s): import subprocess closefds = os.name == 'posix' -def popen2(cmd, newlines=False): +def popen2(cmd, env=None, newlines=False): # Setting bufsize to -1 lets the system decide the buffer size. # The default for bufsize is 0, meaning unbuffered. This leads to # poor performance on Mac OS X: http://bugs.python.org/issue4194 p = subprocess.Popen(cmd, shell=True, bufsize=-1, close_fds=closefds, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - universal_newlines=newlines) + universal_newlines=newlines, + env=env) return p.stdin, p.stdout -def popen3(cmd, newlines=False): +def popen3(cmd, env=None, newlines=False): p = subprocess.Popen(cmd, shell=True, bufsize=-1, close_fds=closefds, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - universal_newlines=newlines) + universal_newlines=newlines, + env=env) return p.stdin, p.stdout, p.stderr def version():