chgserver: extract stub factory of service object
authorYuya Nishihara <yuya@tcha.org>
Sun, 22 May 2016 13:13:04 +0900
changeset 29546 a7513390a9db
parent 29545 28aca3fafc2a
child 29547 300318b7d66d
chgserver: extract stub factory of service object The class inheritance will be replaced by composition. See the next patch for details.
hgext/chgserver.py
--- a/hgext/chgserver.py	Sun May 22 13:08:30 2016 +0900
+++ b/hgext/chgserver.py	Sun May 22 13:13:04 2016 +0900
@@ -538,13 +538,7 @@
 def _hashaddress(address, hashstr):
     return '%s-%s' % (address, hashstr)
 
-class chgunixservice(commandserver.unixservice):
-    def __init__(self, ui, repo, opts):
-        super(chgunixservice, self).__init__(ui, repo=None, opts=opts)
-        if repo:
-            # one chgserver can serve multiple repos. drop repo infomation
-            self.ui.setconfig('bundle', 'mainreporoot', '', 'repo')
-
+class _chgunixservice(commandserver.unixservice):
     def init(self):
         self._inithashstate()
         self._checkextensions()
@@ -653,6 +647,12 @@
         return chgcmdserver(ui, repo, fin, fout, conn,
                             self.server.hashstate, self.server.baseaddress)
 
+def chgunixservice(ui, repo, opts):
+    if repo:
+        # one chgserver can serve multiple repos. drop repo infomation
+        ui.setconfig('bundle', 'mainreporoot', '', 'repo')
+    return _chgunixservice(ui, repo=None, opts=opts)
+
 def uisetup(ui):
     commandserver._servicemap['chgunix'] = chgunixservice