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
1=== modified file 'breezy/tests/test_http.py'
2--- breezy/tests/test_http.py 2018-08-31 10:23:32 +0000
3+++ breezy/tests/test_http.py 2018-09-13 12:06:57 +0000
4@@ -389,7 +389,7 @@
5 self._transport('http://example.com/bzr/bzr.dev/')
6 self.assertRaises(urlutils.InvalidURL,
7 self._transport,
8- 'http://http://example.com/bzr/bzr.dev/')
9+ 'http://example.com:port/bzr/bzr.dev/')
10
11 def test_http_root_urls(self):
12 """Construction of URLs from server root"""
13
14=== modified file 'breezy/tests/test_urlutils.py'
15--- breezy/tests/test_urlutils.py 2018-08-22 02:05:28 +0000
16+++ breezy/tests/test_urlutils.py 2018-09-13 12:06:57 +0000
17@@ -933,6 +933,15 @@
18 self.assertIsNot(url, url3)
19 self.assertEqual(url, url3)
20
21+ def test_parse_empty_port(self):
22+ parsed = urlutils.URL.from_string('http://example.com:/one')
23+ self.assertEqual('http', parsed.scheme)
24+ self.assertIs(None, parsed.user)
25+ self.assertIs(None, parsed.password)
26+ self.assertEqual('example.com', parsed.host)
27+ self.assertIs(None, parsed.port)
28+ self.assertEqual('/one', parsed.path)
29+
30
31 class TestFileRelpath(TestCase):
32
33
34=== modified file 'breezy/urlutils.py'
35--- breezy/urlutils.py 2018-08-22 02:05:28 +0000
36+++ breezy/urlutils.py 2018-09-13 12:06:57 +0000
37@@ -929,11 +929,14 @@
38 if ':' in host and not (host[0] == '[' and host[-1] == ']'):
39 # there *is* port
40 host, port = host.rsplit(':', 1)
41- try:
42- port = int(port)
43- except ValueError:
44- raise InvalidURL('invalid port number %s in url:\n%s' %
45- (port, url))
46+ if port:
47+ try:
48+ port = int(port)
49+ except ValueError:
50+ raise InvalidURL('invalid port number %s in url:\n%s' %
51+ (port, url))
52+ else:
53+ port = None
54 if host != "" and host[0] == '[' and host[-1] == ']': #IPv6
55 host = host[1:-1]
56

Subscribers

People subscribed via source and target branches