[PATCH 2 of 4] chgserver: change newchgui to wrapchgui

Jun Wu quark at fb.com
Fri Dec 16 10:01:19 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1481900146 0
#      Fri Dec 16 14:55:46 2016 +0000
# Node ID 4033499405eb31a5b60bfc2001f109e341c9339d
# Parent  5d314c588c67b0e0651557610d68e3705fc61f1d
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 4033499405eb
chgserver: change newchgui to wrapchgui

chgserver will let dispatch create the ui object for runcommand eventually.
That means chgserver's own ui object won't be used. And we need to use the
typical "wrapping" approach instead of creating a new ui object.

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -210,5 +210,5 @@ def _setuppagercmd(ui, options, cmd):
         return p
 
-def _newchgui(srcui, csystem):
+def _wrapchgui(srcui, csystem):
     class chgui(srcui.__class__):
         def __init__(self, src=None):
@@ -251,5 +251,5 @@ def _newchgui(srcui, csystem):
             return rc
 
-    return chgui(srcui)
+    srcui.__class__ = chgui
 
 def _loadnewui(srcui, args):
@@ -330,6 +330,6 @@ class chgcmdserver(commandserver.server)
     def __init__(self, ui, repo, fin, fout, sock, hashstate, baseaddress):
         self._csystem = channeledsystem(fin, fout, 'S')
-        super(chgcmdserver, self).__init__(
-            _newchgui(ui, self._csystem), repo, fin, fout)
+        _wrapchgui(ui, self._csystem)
+        super(chgcmdserver, self).__init__(ui, repo, fin, fout)
         self.clientsock = sock
         self._oldios = []  # original (self.ch, ui.fp, fd) before "attachio"


More information about the Mercurial-devel mailing list