diff hgext/chgserver.py @ 29511:540c01a18bb7

commandserver: extract method to create commandserver instance per request This is a step toward merging chgserver._requesthandler with commandserver's.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 May 2016 15:12:19 +0900
parents 71ed5a3ef8a9
children 538d0003c9e0
line wrap: on
line diff
--- a/hgext/chgserver.py	Mon Jul 11 21:40:02 2016 +0900
+++ b/hgext/chgserver.py	Sat May 21 15:12:19 2016 +0900
@@ -545,11 +545,9 @@
         # same state inherited from parent.
         random.seed()
         ui = self.server.ui
-        repo = self.server.repo
         sv = None
         try:
-            sv = chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection,
-                              self.server.hashstate, self.server.baseaddress)
+            sv = self._createcmdserver()
             try:
                 sv.serve()
             # handle exceptions that may be raised by command server. most of
@@ -576,6 +574,12 @@
             # trigger __del__ since ForkingMixIn uses os._exit
             gc.collect()
 
+    def _createcmdserver(self):
+        ui = self.server.ui
+        repo = self.server.repo
+        return chgcmdserver(ui, repo, self.rfile, self.wfile, self.connection,
+                            self.server.hashstate, self.server.baseaddress)
+
 def _tempaddress(address):
     return '%s.%d.tmp' % (address, os.getpid())