[PATCH 2 of 7] chgserver: set sys.argv to improve compatibility

Jun Wu quark at fb.com
Sun Apr 3 22:30:49 EDT 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1459730303 -3600
#      Mon Apr 04 01:38:23 2016 +0100
# Node ID ffe771bf6fa7d5a81a9c9335f28c23688775fc2c
# Parent  c2c62ede8eb5c192cc134b994cdbff46215664cf
chgserver: set sys.argv to improve compatibility

Before this patch, extensions reading sys.argv will behave incorrectly when
running with chg, because chg has a different sys.argv which is how the
chgserver started.

The chgserver argv is meaningless for extensions (and for chg itself). So
let's replace it with what the user actually uses passed from the chg client.

Therefore the extensions reading sys.argv even in reposetup will have correct
behaviors.

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -447,6 +447,10 @@
         the instructions.
         """
         args = self._readlist()
+        # some extensions read sys.argv in reposetup or their commands.
+        # support them. this won't affect sys.argv of the main server process
+        # because we forked.
+        sys.argv = args
         try:
             self.ui, lui = _loadnewui(self.ui, args)
         except error.ParseError as inst:


More information about the Mercurial-devel mailing list