[PATCH] Fix the path problem on Windows that prevents to run hg from its own repository

Matt Mackall mpm at selenic.com
Sat Jul 2 16:44:02 CDT 2005


On Sat, Jul 02, 2005 at 02:54:14PM +0200, Giuseppe Bilotta wrote:
> On Fri, 1 Jul 2005 15:02:24 -0700, Matt Mackall wrote:
> 
> > On Fri, Jul 01, 2005 at 06:17:18PM +0200, Giuseppe Bilotta wrote:
> >> The attached patch solves the path problem that prevents to run hg
> >> from its own repository. Under Windows, under normal circumstances,
> >> the current path is searched before the site-lib path. Therefore, when
> >> running a properly-installed hg from a repository containing a
> >> directory named 'mercurial', hg will fail in various way. The solution
> >> is to move the current path to the end of the module look-up path.
> >> This is only done if the current path is present already.
> > 
> > This is still slightly problematic.
> > 
> > What if you're running Mercurial out of its working directory? I think
> > you need to go a step further and not do this unless
> > os.path.dirname(__file__) != os.getcwd(). 
> 
> I think I see what you mean. What about this one, instead.
> 
> ---===***===---
> diff -r be6233a2bfdd hg
> --- a/hg	Fri Jul 01 19:49:58 2005
> +++ b/hg	Sat Jul 02 14:52:28 2005
> @@ -8,6 +8,12 @@
>  # This software may be used and distributed according to the terms
>  # of the GNU General Public License, incorporated herein by reference.
>  
> +import sys, os
> +cwd = os.getcwd()
> +if cwd in sys.path and os.path.dirname(__file__) != cwd:
> +  sys.path.remove(cwd)
> +  sys.path.append(cwd)
> +
>  from mercurial import commands
>  
>  commands.run()
> ---===***===---
> 
> This also uses the appropriate command (.append() instead of .extend()
> ... sorry, I used the wrong version in the other patch ...)

Ok, still waiting for other Windows folks need to speak up as to
whether this patch is really needed.

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial mailing list