/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: Adrian Wilkins
  • Date: 2008-06-18 12:25:26 UTC
  • mto: This revision was merged to the branch mainline in revision 3550.
  • Revision ID: adrian.wilkins@gmail.com-20080618122526-dq1s32hhlrqno1eq
Add a couple of special cases to urlutils._win32_path_(from|to)_url

 * 'file://' resolves to a path of ''
 * '/' resolves to a URI of 'file://'

This fixes #240910 by allowing ``bzr serve --directory=/`` to access all paths
on the Windows filesystem rather than just paths relative to the root of the 
drive Python.exe is running from. This is the value for the directory arg
used by remote SSH invocation, so the most desirable effect is to allow
you to reach any permitted path on the filesystem using SSH as with *nix.

Internally, this works by creating a LocalTransport instance with an empty string 
as a base path. This allows you to pass normal (for Windows) ssh/sftp URIs in the style :

bzr://camelot/x:/foo/bar
bzr+ssh://robin@camelot/x:/foo/bar

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
 
238
238
def _win32_local_path_from_url(url):
239
239
    """Convert a url like file:///C:/path/to/foo into C:/path/to/foo"""
 
240
    if url == 'file://':
 
241
        return ''
 
242
 
240
243
    if not url.startswith('file://'):
241
244
        raise errors.InvalidURL(url, 'local urls must start with file:///, '
242
245
                                     'UNC path urls must start with file://')
270
273
    #       which actually strips trailing space characters.
271
274
    #       The worst part is that under linux ntpath.abspath has different
272
275
    #       semantics, since 'nt' is not an available module.
 
276
    if path == '/':
 
277
        return 'file://'
 
278
 
273
279
    win32_path = osutils._win32_abspath(path)
274
280
    # check for UNC path \\HOST\path
275
281
    if win32_path.startswith('//'):