Patchwork [2,of,4] chgserver: change newchgui to wrapchgui

login
register
mail settings
Submitter Jun Wu
Date Dec. 16, 2016, 3:01 p.m.
Message ID <4033499405eb31a5b60b.1481900479@x1c>
Download mbox | patch
Permalink /patch/17933/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - Dec. 16, 2016, 3:01 p.m.
# HG changeset patch
# User Jun Wu <quark@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.

Patch

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"