comparison mercurial/chgserver.py @ 31124:fbce78c58f1e

chg: refactor ui.system() to be partly overridden Since fd598149112b changed the signature of ui.system(), chgui.system() should have been updated. This patch factors out the util.system() call so that chg can override how a shell command is executed.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 19 Feb 2017 01:00:10 +0900
parents cb899ee133d8
children 3f8f53190d6a
comparison
equal deleted inserted replaced
31123:a185b903bda3 31124:fbce78c58f1e
177 if src: 177 if src:
178 self._csystem = getattr(src, '_csystem', csystem) 178 self._csystem = getattr(src, '_csystem', csystem)
179 else: 179 else:
180 self._csystem = csystem 180 self._csystem = csystem
181 181
182 def system(self, cmd, environ=None, cwd=None, onerr=None, 182 def _runsystem(self, cmd, environ, cwd, onerr, errprefix, out):
183 errprefix=None):
184 # fallback to the original system method if the output needs to be 183 # fallback to the original system method if the output needs to be
185 # captured (to self._buffers), or the output stream is not stdout 184 # captured (to self._buffers), or the output stream is not stdout
186 # (e.g. stderr, cStringIO), because the chg client is not aware of 185 # (e.g. stderr, cStringIO), because the chg client is not aware of
187 # these situations and will behave differently (write to stdout). 186 # these situations and will behave differently (write to stdout).
188 if (any(s[1] for s in self._bufferstates) 187 if (out is not self.fout
189 or not util.safehasattr(self.fout, 'fileno') 188 or not util.safehasattr(self.fout, 'fileno')
190 or self.fout.fileno() != util.stdout.fileno()): 189 or self.fout.fileno() != util.stdout.fileno()):
191 return super(chgui, self).system(cmd, environ, cwd, onerr, 190 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
192 errprefix) 191 errprefix=errprefix, out=out)
193 self.flush() 192 self.flush()
194 rc = self._csystem(cmd, util.shellenviron(environ), cwd) 193 rc = self._csystem(cmd, util.shellenviron(environ), cwd)
195 if rc and onerr: 194 if rc and onerr:
196 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), 195 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
197 util.explainexit(rc)[0]) 196 util.explainexit(rc)[0])