[PATCH 1 of 1] url: added support for scp/rsync style URLs for ssh

Thomas Arendsen Hein thomas at intevation.de
Thu Apr 7 03:21:22 CDT 2011


(Adding Sascha to Cc: again, he got dropped)

* Brodie Rao <brodie at bitheap.org> [20110407 09:29]:
> On Apr 6, 2011, at 6:36 AM, Thomas Arendsen Hein wrote:
>> url: added support for scp/rsync style URLs for ssh
>
> Seems like this would be nice to have.

Good to hear :)

>> +        # special case: ssh url of the form [<user>@]<host>:<path>
>> +        if path and ':' in path:
>> +            parts = path.split(':', 1)
>> +            if (parts[0] != 'file' and
>
> Why check for just file? You should probably check that it isn't bundle: 
> either.

"bundle:" and Windows drive letters are handled before.

>> +                not ('/' in parts[0] or '\\' in parts[0]) and
>> +                (not parts[1] or parts[1].startswith('//'))):
>
> Would it be simpler to do some or all of this in a regular expression?

Avoiding regular expressions where easily possible is a good thing.

>> --- a/tests/test-url.py	Wed Apr 06 12:48:59 2011 +0200
>> +++ b/tests/test-url.py	Wed Apr 06 15:22:41 2011 +0200
>> @@ -104,14 +104,10 @@
>>>>> url('http://joe:xxx@/foo')
>>     <url scheme: 'http', user: 'joe', passwd: 'xxx', path: 'foo'>
>>
>> -    Just a scheme and a path:
>> +    Drive letter:
>>
>> -    >>> url('mailto:John.Doe at example.com')
>> -    <url scheme: 'mailto', path: 'John.Doe at example.com'>
>>>>> url('a:b:c:d')
>>     <url path: 'a:b:c:d'>
>> -    >>> url('aa:bb:cc:dd')
>> -    <url scheme: 'aa', path: 'bb:cc:dd'>
>
> Please don't remove these tests, just update them to show the new  
> behavior. It makes it a lot easier to see the consequences of this  
> change.

These tests had the headline "Just a scheme and a path:", but
neither mailto: nor aa: were ever handled by the code, so the tests
were somehow bogus.

Maybe the tests can be re-added with a comment like "We don't handle
this explicitly, therefore these will be read as host names".

Thomas

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Neuer Graben 17, 49074 Osnabrueck - AG Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner


More information about the Mercurial-devel mailing list