[PATCH 1 of 4] chgserver: narrow scope of chdir() to socket.bind()

Yuya Nishihara yuya at tcha.org
Wed Jul 13 08:09:32 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1463816579 -32400
#      Sat May 21 16:42:59 2016 +0900
# Node ID 4e4bf46112a5de1cccf339db1c9de4fb2f391085
# Parent  e5b4d79a9140c3d90e9b6aa22070351b73ef2d4c
chgserver: narrow scope of chdir() to socket.bind()

This helps extracting a utility function.

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -587,13 +587,13 @@ class AutoExitMixIn:  # use old-style to
             bakwdfd = os.open('.', os.O_DIRECTORY)
             os.chdir(dirname)
         self.socket.bind(basename)
-        self._socketstat = os.stat(basename)
-        # rename will replace the old socket file if exists atomically. the
-        # old server will detect ownership change and exit.
-        util.rename(basename, self.server_address)
         if bakwdfd:
             os.fchdir(bakwdfd)
             os.close(bakwdfd)
+        self._socketstat = os.stat(tempaddress)
+        # rename will replace the old socket file if exists atomically. the
+        # old server will detect ownership change and exit.
+        util.rename(tempaddress, self.server_address)
 
     def issocketowner(self):
         try:


More information about the Mercurial-devel mailing list