[PATCH] subrepo: fix path normalization

Patrick Mézard pmezard at gmail.com
Mon May 16 17:01:26 CDT 2011


Le 16/05/11 23:59, Patrick Mezard a écrit :
> # HG changeset patch
> # User Patrick Mezard <pmezard at gmail.com>
> # Date 1305582739 -7200
> # Node ID 8a48103713fc7277521b8e6402dfdea054a3dc20
> # Parent  defa319d8bb7cea6a588e453cd4be4b467af8c47
> subrepo: fix path normalization
> 
> Calling posixpath.normpath() on a Windows path does not work as expected:
> 
>   >> posixpath.normpath('c:\\foo\\bar/../baz')
>   >> 'baz'
> 
> Either the path should be first normalized to have a slash as separator, or
> they should be handled by platform specific normalization routines.
> 
> diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> --- a/mercurial/subrepo.py
> +++ b/mercurial/subrepo.py
> @@ -190,19 +190,25 @@
>          return sub._path
>      return reporelpath(sub._repo)
>  
> +def _normpath(url):
> +    if any((url.scheme, url.host, url.user, url.passwd)):
> +        url.path = posixpath.normpath(url.path)
> +    else:
> +        url.path = os.path.normpath(url.path)
> +

I considered turning this into a url method but none of them currently mutate the object and it might be confusing to have a non-mutable localpath() and a mutable normpath().

--
Patrick Mézard


More information about the Mercurial-devel mailing list