[PATCH] posix: remove unixdomainserver class

Augie Fackler raf at durin42.com
Tue Dec 15 12:15:06 CST 2015


On Sun, Dec 13, 2015 at 11:49:28PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1448090512 -32400
> #      Sat Nov 21 16:21:52 2015 +0900
> # Node ID d43f8d4b12a79e66b1350c3669f599a9a45b2ee8
> # Parent  374b960b42acf96be105d8eb429fd041a30929c7
> posix: remove unixdomainserver class

Queued with delight. My favorite kind of patch: all removals!

>
> 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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list