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
=== modified file 'NEWS'
--- NEWS 2010-06-02 01:54:25 +0000
+++ NEWS 2010-06-02 01:54:25 +0000
@@ -29,6 +29,9 @@
29 arguments on Windows, because bzr script does the same.29 arguments on Windows, because bzr script does the same.
30 (Alexander Belchenko, #588277)30 (Alexander Belchenko, #588277)
3131
32* ``bzr pull`` now works when a lp: URL is explicitly defined as the parent
33 or pull location in locations.conf or branch.conf. (Gordon Tyler)
34
32Improvements35Improvements
33************36************
3437
3538
=== modified file 'bzrlib/tests/test_urlutils.py'
--- bzrlib/tests/test_urlutils.py 2010-06-02 01:54:25 +0000
+++ bzrlib/tests/test_urlutils.py 2010-06-02 01:54:25 +0000
@@ -195,6 +195,20 @@
195 dirname('path/to/foo/', exclude_trailing_slash=False))195 dirname('path/to/foo/', exclude_trailing_slash=False))
196 self.assertEqual('path/..', dirname('path/../foo'))196 self.assertEqual('path/..', dirname('path/../foo'))
197 self.assertEqual('../path', dirname('../path/foo'))197 self.assertEqual('../path', dirname('../path/foo'))
198
199 def test_is_url(self):
200 self.assertTrue(urlutils.is_url('http://foo/bar'))
201 self.assertTrue(urlutils.is_url('bzr+ssh://foo/bar'))
202 self.assertTrue(urlutils.is_url('lp:foo/bar'))
203 self.assertTrue(urlutils.is_url('file:///foo/bar'))
204 self.assertFalse(urlutils.is_url(''))
205 self.assertFalse(urlutils.is_url('foo'))
206 self.assertFalse(urlutils.is_url('foo/bar'))
207 self.assertFalse(urlutils.is_url('/foo'))
208 self.assertFalse(urlutils.is_url('/foo/bar'))
209 self.assertFalse(urlutils.is_url('C:/'))
210 self.assertFalse(urlutils.is_url('C:/foo'))
211 self.assertTrue(urlutils.is_url('C:/foo/bar'))
198212
199 def test_join(self):213 def test_join(self):
200 def test(expected, *args):214 def test(expected, *args):
201215
=== modified file 'bzrlib/transport/__init__.py'
--- bzrlib/transport/__init__.py 2010-05-30 16:26:11 +0000
+++ bzrlib/transport/__init__.py 2010-06-02 01:54:25 +0000
@@ -1551,9 +1551,6 @@
1551 return transport1551 return transport
15521552
15531553
1554# We try to recognize an url lazily (ignoring user, password, etc)
1555_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
1556
1557def get_transport(base, possible_transports=None):1554def get_transport(base, possible_transports=None):
1558 """Open a transport to access a URL or directory.1555 """Open a transport to access a URL or directory.
15591556
@@ -1572,8 +1569,7 @@
1572 base = directories.dereference(base)1569 base = directories.dereference(base)
15731570
1574 def convert_path_to_url(base, error_str):1571 def convert_path_to_url(base, error_str):
1575 m = _urlRE.match(base)1572 if urlutils.is_url(base):
1576 if m:
1577 # This looks like a URL, but we weren't able to1573 # This looks like a URL, but we weren't able to
1578 # instantiate it as such raise an appropriate error1574 # instantiate it as such raise an appropriate error
1579 # FIXME: we have a 'error_str' unused and we use last_err below1575 # FIXME: we have a 'error_str' unused and we use last_err below
15801576
=== modified file 'bzrlib/urlutils.py'
--- bzrlib/urlutils.py 2010-06-02 01:54:25 +0000
+++ bzrlib/urlutils.py 2010-06-02 01:54:25 +0000
@@ -104,6 +104,11 @@
104 return len(scheme), first_path_slash+m.start('path')104 return len(scheme), first_path_slash+m.start('path')
105105
106106
107def is_url(url):
108 """Tests whether a URL is in actual fact a URL."""
109 return _url_scheme_re.match(url) is not None
110
111
107def join(base, *args):112def join(base, *args):
108 """Create a URL by joining sections.113 """Create a URL by joining sections.
109114