Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 39831:c31ce080eb75
py3: convert arguments, cwd and env to native strings when spawning subprocess
This keeps Windows happy.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 23 Sep 2018 00:47:04 -0400 |
parents | 41ac8ea1bdd7 |
children | 6f152067ba57 |
comparison
equal
deleted
inserted
replaced
39830:874712506b07 | 39831:c31ce080eb75 |
---|---|
949 lc_all = env.get('LC_ALL') | 949 lc_all = env.get('LC_ALL') |
950 if lc_all: | 950 if lc_all: |
951 env['LANG'] = lc_all | 951 env['LANG'] = lc_all |
952 del env['LC_ALL'] | 952 del env['LC_ALL'] |
953 env['LC_MESSAGES'] = 'C' | 953 env['LC_MESSAGES'] = 'C' |
954 p = subprocess.Popen(cmd, bufsize=-1, close_fds=procutil.closefds, | 954 p = subprocess.Popen(pycompat.rapply(procutil.tonativestr, cmd), |
955 bufsize=-1, close_fds=procutil.closefds, | |
955 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 956 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
956 universal_newlines=True, env=env, **extrakw) | 957 universal_newlines=True, |
958 env=procutil.tonativeenv(env), **extrakw) | |
957 stdout, stderr = p.communicate() | 959 stdout, stderr = p.communicate() |
958 stderr = stderr.strip() | 960 stderr = stderr.strip() |
959 if not failok: | 961 if not failok: |
960 if p.returncode: | 962 if p.returncode: |
961 raise error.Abort(stderr or 'exited with code %d' | 963 raise error.Abort(stderr or 'exited with code %d' |
1266 errpipe = open(os.devnull, 'w') | 1268 errpipe = open(os.devnull, 'w') |
1267 if self.ui._colormode and len(commands) and commands[0] == "diff": | 1269 if self.ui._colormode and len(commands) and commands[0] == "diff": |
1268 # insert the argument in the front, | 1270 # insert the argument in the front, |
1269 # the end of git diff arguments is used for paths | 1271 # the end of git diff arguments is used for paths |
1270 commands.insert(1, '--color') | 1272 commands.insert(1, '--color') |
1271 p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1, | 1273 p = subprocess.Popen(pycompat.rapply(procutil.tonativestr, |
1272 cwd=cwd, env=env, close_fds=procutil.closefds, | 1274 [self._gitexecutable] + commands), |
1275 bufsize=-1, | |
1276 cwd=pycompat.rapply(procutil.tonativestr, cwd), | |
1277 env=procutil.tonativeenv(env), | |
1278 close_fds=procutil.closefds, | |
1273 stdout=subprocess.PIPE, stderr=errpipe) | 1279 stdout=subprocess.PIPE, stderr=errpipe) |
1274 if stream: | 1280 if stream: |
1275 return p.stdout, None | 1281 return p.stdout, None |
1276 | 1282 |
1277 retdata = p.stdout.read().strip() | 1283 retdata = p.stdout.read().strip() |