Patchwork [5,of,7] chgserver: extract stub factory of service object

login
register
mail settings
Submitter Yuya Nishihara
Date July 14, 2016, 3:20 p.m.
Message ID <1c47f0361d40b86ec4e6.1468509643@mimosa>
Download mbox | patch
Permalink /patch/15858/
State Accepted
Headers show

Comments

Yuya Nishihara - July 14, 2016, 3:20 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1463890384 -32400
#      Sun May 22 13:13:04 2016 +0900
# Node ID 1c47f0361d40b86ec4e6b1aca6d7b7a980ba78fd
# Parent  35585295685ad2c8478f8cb59a3d4cada5d224be
chgserver: extract stub factory of service object

The class inheritance will be replaced by composition. See the next patch
for details.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -538,13 +538,7 @@  def _tempaddress(address):
 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 @@  class _requesthandler(commandserver._req
         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