Rev 6127: (gz) Fix breakage when creating a transport at drive root on windows (Martin in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Sep 5 19:48:37 UTC 2011


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

------------------------------------------------------------
revno: 6127 [merge]
revision-id: pqm at pqm.ubuntu.com-20110905194835-zadpgrm73dsrxrkd
parent: pqm at pqm.ubuntu.com-20110904105444-pnhb87wwruork1ki
parent: gzlist at googlemail.com-20110905171809-o1kcid6klnxbcrfm
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-09-05 19:48:35 +0000
message:
  (gz) Fix breakage when creating a transport at drive root on windows (Martin
   [gz])
modified:
  bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
  bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/tests/test_urlutils.py'
--- a/bzrlib/tests/test_urlutils.py	2011-08-15 13:12:36 +0000
+++ b/bzrlib/tests/test_urlutils.py	2011-09-04 23:18:43 +0000
@@ -457,6 +457,12 @@
         self.assertEqual(('file:///C:', '/foo'), extract('file://', '/C:/foo'))
         self.assertEqual(('file:///d|', '/path'), extract('file://', '/d|/path'))
         self.assertRaises(InvalidURL, extract, 'file://', '/path')
+        # Root drives without slash treated as invalid, see bug #841322
+        self.assertEqual(('file:///C:', '/'), extract('file://', '/C:/'))
+        self.assertRaises(InvalidURL, extract, 'file://', '/C:')
+        # Invalid without drive separator or following forward slash
+        self.assertRaises(InvalidURL, extract, 'file://', '/C')
+        self.assertRaises(InvalidURL, extract, 'file://', '/C:ool')
 
     def test_split(self):
         # Test bzrlib.urlutils.split()

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2011-08-28 15:33:21 +0000
+++ b/bzrlib/transport/__init__.py	2011-09-04 23:25:09 +0000
@@ -310,8 +310,7 @@
     def __init__(self, base):
         super(Transport, self).__init__()
         self.base = base
-        self._segment_parameters = urlutils.split_segment_parameters(
-            base.rstrip("/"))[1]
+        self._segment_parameters = urlutils.split_segment_parameters(base)[1]
 
     def _translate_error(self, e, path, raise_generic=True):
         """Translate an IOError or OSError into an appropriate bzr error.

=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py	2011-08-15 13:12:36 +0000
+++ b/bzrlib/urlutils.py	2011-09-04 23:22:47 +0000
@@ -388,7 +388,7 @@
     """On win32 the drive letter needs to be added to the url base."""
     # Strip off the drive letter
     # path is currently /C:/foo
-    if len(path) < 3 or path[2] not in ':|' or path[3] != '/':
+    if len(path) < 4 or path[2] not in ':|' or path[3] != '/':
         raise errors.InvalidURL(url_base + path,
             'win32 file:/// paths need a drive letter')
     url_base += path[0:3] # file:// + /C:

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-09-02 12:45:36 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-09-05 17:18:09 +0000
@@ -148,6 +148,10 @@
 * Decode ``BZR_HOME`` with fs encoding on posix platforms to avoid unicode
   errors.  (Vincent Ladeuil, #822571)
 
+* Fix fallout from URL handling changes in 2.5 that caused an IndexError to be
+  raised whenever a transport at the drive root was opened on windows.
+  (Martin [gz], #841322)
+
 * Rather than an error being raised, a warning is now printed when the
   current user does not have permission to read a configuration file.
   (Jelmer Vernooij, #837324)




More information about the bazaar-commits mailing list