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) |