Merge lp:~doxxx/bzr/534787-pull-lp-in-config into lp:bzr

Proposed by Gordon Tyler
Status: Merged
Merged at revision: 5294
Proposed branch: lp:~doxxx/bzr/534787-pull-lp-in-config
Merge into: lp:bzr
Prerequisite: lp:~doxxx/bzr/urlutils-lp-support
Diff against target: 77 lines (+23/-5)
4 files modified
NEWS (+3/-0)
bzrlib/tests/test_urlutils.py (+14/-0)
bzrlib/transport/__init__.py (+1/-5)
bzrlib/urlutils.py (+5/-0)
To merge this branch: bzr merge lp:~doxxx/bzr/534787-pull-lp-in-config
Reviewer Review Type Date Requested Status
Andrew Bennetts Needs Fixing
Martin Pool Approve
Review via email: mp+26552@code.launchpad.net

Commit message

(doxxx) Fixed 'bzr pull' when lp: URL explicitly defined in locations.conf or branch.conf.

Description of the change

This fixes bug 534787 by fixing how get_transport tests whether a base path is actually a URL in its convert_path_to_url function.

It depends on lp:~doxxx/bzr/urlutils-lp-support for fixes in bzrlib.urlutils to handle lp: URLs.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

That looks pretty nice. (Yet to review the other patch.)

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

 review approve

> This fixes bug 534787 by fixing how get_transport tests whether a base path is
> actually a URL in its convert_path_to_url function.

Looks good. Only one tweak:

[...]
> +* ``bzr pull`` now works when a lp: URL is explicitly defined as the parent
> + or pull location in locations.conf or branch.conf. (Gordon Tyler)

This NEWS entry should include the bug number. I'll fix that and land it (as
the prerequisite branch is now approved).

Thanks!

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

The combined branch (including my tweak to NEWS, <lp:~spiv/bzr/534787-pull-lp-in-config>) is failing tests:

======================================================================
FAIL: bzrlib.tests.test_urlutils.TestUrlToPath.test_is_url
----------------------------------------------------------------------
_StringException: Text attachment: log
------------

------------
Text attachment: traceback
------------
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/testtools/runtest.py", line 128, in _run_user
    return fn(*args)
  File "/usr/lib/python2.6/dist-packages/testtools/testcase.py", line 368, in _run_test_method
    testMethod()
  File "/home/andrew/warthogs/bzr/534787-pull-lp-in-config/bzrlib/tests/test_urlutils.py", line 211, in test_is_url
    self.assertTrue(urlutils.is_url('C:/foo/bar'))
AssertionError
------------

review: Needs Fixing
Revision history for this message
Gordon Tyler (doxxx) wrote :

Sorry, looks like I left a debugging change in, that should be assertFalse.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-06-02 01:54:25 +0000
3+++ NEWS 2010-06-02 01:54:25 +0000
4@@ -29,6 +29,9 @@
5 arguments on Windows, because bzr script does the same.
6 (Alexander Belchenko, #588277)
7
8+* ``bzr pull`` now works when a lp: URL is explicitly defined as the parent
9+ or pull location in locations.conf or branch.conf. (Gordon Tyler)
10+
11 Improvements
12 ************
13
14
15=== modified file 'bzrlib/tests/test_urlutils.py'
16--- bzrlib/tests/test_urlutils.py 2010-06-02 01:54:25 +0000
17+++ bzrlib/tests/test_urlutils.py 2010-06-02 01:54:25 +0000
18@@ -195,6 +195,20 @@
19 dirname('path/to/foo/', exclude_trailing_slash=False))
20 self.assertEqual('path/..', dirname('path/../foo'))
21 self.assertEqual('../path', dirname('../path/foo'))
22+
23+ def test_is_url(self):
24+ self.assertTrue(urlutils.is_url('http://foo/bar'))
25+ self.assertTrue(urlutils.is_url('bzr+ssh://foo/bar'))
26+ self.assertTrue(urlutils.is_url('lp:foo/bar'))
27+ self.assertTrue(urlutils.is_url('file:///foo/bar'))
28+ self.assertFalse(urlutils.is_url(''))
29+ self.assertFalse(urlutils.is_url('foo'))
30+ self.assertFalse(urlutils.is_url('foo/bar'))
31+ self.assertFalse(urlutils.is_url('/foo'))
32+ self.assertFalse(urlutils.is_url('/foo/bar'))
33+ self.assertFalse(urlutils.is_url('C:/'))
34+ self.assertFalse(urlutils.is_url('C:/foo'))
35+ self.assertTrue(urlutils.is_url('C:/foo/bar'))
36
37 def test_join(self):
38 def test(expected, *args):
39
40=== modified file 'bzrlib/transport/__init__.py'
41--- bzrlib/transport/__init__.py 2010-05-30 16:26:11 +0000
42+++ bzrlib/transport/__init__.py 2010-06-02 01:54:25 +0000
43@@ -1551,9 +1551,6 @@
44 return transport
45
46
47-# We try to recognize an url lazily (ignoring user, password, etc)
48-_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
49-
50 def get_transport(base, possible_transports=None):
51 """Open a transport to access a URL or directory.
52
53@@ -1572,8 +1569,7 @@
54 base = directories.dereference(base)
55
56 def convert_path_to_url(base, error_str):
57- m = _urlRE.match(base)
58- if m:
59+ if urlutils.is_url(base):
60 # This looks like a URL, but we weren't able to
61 # instantiate it as such raise an appropriate error
62 # FIXME: we have a 'error_str' unused and we use last_err below
63
64=== modified file 'bzrlib/urlutils.py'
65--- bzrlib/urlutils.py 2010-06-02 01:54:25 +0000
66+++ bzrlib/urlutils.py 2010-06-02 01:54:25 +0000
67@@ -104,6 +104,11 @@
68 return len(scheme), first_path_slash+m.start('path')
69
70
71+def is_url(url):
72+ """Tests whether a URL is in actual fact a URL."""
73+ return _url_scheme_re.match(url) is not None
74+
75+
76 def join(base, *args):
77 """Create a URL by joining sections.
78