Patchwork [4,of,7] chgserver: reorder service classes to make future patches readable

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

Comments

Yuya Nishihara - July 14, 2016, 3:20 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1463890110 -32400
#      Sun May 22 13:08:30 2016 +0900
# Node ID 35585295685ad2c8478f8cb59a3d4cada5d224be
# Parent  e56508ea57c23af68d05d941d344321b6ade8184
chgserver: reorder service classes to make future patches readable

Includes no functional change.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -532,18 +532,61 @@  class chgcmdserver(commandserver.server)
                          'setenv': setenv,
                          'setumask': setumask})
 
-class _requesthandler(commandserver._requesthandler):
-    def _createcmdserver(self, repo, conn, fin, fout):
-        ui = self.server.ui
-        return chgcmdserver(ui, repo, fin, fout, conn,
-                            self.server.hashstate, self.server.baseaddress)
-
 def _tempaddress(address):
     return '%s.%d.tmp' % (address, os.getpid())
 
 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')
+
+    def init(self):
+        self._inithashstate()
+        self._checkextensions()
+        class cls(AutoExitMixIn, socketserver.ForkingMixIn,
+                  socketserver.UnixStreamServer):
+            ui = self.ui
+            repo = self.repo
+            hashstate = self.hashstate
+            baseaddress = self.baseaddress
+        self.server = cls(self.address, _requesthandler)
+        self.server.idletimeout = self.ui.configint(
+            'chgserver', 'idletimeout', self.server.idletimeout)
+        self.server.startautoexitthread()
+        self._createsymlink()
+
+    def _inithashstate(self):
+        self.baseaddress = self.address
+        if self.ui.configbool('chgserver', 'skiphash', False):
+            self.hashstate = None
+            return
+        self.hashstate = hashstate.fromui(self.ui)
+        self.address = _hashaddress(self.address, self.hashstate.confighash)
+
+    def _checkextensions(self):
+        if not self.hashstate:
+            return
+        if extensions.notloaded():
+            # one or more extensions failed to load. mtimehash becomes
+            # meaningless because we do not know the paths of those extensions.
+            # set mtimehash to an illegal hash value to invalidate the server.
+            self.hashstate.mtimehash = ''
+
+    def _createsymlink(self):
+        if self.baseaddress == self.address:
+            return
+        tempaddress = _tempaddress(self.baseaddress)
+        os.symlink(os.path.basename(self.address), tempaddress)
+        util.rename(tempaddress, self.baseaddress)
+
+    def _cleanup(self):
+        self.server.unlinksocketfile()
+
 class AutoExitMixIn:  # use old-style to comply with SocketServer design
     lastactive = time.time()
     idletimeout = 3600  # default 1 hour
@@ -604,54 +647,11 @@  class AutoExitMixIn:  # use old-style to
             if exc.errno != errno.ENOENT:
                 raise
 
-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')
-
-    def init(self):
-        self._inithashstate()
-        self._checkextensions()
-        class cls(AutoExitMixIn, socketserver.ForkingMixIn,
-                  socketserver.UnixStreamServer):
-            ui = self.ui
-            repo = self.repo
-            hashstate = self.hashstate
-            baseaddress = self.baseaddress
-        self.server = cls(self.address, _requesthandler)
-        self.server.idletimeout = self.ui.configint(
-            'chgserver', 'idletimeout', self.server.idletimeout)
-        self.server.startautoexitthread()
-        self._createsymlink()
-
-    def _inithashstate(self):
-        self.baseaddress = self.address
-        if self.ui.configbool('chgserver', 'skiphash', False):
-            self.hashstate = None
-            return
-        self.hashstate = hashstate.fromui(self.ui)
-        self.address = _hashaddress(self.address, self.hashstate.confighash)
-
-    def _checkextensions(self):
-        if not self.hashstate:
-            return
-        if extensions.notloaded():
-            # one or more extensions failed to load. mtimehash becomes
-            # meaningless because we do not know the paths of those extensions.
-            # set mtimehash to an illegal hash value to invalidate the server.
-            self.hashstate.mtimehash = ''
-
-    def _createsymlink(self):
-        if self.baseaddress == self.address:
-            return
-        tempaddress = _tempaddress(self.baseaddress)
-        os.symlink(os.path.basename(self.address), tempaddress)
-        util.rename(tempaddress, self.baseaddress)
-
-    def _cleanup(self):
-        self.server.unlinksocketfile()
+class _requesthandler(commandserver._requesthandler):
+    def _createcmdserver(self, repo, conn, fin, fout):
+        ui = self.server.ui
+        return chgcmdserver(ui, repo, fin, fout, conn,
+                            self.server.hashstate, self.server.baseaddress)
 
 def uisetup(ui):
     commandserver._servicemap['chgunix'] = chgunixservice