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

login
register
mail settings
Submitter Jun Wu
Date March 2, 2016, 10:44 a.m.
Message ID <228cda48daee93dc23dc.1456915447@x1c>
Download mbox | patch
Permalink /patch/13525/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - March 2, 2016, 10:44 a.m.
# HG changeset patch
# User Jun Wu <quark@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 /.
timeless - March 2, 2016, 2:29 p.m.
Jun Wu <quark@fb.com> wrote:
> chgserver will not behavior correctly because commandserver.server uses

behave

Patch

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()