[PATCH 2 of 4] chgserver: reorder functions in chgunixservicehandler

Yuya Nishihara yuya at tcha.org
Mon Jul 18 09:53:36 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1463893534 -32400
#      Sun May 22 14:05:34 2016 +0900
# Node ID d03c1efd598ff58a56830cfb2ca1015c5a96a49a
# Parent  913392f7d88719993f4787e39ed0a039e812dc48
chgserver: reorder functions in chgunixservicehandler

This should make it slightly easier to follow the call path.

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -569,29 +569,6 @@ class chgunixservicehandler(object):
             # 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 printbanner(self, address):
-        # no "listening at" message should be printed to simulate hg behavior
-        pass
-
-    def shouldexit(self):
-        if not self.issocketowner():
-            self.ui.debug('%s is not owned, exiting.\n' % self.address)
-            return True
-        if time.time() - self.lastactive > self.idletimeout:
-            self.ui.debug('being idle too long. exiting.\n')
-            return True
-        return False
-
-    def newconnection(self):
-        self.lastactive = time.time()
-
     def _bind(self, sock):
         # use a unique temp address so we can stat the file and do ownership
         # check later
@@ -602,6 +579,13 @@ class chgunixservicehandler(object):
         # old server will detect ownership change and exit.
         util.rename(tempaddress, self.address)
 
+    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 issocketowner(self):
         try:
             stat = os.stat(self.address)
@@ -623,6 +607,22 @@ class chgunixservicehandler(object):
             if exc.errno != errno.ENOENT:
                 raise
 
+    def printbanner(self, address):
+        # no "listening at" message should be printed to simulate hg behavior
+        pass
+
+    def shouldexit(self):
+        if not self.issocketowner():
+            self.ui.debug('%s is not owned, exiting.\n' % self.address)
+            return True
+        if time.time() - self.lastactive > self.idletimeout:
+            self.ui.debug('being idle too long. exiting.\n')
+            return True
+        return False
+
+    def newconnection(self):
+        self.lastactive = time.time()
+
     def createcmdserver(self, repo, conn, fin, fout):
         return chgcmdserver(self.ui, repo, fin, fout, conn,
                             self.hashstate, self.baseaddress)


More information about the Mercurial-devel mailing list