Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/chgserver.py @ 30737:2957409449ac
chgserver: use util.shellenviron
This avoids code duplication.
author | Jun Wu <quark@fb.com> |
---|---|
date | Tue, 10 Jan 2017 06:58:51 +0800 |
parents | 18eb63ec8475 |
children | 815e1cefd082 |
comparison
equal
deleted
inserted
replaced
30736:d9e5b0aeeb90 | 30737:2957409449ac |
---|---|
229 if (any(s[1] for s in self._bufferstates) | 229 if (any(s[1] for s in self._bufferstates) |
230 or not util.safehasattr(self.fout, 'fileno') | 230 or not util.safehasattr(self.fout, 'fileno') |
231 or self.fout.fileno() != util.stdout.fileno()): | 231 or self.fout.fileno() != util.stdout.fileno()): |
232 return super(chgui, self).system(cmd, environ, cwd, onerr, | 232 return super(chgui, self).system(cmd, environ, cwd, onerr, |
233 errprefix) | 233 errprefix) |
234 # copied from mercurial/util.py:system() | |
235 self.flush() | 234 self.flush() |
236 def py2shell(val): | 235 rc = self._csystem(cmd, util.shellenviron(environ), cwd) |
237 if val is None or val is False: | |
238 return '0' | |
239 if val is True: | |
240 return '1' | |
241 return str(val) | |
242 env = encoding.environ.copy() | |
243 if environ: | |
244 env.update((k, py2shell(v)) for k, v in environ.iteritems()) | |
245 env['HG'] = util.hgexecutable() | |
246 rc = self._csystem(cmd, env, cwd) | |
247 if rc and onerr: | 236 if rc and onerr: |
248 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), | 237 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), |
249 util.explainexit(rc)[0]) | 238 util.explainexit(rc)[0]) |
250 if errprefix: | 239 if errprefix: |
251 errmsg = '%s: %s' % (errprefix, errmsg) | 240 errmsg = '%s: %s' % (errprefix, errmsg) |