chgserver: reorder functions in chgunixservicehandler
authorYuya Nishihara <yuya@tcha.org>
Sun, 22 May 2016 14:05:34 +0900
changeset 29596 71c197d82b7e
parent 29595 2c4dc91c4c54
child 29597 581c0c7cb258
chgserver: reorder functions in chgunixservicehandler This should make it slightly easier to follow the call path.
hgext/chgserver.py
--- a/hgext/chgserver.py	Sat May 21 18:15:20 2016 +0900
+++ b/hgext/chgserver.py	Sun May 22 14:05:34 2016 +0900
@@ -569,29 +569,6 @@
             # 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 @@
         # 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 @@
             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)