Patchwork [4,of,4] commandserver: extract _cleanup() hook to clarify chg is doing differently

login
register
mail settings
Submitter Yuya Nishihara
Date July 13, 2016, 12:09 p.m.
Message ID <909c25383f481b87502b.1468411775@mimosa>
Download mbox | patch
Permalink /patch/15827/
State Accepted
Headers show

Comments

Yuya Nishihara - July 13, 2016, 12:09 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1463883671 -32400
#      Sun May 22 11:21:11 2016 +0900
# Node ID 909c25383f481b87502b3786f681814ff4619e5b
# Parent  5bd15cd2fed4991214c460875d41a88c8919a829
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.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -651,11 +651,8 @@  class chgunixservice(commandserver.unixs
         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
diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -403,11 +403,14 @@  class unixservice(object):
         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,