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

Augie Fackler raf at durin42.com
Wed May 4 23:27:43 EDT 2016


On Wed, May 04, 2016 at 10:24:12PM +0100, Jun Wu wrote:
> # 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.

What extensions read sys.argv? I'm having trouble figuring out why one
would even do that...


> 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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list