[PATCH 1 of 3] ui: introduce util.system() wrapper to make sure ui.fout is used

Yuya Nishihara yuya at tcha.org
Fri Nov 7 23:42:13 CST 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1415419062 -32400
#      Sat Nov 08 12:57:42 2014 +0900
# Node ID d83746a91dc410f60b45916c2e55dadde4238b42
# Parent  2d54aa5397cdb1c697673ba10b7618d5ac25c69e
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.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -814,10 +814,9 @@ class ui(object):
 
             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,10 @@ class ui(object):
 
         return t
 
+    def system(self, cmd, environ={}, cwd=None, onerr=None, errprefix=None):
+        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


More information about the Mercurial-devel mailing list