comparison mercurial/util.py @ 10199:c2e2a5e6c36b

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.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 02 Jan 2010 16:42:00 +0100
parents 29e3c4a7699b
children 8e4be44a676f
comparison
equal deleted inserted replaced
10198:c2168d170f05 10199:c2e2a5e6c36b
37 return _sha1(s) 37 return _sha1(s)
38 38
39 import subprocess 39 import subprocess
40 closefds = os.name == 'posix' 40 closefds = os.name == 'posix'
41 41
42 def popen2(cmd, newlines=False): 42 def popen2(cmd, env=None, newlines=False):
43 # Setting bufsize to -1 lets the system decide the buffer size. 43 # Setting bufsize to -1 lets the system decide the buffer size.
44 # The default for bufsize is 0, meaning unbuffered. This leads to 44 # The default for bufsize is 0, meaning unbuffered. This leads to
45 # poor performance on Mac OS X: http://bugs.python.org/issue4194 45 # poor performance on Mac OS X: http://bugs.python.org/issue4194
46 p = subprocess.Popen(cmd, shell=True, bufsize=-1, 46 p = subprocess.Popen(cmd, shell=True, bufsize=-1,
47 close_fds=closefds, 47 close_fds=closefds,
48 stdin=subprocess.PIPE, stdout=subprocess.PIPE, 48 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
49 universal_newlines=newlines) 49 universal_newlines=newlines,
50 env=env)
50 return p.stdin, p.stdout 51 return p.stdin, p.stdout
51 52
52 def popen3(cmd, newlines=False): 53 def popen3(cmd, env=None, newlines=False):
53 p = subprocess.Popen(cmd, shell=True, bufsize=-1, 54 p = subprocess.Popen(cmd, shell=True, bufsize=-1,
54 close_fds=closefds, 55 close_fds=closefds,
55 stdin=subprocess.PIPE, stdout=subprocess.PIPE, 56 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
56 stderr=subprocess.PIPE, 57 stderr=subprocess.PIPE,
57 universal_newlines=newlines) 58 universal_newlines=newlines,
59 env=env)
58 return p.stdin, p.stdout, p.stderr 60 return p.stdin, p.stdout, p.stderr
59 61
60 def version(): 62 def version():
61 """Return version information if available.""" 63 """Return version information if available."""
62 try: 64 try: