[PATCH] path handling: don't treat paths with unknown scheme as file paths (issue3715)

Mads Kiilerich mads at kiilerich.com
Fri Nov 30 12:33:43 CST 2012


On 11/29/2012 05:40 PM, Till Schneidereit wrote:
> # HG changeset patch
> # User Till Schneidereit <tschneidereit at gmail.com>
> # Date 1354207103 -3600
> # Node ID 3cb67ba27a0795c2fa2728dbcacccd63366723b6
> # Parent  83aa4359c49f67bcb98fb9c7d885ed4ac7443239
> path handling: don't treat paths with unknown scheme as file paths (issue3715)
>
> islocal in hg.py returns True for paths with unknown schemes, making it
> impossible for scheme handlers registered via the handlerfuncs list in url.py
> to handle the URIs.

In which cases would it fail? Can you demonstrate the problem ... and 
perhaps add a test case?

> diff --git a/mercurial/hg.py b/mercurial/hg.py
> --- a/mercurial/hg.py
> +++ b/mercurial/hg.py
> @@ -69,17 +69,17 @@ schemes = {
>       'https': httppeer,
>       'ssh': sshpeer,
>       'static-http': statichttprepo,
>   }
>   
>   def _peerlookup(path):
>       u = util.url(path)
>       scheme = u.scheme or 'file'
> -    thing = schemes.get(scheme) or schemes['file']
> +    thing = schemes.get(scheme)
>       try:
>           return thing(path)
>       except TypeError:
>           return thing

Before _peerlokup used the file scheme for unknown schemes. That 
probably failed, but with a meaningful error message.

With this change _peerlookup will return None for unknown schemes. Can 
the rest of the code handle that? I guess it will crash in unfortunate ways.

Why do you want it to return None?

/Mads


More information about the Mercurial-devel mailing list