Merge lp:~jelmer/brz/fix-git-reidrecits into lp:brz

Proposed by Jelmer Vernooij on 2018-09-09
Status: Merged
Approved by: Jelmer Vernooij on 2018-09-13
Approved revision: 7098
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/fix-git-reidrecits
Merge into: lp:brz
Diff against target: 66 lines (+11/-4)
4 files modified
breezy/git/__init__.py (+3/-2)
breezy/git/dir.py (+6/-1)
breezy/git/remote.py (+1/-0)
breezy/transport/http/__init__.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/fix-git-reidrecits
Reviewer Review Type Date Requested Status
Martin Packman 2018-09-09 Approve on 2018-09-10
Review via email: mp+354534@code.launchpad.net

Commit message

Fix HTTP redirects for Git repositories.

Description of the change

Fix HTTP redirects for Git repositories.

To post a comment you must log in.
Martin Packman (gz) wrote :

Branch misspelt redirects, but attribute has it correct per the _urllib2_wrappers code.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/git/__init__.py'
--- breezy/git/__init__.py 2018-08-04 17:32:58 +0000
+++ breezy/git/__init__.py 2018-09-13 00:20:52 +0000
@@ -148,7 +148,9 @@
148 base_url, _ = urlutils.split_segment_parameters(transport.external_url())148 base_url, _ = urlutils.split_segment_parameters(transport.external_url())
149 url = urlutils.join(base_url, "info/refs") + "?service=git-upload-pack"149 url = urlutils.join(base_url, "info/refs") + "?service=git-upload-pack"
150 from ..transport.http import Request150 from ..transport.http import Request
151 headers = {"Content-Type": "application/x-git-upload-pack-request"}151 headers = {"Content-Type": "application/x-git-upload-pack-request",
152 "Accept": "application/x-git-upload-pack-result",
153 }
152 req = Request('GET', url, accepted_errors=[200, 403, 404, 405],154 req = Request('GET', url, accepted_errors=[200, 403, 404, 405],
153 headers=headers)155 headers=headers)
154 (scheme, user, password, host, port, path) = urlutils.parse_url(req.get_full_url())156 (scheme, user, password, host, port, path) = urlutils.parse_url(req.get_full_url())
@@ -158,7 +160,6 @@
158 elif host == "bazaar.launchpad.net":160 elif host == "bazaar.launchpad.net":
159 # Don't attempt Git probes against bazaar.launchpad.net; pad.lv/1744830161 # Don't attempt Git probes against bazaar.launchpad.net; pad.lv/1744830
160 raise bzr_errors.NotBranchError(transport.base)162 raise bzr_errors.NotBranchError(transport.base)
161 req.follow_redirections = True
162 resp = transport._perform(req)163 resp = transport._perform(req)
163 if resp.code in (404, 405):164 if resp.code in (404, 405):
164 raise bzr_errors.NotBranchError(transport.base)165 raise bzr_errors.NotBranchError(transport.base)
165166
=== modified file 'breezy/git/dir.py'
--- breezy/git/dir.py 2018-08-04 17:32:58 +0000
+++ breezy/git/dir.py 2018-09-13 00:20:52 +0000
@@ -341,8 +341,13 @@
341341
342 """342 """
343 from .transportgit import TransportRepo343 from .transportgit import TransportRepo
344 gitrepo = TransportRepo(transport, self.bare,344 def _open(transport):
345 return TransportRepo(transport, self.bare,
345 refs_text=getattr(self, "_refs_text", None))346 refs_text=getattr(self, "_refs_text", None))
347 def redirected(transport, e, redirection_notice):
348 trace.note(redirection_notice)
349 return transport._redirected_to(e.source, e.target)
350 gitrepo = do_catching_redirections(_open, transport, redirected)
346 if not gitrepo._controltransport.has('HEAD'):351 if not gitrepo._controltransport.has('HEAD'):
347 raise bzr_errors.NotBranchError(path=transport.base)352 raise bzr_errors.NotBranchError(path=transport.base)
348 return LocalGitDir(transport, gitrepo, self)353 return LocalGitDir(transport, gitrepo, self)
349354
=== modified file 'breezy/git/remote.py'
--- breezy/git/remote.py 2018-09-11 19:38:39 +0000
+++ breezy/git/remote.py 2018-09-13 00:20:52 +0000
@@ -644,6 +644,7 @@
644 ('GET' if data is None else 'POST'),644 ('GET' if data is None else 'POST'),
645 url, data, headers,645 url, data, headers,
646 accepted_errors=[200, 404])646 accepted_errors=[200, 404])
647 request.follow_redirections = True
647648
648 response = self.transport._perform(request)649 response = self.transport._perform(request)
649650
650651
=== modified file 'breezy/transport/http/__init__.py'
--- breezy/transport/http/__init__.py 2018-08-01 19:37:07 +0000
+++ breezy/transport/http/__init__.py 2018-09-13 00:20:52 +0000
@@ -611,7 +611,7 @@
611 # determine the excess tail - the relative path that was in611 # determine the excess tail - the relative path that was in
612 # the original request but not part of this transports' URL.612 # the original request but not part of this transports' URL.
613 excess_tail = parsed_source.path[pl:].strip("/")613 excess_tail = parsed_source.path[pl:].strip("/")
614 if not target.endswith(excess_tail):614 if not parsed_target.path.endswith(excess_tail):
615 # The final part of the url has been renamed, we can't handle the615 # The final part of the url has been renamed, we can't handle the
616 # redirection.616 # redirection.
617 return None617 return None

Subscribers

People subscribed via source and target branches