Merge lp:~jelmer/brz/fix-redirects into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fix-redirects
Merge into: lp:brz
Diff against target: 112 lines (+25/-16)
2 files modified
breezy/transport/__init__.py (+20/-14)
breezy/transport/http/__init__.py (+5/-2)
To merge this branch: bzr merge lp:~jelmer/brz/fix-redirects
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+373052@code.launchpad.net

Commit message

Raise an informational message when unable to interpret redirect.

Description of the change

Raise an informational message when unable to interpret redirect.

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

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/transport/__init__.py'
--- breezy/transport/__init__.py 2019-02-09 03:23:20 +0000
+++ breezy/transport/__init__.py 2019-09-21 14:46:19 +0000
@@ -31,19 +31,8 @@
31import errno31import errno
32import sys32import sys
3333
34from ..lazy_import import lazy_import
35lazy_import(globals(), """
36from stat import S_ISDIR34from stat import S_ISDIR
3735
38from breezy import (
39 errors,
40 location as _mod_location,
41 osutils,
42 ui,
43 urlutils,
44 )
45""")
46
47from ..sixish import (36from ..sixish import (
48 BytesIO,37 BytesIO,
49 PY3,38 PY3,
@@ -53,8 +42,12 @@
53 mutter,42 mutter,
54 )43 )
55from .. import (44from .. import (
45 errors,
56 hooks,46 hooks,
57 registry,47 registry,
48 osutils,
49 ui,
50 urlutils,
58 )51 )
5952
6053
@@ -96,6 +89,16 @@
96 return result89 return result
9790
9891
92class UnusableRedirect(errors.BzrError):
93
94 _fmt = ("Unable to follow redirect from %(source)s to %(target)s: "
95 "%(reason)s.")
96
97 def __init__(self, source, target, reason):
98 super(UnusableRedirect, self).__init__(
99 source=source, target=target, reason=reason)
100
101
99class TransportListRegistry(registry.Registry):102class TransportListRegistry(registry.Registry):
100 """A registry which simplifies tracking available Transports.103 """A registry which simplifies tracking available Transports.
101104
@@ -1235,11 +1238,13 @@
1235 The redirection can be handled only if the relpath involved is not1238 The redirection can be handled only if the relpath involved is not
1236 renamed by the redirection.1239 renamed by the redirection.
12371240
1238 :returns: A transport or None.1241 :returns: A transport
1242 :raise UnusableRedirect: when redirection can not be provided
1239 """1243 """
1240 # This returns None by default, meaning the transport can't handle the1244 # This returns None by default, meaning the transport can't handle the
1241 # redirection.1245 # redirection.
1242 return None1246 raise UnusableRedirect(
1247 source, target, "transport does not support redirection")
12431248
12441249
1245class _SharedConnection(object):1250class _SharedConnection(object):
@@ -1569,8 +1574,9 @@
1569 """1574 """
1570 if base is None:1575 if base is None:
1571 base = '.'1576 base = '.'
1577 from ..location import location_to_url
1572 return get_transport_from_url(1578 return get_transport_from_url(
1573 _mod_location.location_to_url(base, purpose=purpose),1579 location_to_url(base, purpose=purpose),
1574 possible_transports)1580 possible_transports)
15751581
15761582
15771583
=== modified file 'breezy/transport/http/__init__.py'
--- breezy/transport/http/__init__.py 2019-08-11 16:27:38 +0000
+++ breezy/transport/http/__init__.py 2019-09-21 14:46:19 +0000
@@ -81,6 +81,7 @@
81from ...trace import mutter81from ...trace import mutter
82from ...transport import (82from ...transport import (
83 ConnectedTransport,83 ConnectedTransport,
84 UnusableRedirect,
84 )85 )
8586
8687
@@ -2500,7 +2501,8 @@
2500 The redirection can be handled only if the relpath involved is not2501 The redirection can be handled only if the relpath involved is not
2501 renamed by the redirection.2502 renamed by the redirection.
25022503
2503 :returns: A transport or None.2504 :returns: A transport
2505 :raise UnusableRedirect: when the URL can not be reinterpreted
2504 """2506 """
2505 parsed_source = self._split_url(source)2507 parsed_source = self._split_url(source)
2506 parsed_target = self._split_url(target)2508 parsed_target = self._split_url(target)
@@ -2511,7 +2513,8 @@
2511 if not parsed_target.path.endswith(excess_tail):2513 if not parsed_target.path.endswith(excess_tail):
2512 # The final part of the url has been renamed, we can't handle the2514 # The final part of the url has been renamed, we can't handle the
2513 # redirection.2515 # redirection.
2514 return None2516 raise UnusableRedirect(
2517 source, target, "final part of the url was renamed")
25152518
2516 target_path = parsed_target.path2519 target_path = parsed_target.path
2517 if excess_tail:2520 if excess_tail:

Subscribers

People subscribed via source and target branches