[PATCH V2] chgserver: set sys.argv to improve compatibility

Jun Wu quark at fb.com
Wed May 4 21:24:12 UTC 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1459730303 -3600
#      Mon Apr 04 01:38:23 2016 +0100
# Node ID 6889dd5f104d2870f74ae1ef54eb7c2450bb6ea5
# Parent  906a1c8a75fd8a18e43e8545eedcbe5222f84647
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
@@ -448,6 +448,11 @@
         the instructions.
         """
         args = self._readlist()
+        # some extensions read sys.argv in reposetup or their commands. we
+        # don't have an easy way to get command args from an extension so
+        # just change sys.argv to support them. this won't affect sys.argv
+        # of the main server process since 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