posix: remove unixdomainserver class
authorYuya Nishihara <yuya@tcha.org>
Sat, 21 Nov 2015 16:21:52 +0900
changeset 27362 c220434a3461
parent 27361 29f50344fa83
child 27363 c7ab2087d436
posix: remove unixdomainserver class It's no longer used since the removal of the inotify extension.
mercurial/posix.py
--- a/mercurial/posix.py	Sat Dec 12 23:22:18 2015 -0800
+++ b/mercurial/posix.py	Sat Nov 21 16:21:52 2015 +0900
@@ -15,7 +15,6 @@
 import pwd
 import re
 import select
-import socket
 import stat
 import sys
 import tempfile
@@ -555,46 +554,6 @@
 def executablepath():
     return None # available on Windows only
 
-class unixdomainserver(socket.socket):
-    def __init__(self, join, subsystem):
-        '''Create a unix domain socket with the given prefix.'''
-        super(unixdomainserver, self).__init__(socket.AF_UNIX)
-        sockname = subsystem + '.sock'
-        self.realpath = self.path = join(sockname)
-        if os.path.islink(self.path):
-            if os.path.exists(self.path):
-                self.realpath = os.readlink(self.path)
-            else:
-                os.unlink(self.path)
-        try:
-            self.bind(self.realpath)
-        except socket.error as err:
-            if err.args[0] == 'AF_UNIX path too long':
-                tmpdir = tempfile.mkdtemp(prefix='hg-%s-' % subsystem)
-                self.realpath = os.path.join(tmpdir, sockname)
-                try:
-                    self.bind(self.realpath)
-                    os.symlink(self.realpath, self.path)
-                except (OSError, socket.error):
-                    self.cleanup()
-                    raise
-            else:
-                raise
-        self.listen(5)
-
-    def cleanup(self):
-        def okayifmissing(f, path):
-            try:
-                f(path)
-            except OSError as err:
-                if err.errno != errno.ENOENT:
-                    raise
-
-        okayifmissing(os.unlink, self.path)
-        if self.realpath != self.path:
-            okayifmissing(os.unlink, self.realpath)
-            okayifmissing(os.rmdir, os.path.dirname(self.realpath))
-
 def statislink(st):
     '''check whether a stat result is a symlink'''
     return st and stat.S_ISLNK(st.st_mode)