[PATCH] hg script: remove current directory from sys.path (issue2557)

Martin Geisler mg at aragost.com
Tue Feb 1 03:47:14 CST 2011


Dan Villiom Podlaski Christiansen <danchr at gmail.com> writes:

> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
> # Date 1292530833 -3600
> # Node ID 72f669c3f555295fb1fc7b7c73ae4053c69441fd
> # Parent  aae2d5cbde647da49fb1927d02faabfc37975c63
> hg script: remove current directory from sys.path (issue2557)
>
> diff --git a/hg b/hg
> --- a/hg
> +++ b/hg
> @@ -13,6 +13,11 @@ import sys
>  libdir = '@LIBDIR@'
>  
>  if libdir != '@' 'LIBDIR' '@':
> +    # issue2557: remove current directory from path
> +    if 'PYTHONPATH' in os.environ and '' in os.environ['PYTHONPATH'].split(':'):

We should split on os.pathsep instead.

> +        curdir = os.path.abspath(os.curdir)
> +        sys.path = [p for p in sys.path if p and p != curdir]

Also, it seems that we can just delete sys.path[0]? See the doc here:

  http://docs.python.org/library/sys.html#sys.path

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/en/services/mercurial/blog/


More information about the Mercurial-devel mailing list