ui: introduce util.system() wrapper to make sure ui.fout is used
authorYuya Nishihara <yuya@tcha.org>
Sat, 08 Nov 2014 12:57:42 +0900
changeset 23269 d9d8d2e0f701
parent 23268 0fd3862ef425
child 23270 41c03b7592ed
ui: introduce util.system() wrapper to make sure ui.fout is used This change is intended to avoid future problem of data corruption under command server. out=ui.fout is mandatory as long as command server uses stdout as IPC channel.
mercurial/ui.py
--- a/mercurial/ui.py	Wed Nov 12 22:21:51 2014 +0900
+++ b/mercurial/ui.py	Sat Nov 08 12:57:42 2014 +0900
@@ -814,10 +814,9 @@
 
             editor = self.geteditor()
 
-            util.system("%s \"%s\"" % (editor, name),
+            self.system("%s \"%s\"" % (editor, name),
                         environ=environ,
-                        onerr=util.Abort, errprefix=_("edit failed"),
-                        out=self.fout)
+                        onerr=util.Abort, errprefix=_("edit failed"))
 
             f = open(name)
             t = f.read()
@@ -827,6 +826,13 @@
 
         return t
 
+    def system(self, cmd, environ={}, cwd=None, onerr=None, errprefix=None):
+        '''execute shell command with appropriate output stream. command
+        output will be redirected if fout is not stdout.
+        '''
+        return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
+                           errprefix=errprefix, out=self.fout)
+
     def traceback(self, exc=None, force=False):
         '''print exception traceback if traceback printing enabled or forced.
         only to call in exception handler. returns true if traceback