From patchwork Sun Dec 13 14:49:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: posix: remove unixdomainserver class From: Yuya Nishihara X-Patchwork-Id: 12013 Message-Id: To: mercurial-devel@selenic.com Date: Sun, 13 Dec 2015 23:49:28 +0900 # HG changeset patch # User Yuya Nishihara # Date 1448090512 -32400 # Sat Nov 21 16:21:52 2015 +0900 # Node ID d43f8d4b12a79e66b1350c3669f599a9a45b2ee8 # Parent 374b960b42acf96be105d8eb429fd041a30929c7 posix: remove unixdomainserver class It's no longer used since the removal of the inotify extension. diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -15,7 +15,6 @@ import os import pwd import re import select -import socket import stat import sys import tempfile @@ -555,46 +554,6 @@ class cachestat(object): 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)