[PATCH 05 of 10] chgserver: avoid os.getcwd() failure

Jun Wu quark at fb.com
Wed Mar 2 05:44:07 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1456746944 0
#      Mon Feb 29 11:55:44 2016 +0000
# Node ID 228cda48daee93dc23dc512b9390c9eadfd93f19
# Parent  9cd173eff72962ada9601a368efdb8f87e2eed43
chgserver: avoid os.getcwd() failure

Before this patch, if the directory that chgserver starts from is deleted,
chgserver will not behavior correctly because commandserver.server uses
os.getcwd(). This patch avoids the issue by chdir to /.

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -591,6 +591,8 @@
             'chgserver', 'idletimeout', self.server.idletimeout)
         self.server.startautoexitthread()
         self._createsymlink()
+        # avoid possible "os.getcwd()" failure in the future
+        os.chdir('/')
         # avoid writing "listening at" message to stdout before attachio
         # request, which calls setvbuf()
 


More information about the Mercurial-devel mailing list