serve: Don't change directory in the child if invoked with -d and --cwd
authorBryan O'Sullivan <bos@serpentine.com>
Fri, 04 Jan 2008 11:52:24 -0800
changeset 5797 7b7f03c7dfa5
parent 5796 7705d308eb5e
child 5798 86f5d8f608b7
serve: Don't change directory in the child if invoked with -d and --cwd
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Jan 04 14:25:04 2008 +0100
+++ b/mercurial/cmdutil.py	Fri Jan 04 11:52:24 2008 -0800
@@ -495,6 +495,15 @@
         rfd, wfd = os.pipe()
         args = sys.argv[:]
         args.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
+        # Don't pass --cwd to the child process, because we've already
+        # changed directory.
+        for i in xrange(1,len(args)):
+            if args[i].startswith('--cwd='):
+                del args[i]
+                break
+            elif args[i].startswith('--cwd'):
+                del args[i:i+2]
+                break
         pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
                          args[0], args)
         os.close(wfd)