posix: remove unixdomainserver class
authorYuya Nishihara <yuya@tcha.org>
Sat, 21 Nov 2015 16:21:52 +0900
changeset 28890 c220434a34613c5c424413156bf6ea462b473ba0
parent 28889 29f50344fa83c3fdae8e1ca923eed58e0b68cf06
child 28891 c7ab2087d436b1a56e97b5f0f51177c5cfe7d0f9
push id112
push usergszorc@mozilla.com
push dateWed, 16 Dec 2015 00:04:22 +0000
posix: remove unixdomainserver class It's no longer used since the removal of the inotify extension.
mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -10,17 +10,16 @@ from __future__ import absolute_import
 import errno
 import fcntl
 import getpass
 import grp
 import os
 import pwd
 import re
 import select
-import socket
 import stat
 import sys
 import tempfile
 import unicodedata
 
 from .i18n import _
 from . import (
     encoding,
@@ -550,56 +549,16 @@ class cachestat(object):
             return False
 
     def __ne__(self, other):
         return not self == other
 
 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)
 
 def statisexec(st):
     '''check whether a stat result is an executable file'''
     return st and (st.st_mode & 0o100 != 0)