Merge lp:~jelmer/brz/empty-port into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7098
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/empty-port
Merge into: lp:brz
Diff against target: 55 lines (+18/-6)
3 files modified
breezy/tests/test_http.py (+1/-1)
breezy/tests/test_urlutils.py (+9/-0)
breezy/urlutils.py (+8/-5)
To merge this branch: bzr merge lp:~jelmer/brz/empty-port
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+354640@code.launchpad.net

Commit message

Allow port to be empty when parsing URLs.

Description of the change

Allow port to be empty when parsing URLs.

Git allows this, and at least one some Debian Vcs-Git rely on it.

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

Makes sense, most parsers will turn this into the port-less form happily it seems.

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/446/

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/454/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/tests/test_http.py'
--- breezy/tests/test_http.py 2018-08-31 10:23:32 +0000
+++ breezy/tests/test_http.py 2018-09-13 12:06:57 +0000
@@ -389,7 +389,7 @@
389 self._transport('http://example.com/bzr/bzr.dev/')389 self._transport('http://example.com/bzr/bzr.dev/')
390 self.assertRaises(urlutils.InvalidURL,390 self.assertRaises(urlutils.InvalidURL,
391 self._transport,391 self._transport,
392 'http://http://example.com/bzr/bzr.dev/')392 'http://example.com:port/bzr/bzr.dev/')
393393
394 def test_http_root_urls(self):394 def test_http_root_urls(self):
395 """Construction of URLs from server root"""395 """Construction of URLs from server root"""
396396
=== modified file 'breezy/tests/test_urlutils.py'
--- breezy/tests/test_urlutils.py 2018-08-22 02:05:28 +0000
+++ breezy/tests/test_urlutils.py 2018-09-13 12:06:57 +0000
@@ -933,6 +933,15 @@
933 self.assertIsNot(url, url3)933 self.assertIsNot(url, url3)
934 self.assertEqual(url, url3)934 self.assertEqual(url, url3)
935935
936 def test_parse_empty_port(self):
937 parsed = urlutils.URL.from_string('http://example.com:/one')
938 self.assertEqual('http', parsed.scheme)
939 self.assertIs(None, parsed.user)
940 self.assertIs(None, parsed.password)
941 self.assertEqual('example.com', parsed.host)
942 self.assertIs(None, parsed.port)
943 self.assertEqual('/one', parsed.path)
944
936945
937class TestFileRelpath(TestCase):946class TestFileRelpath(TestCase):
938947
939948
=== modified file 'breezy/urlutils.py'
--- breezy/urlutils.py 2018-08-22 02:05:28 +0000
+++ breezy/urlutils.py 2018-09-13 12:06:57 +0000
@@ -929,11 +929,14 @@
929 if ':' in host and not (host[0] == '[' and host[-1] == ']'):929 if ':' in host and not (host[0] == '[' and host[-1] == ']'):
930 # there *is* port930 # there *is* port
931 host, port = host.rsplit(':', 1)931 host, port = host.rsplit(':', 1)
932 try:932 if port:
933 port = int(port)933 try:
934 except ValueError:934 port = int(port)
935 raise InvalidURL('invalid port number %s in url:\n%s' %935 except ValueError:
936 (port, url))936 raise InvalidURL('invalid port number %s in url:\n%s' %
937 (port, url))
938 else:
939 port = None
937 if host != "" and host[0] == '[' and host[-1] == ']': #IPv6940 if host != "" and host[0] == '[' and host[-1] == ']': #IPv6
938 host = host[1:-1]941 host = host[1:-1]
939942

Subscribers

People subscribed via source and target branches