Rev 4830: bzrlib.urlutils.local_path_from_url now accepts file://localhost/ as in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Nov 26 05:59:18 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4830 [merge]
revision-id: pqm at pqm.ubuntu.com-20091126054210-6mbpjr1bstyu92wv
parent: pqm at pqm.ubuntu.com-20091126045809-fzd0z4hll8fsgosd
parent: michael.hudson at canonical.com-20091126040919-vfjvv7gcpdo4w4jm
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-11-26 05:42:10 +0000
message:
bzrlib.urlutils.local_path_from_url now accepts file://localhost/ as
well as file:/// URLs on POSIX. (Michael Hudson)
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 2009-11-26 01:42:06 +0000
+++ b/NEWS 2009-11-26 04:09:19 +0000
@@ -54,6 +54,10 @@
Improvements
************
+* ``bzrlib.urlutils.local_path_from_url`` now accepts
+ 'file://localhost/' as well as 'file:///' URLs on POSIX. (Michael
+ Hudson)
+
Documentation
*************
=== modified file 'bzrlib/tests/test_urlutils.py'
--- a/bzrlib/tests/test_urlutils.py 2009-04-04 01:45:09 +0000
+++ b/bzrlib/tests/test_urlutils.py 2009-11-26 04:01:58 +0000
@@ -17,7 +17,6 @@
"""Tests for the urlutils wrapper."""
import os
-import re
import sys
from bzrlib import osutils, urlutils, win32utils
@@ -300,8 +299,13 @@
from_url('file:///path/to/r%C3%A4ksm%C3%B6rg%C3%A5s'))
self.assertEqual(u'/path/to/r\xe4ksm\xf6rg\xe5s',
from_url('file:///path/to/r%c3%a4ksm%c3%b6rg%c3%a5s'))
+ self.assertEqual(u'/path/to/r\xe4ksm\xf6rg\xe5s',
+ from_url('file://localhost/path/to/r%c3%a4ksm%c3%b6rg%c3%a5s'))
self.assertRaises(InvalidURL, from_url, '/path/to/foo')
+ self.assertRaises(
+ InvalidURL, from_url,
+ 'file://remotehost/path/to/r%c3%a4ksm%c3%b6rg%c3%a5s')
def test_win32_local_path_to_url(self):
to_url = urlutils._win32_local_path_to_url
=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py 2009-07-16 07:10:45 +0000
+++ b/bzrlib/urlutils.py 2009-11-26 04:01:58 +0000
@@ -217,10 +217,16 @@
# jam 20060502 Sorted to 'l' because the final target is 'local_path_from_url'
def _posix_local_path_from_url(url):
"""Convert a url like file:///path/to/foo into /path/to/foo"""
- if not url.startswith('file:///'):
- raise errors.InvalidURL(url, 'local urls must start with file:///')
+ file_localhost_prefix = 'file://localhost/'
+ if url.startswith(file_localhost_prefix):
+ path = url[len(file_localhost_prefix) - 1:]
+ elif not url.startswith('file:///'):
+ raise errors.InvalidURL(
+ url, 'local urls must start with file:/// or file://localhost/')
+ else:
+ path = url[len('file://'):]
# We only strip off 2 slashes
- return unescape(url[len('file://'):])
+ return unescape(path)
def _posix_local_path_to_url(path):
More information about the bazaar-commits
mailing list