commandserver: extract _cleanup() hook to clarify chg is doing differently
authorYuya Nishihara <yuya@tcha.org>
Sun, 22 May 2016 11:21:11 +0900
changeset 29532 dda6bf886839
parent 29531 b439a2a268eb
child 29533 6835777a180e
commandserver: extract _cleanup() hook to clarify chg is doing differently This makes it clear that chg needs its own way to unlink closed socket file. I made a mistake in draft patches without noting the difference.
hgext/chgserver.py
mercurial/commandserver.py
--- a/hgext/chgserver.py	Sat May 21 17:06:39 2016 +0900
+++ b/hgext/chgserver.py	Sun May 22 11:21:11 2016 +0900
@@ -651,11 +651,8 @@
         os.symlink(os.path.basename(self.address), tempaddress)
         util.rename(tempaddress, self.baseaddress)
 
-    def run(self):
-        try:
-            self.server.serve_forever()
-        finally:
-            self.server.unlinksocketfile()
+    def _cleanup(self):
+        self.server.unlinksocketfile()
 
 def uisetup(ui):
     commandserver._servicemap['chgunix'] = chgunixservice
--- a/mercurial/commandserver.py	Sat May 21 17:06:39 2016 +0900
+++ b/mercurial/commandserver.py	Sun May 22 11:21:11 2016 +0900
@@ -403,11 +403,14 @@
         self.ui.status(_('listening at %s\n') % self.address)
         self.ui.flush()  # avoid buffering of status message
 
+    def _cleanup(self):
+        os.unlink(self.address)
+
     def run(self):
         try:
             self.server.serve_forever()
         finally:
-            os.unlink(self.address)
+            self._cleanup()
 
 _servicemap = {
     'pipe': pipeservice,