dispatch: pass around ui.fmsg channel
authorYuya Nishihara <yuya@tcha.org>
Sun, 18 Jan 2015 18:43:23 +0900
changeset 40587 5542bc9125c9
parent 40586 3b0f07cc9626
child 40588 9683dfb6f13a
dispatch: pass around ui.fmsg channel This will be set by the command server. See the next patch.
mercurial/dispatch.py
mercurial/ui.py
--- a/mercurial/dispatch.py	Sat Nov 10 12:01:21 2018 +0900
+++ b/mercurial/dispatch.py	Sun Jan 18 18:43:23 2015 +0900
@@ -50,7 +50,7 @@
 
 class request(object):
     def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
-                 ferr=None, prereposetups=None):
+                 ferr=None, fmsg=None, prereposetups=None):
         self.args = args
         self.ui = ui
         self.repo = repo
@@ -59,6 +59,8 @@
         self.fin = fin
         self.fout = fout
         self.ferr = ferr
+        # separate stream for status/error messages
+        self.fmsg = fmsg
 
         # remember options pre-parsed by _earlyparseopts()
         self.earlyoptions = {}
@@ -205,6 +207,8 @@
                 req.ui.fout = req.fout
             if req.ferr:
                 req.ui.ferr = req.ferr
+            if req.fmsg:
+                req.ui.fmsg = req.fmsg
         except error.Abort as inst:
             ferr.write(_("abort: %s\n") % inst)
             if inst.hint:
@@ -955,6 +959,7 @@
                 repo.ui.fin = ui.fin
                 repo.ui.fout = ui.fout
                 repo.ui.ferr = ui.ferr
+                repo.ui.fmsg = ui.fmsg
             else:
                 try:
                     repo = hg.repository(ui, path=path,
--- a/mercurial/ui.py	Sat Nov 10 12:01:21 2018 +0900
+++ b/mercurial/ui.py	Sun Jan 18 18:43:23 2015 +0900
@@ -231,6 +231,7 @@
             self._fout = src._fout
             self._ferr = src._ferr
             self._fin = src._fin
+            self._fmsg = src._fmsg
             self._fmsgout = src._fmsgout
             self._fmsgerr = src._fmsgerr
             self._finoutredirected = src._finoutredirected
@@ -258,6 +259,7 @@
             self._fout = procutil.stdout
             self._ferr = procutil.stderr
             self._fin = procutil.stdin
+            self._fmsg = None
             self._fmsgout = self.fout  # configurable
             self._fmsgerr = self.ferr  # configurable
             self._finoutredirected = False
@@ -912,6 +914,17 @@
     def fin(self, f):
         self._fin = f
 
+    @property
+    def fmsg(self):
+        """Stream dedicated for status/error messages; may be None if
+        fout/ferr are used"""
+        return self._fmsg
+
+    @fmsg.setter
+    def fmsg(self, f):
+        self._fmsg = f
+        self._fmsgout, self._fmsgerr = _selectmsgdests(self)
+
     def pushbuffer(self, error=False, subproc=False, labeled=False):
         """install a buffer to capture standard output of the ui object