Rev 3550: (Adrian Wilkins) Serve all filesystem roots on Windows (bug #240910) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jul 17 07:17:57 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3550
revision-id:pqm at pqm.ubuntu.com-20080717061742-zs1bj4n2m7qnzoaf
parent: pqm at pqm.ubuntu.com-20080717023455-idnyms69oiauf7fh
parent: adwi2 at 014661-xp-20080711230517-6giupapiqdpuduir
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-07-17 07:17:42 +0100
message:
  (Adrian Wilkins) Serve all filesystem roots on Windows (bug #240910)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
  bzrlib/transport/local.py      local_transport.py-20050711165921-9b1f142bfe480c24
  bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
    ------------------------------------------------------------
    revno: 3503.1.2
    revision-id:adwi2 at 014661-xp-20080711230517-6giupapiqdpuduir
    parent: adrian.wilkins at gmail.com-20080618122526-dq1s32hhlrqno1eq
    committer: adwi2 <adwi2 at 014661-XP>
    branch nick: bzr.serve_all_roots_win32
    timestamp: Sat 2008-07-12 00:05:17 +0100
    message:
      Permits Windows to serve all paths on all drives.
      
       1) Special case in local transport for "/" on Windows
          * This is taken to be an empty base path
       2) urlutils._win32_path_(from|to)_url changes
          * file:/// == / and vice versa
      
      This fixes the problems detailed in #240910
       * Since the server started by use of bzr+ssh:// uses '/' as a base,
         you can now access paths that are not on the root of the drive
         Python.exe is hosted on
       * You may now voluntarily serve all paths from a single server process, 
         should you find this desirable
    modified:
      bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
      bzrlib/transport/local.py      local_transport.py-20050711165921-9b1f142bfe480c24
      bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
    ------------------------------------------------------------
    revno: 3503.1.1
    revision-id:adrian.wilkins at gmail.com-20080618122526-dq1s32hhlrqno1eq
    parent: pqm at pqm.ubuntu.com-20080618051428-txnglk8ls5jd93fc
    committer: Adrian Wilkins <adrian.wilkins at gmail.com>
    branch nick: bzr.serve_all_roots_win32
    timestamp: Wed 2008-06-18 13:25:26 +0100
    message:
      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
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
      bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
=== modified file 'NEWS'
--- a/NEWS	2008-07-16 23:23:13 +0000
+++ b/NEWS	2008-07-17 06:17:42 +0000
@@ -64,6 +64,11 @@
       requires a branch to be present.
       (Daniel Watkins, #64783)
 
+    * ``bzr serve --directory=/`` now correctly allows the whole
+      filesystem to be accessed on Windows, not just the root of the drive
+      that Python is running from.
+      (Adrian Wilkins, #240910)
+
     * Clearer message about how to set the PYTHONPATH if bzrlib can't be
       loaded. 
       (Martin Pool, #205230)

=== modified file 'bzrlib/tests/test_urlutils.py'
--- a/bzrlib/tests/test_urlutils.py	2008-06-20 14:47:40 +0000
+++ b/bzrlib/tests/test_urlutils.py	2008-07-17 06:17:42 +0000
@@ -316,6 +316,8 @@
         #     to_url('C:/path/to/foo '))
         self.assertEqual('file:///C:/path/to/f%20oo',
             to_url('C:/path/to/f oo'))
+        
+        self.assertEqual('file:///', to_url('/'))
 
         try:
             result = to_url(u'd:/path/to/r\xe4ksm\xf6rg\xe5s')
@@ -348,6 +350,7 @@
             from_url('file:///d|/path/to/r%C3%A4ksm%C3%B6rg%C3%A5s'))
         self.assertEqual(u'D:/path/to/r\xe4ksm\xf6rg\xe5s',
             from_url('file:///d:/path/to/r%c3%a4ksm%c3%b6rg%c3%a5s'))
+        self.assertEqual('/', from_url('file:///'))
 
         self.assertRaises(InvalidURL, from_url, '/path/to/foo')
         # Not a valid _win32 url, no drive letter

=== modified file 'bzrlib/transport/local.py'
--- a/bzrlib/transport/local.py	2008-04-24 07:22:53 +0000
+++ b/bzrlib/transport/local.py	2008-07-11 23:05:17 +0000
@@ -63,6 +63,15 @@
             base = urlutils.local_path_to_url(base)
         if base[-1] != '/':
             base = base + '/'
+
+        # Special case : windows has no "root", but does have
+        # multiple lettered drives inside it. #240910
+        if sys.platform == 'win32' and base == 'file:///':
+            base = ''
+            self._local_base = ''
+            super(LocalTransport, self).__init__(base)
+            return
+            
         super(LocalTransport, self).__init__(base)
         self._local_base = urlutils.local_path_from_url(base)
 

=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py	2008-07-15 13:56:41 +0000
+++ b/bzrlib/urlutils.py	2008-07-17 06:17:42 +0000
@@ -250,6 +250,11 @@
             raise errors.InvalidURL(url, 'Win32 UNC path urls'
                 ' have form file://HOST/path')
         return unescape(win32_url)
+
+    # allow empty paths so we can serve all roots
+    if win32_url == '///':
+        return '/'
+    
     # usual local path with drive letter
     if (win32_url[3] not in ('abcdefghijklmnopqrstuvwxyz'
                              'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
@@ -271,6 +276,9 @@
     #       which actually strips trailing space characters.
     #       The worst part is that under linux ntpath.abspath has different
     #       semantics, since 'nt' is not an available module.
+    if path == '/':
+        return 'file:///'
+
     win32_path = osutils._win32_abspath(path)
     # check for UNC path \\HOST\path
     if win32_path.startswith('//'):




More information about the bazaar-commits mailing list