Patchwork [1,of,8] dispatch: pass around ui.fmsg channel

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 8, 2018, 2:24 p.m.
Message ID <bd8ab1b84b2a778ea30e.1541687079@mimosa>
Download mbox | patch
Permalink /patch/36470/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 8, 2018, 2:24 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1421574203 -32400
#      Sun Jan 18 18:43:23 2015 +0900
# Node ID bd8ab1b84b2a778ea30e61a2386d2824c9a20750
# Parent  b93157f69f46a1359726be32bde4afb1e5af4384
dispatch: pass around ui.fmsg channel

This will be set by the command server. See the next patch.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -50,7 +50,7 @@  from .utils import (
 
 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 @@  class request(object):
         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 @@  def dispatch(req):
                 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 @@  def _dispatch(req):
                 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,
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -234,6 +234,7 @@  class ui(object):
             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
@@ -261,6 +262,7 @@  class ui(object):
             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
@@ -915,6 +917,17 @@  class ui(object):
     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