Merge lp:~jelmer/brz/github-401s into lp:brz/3.1

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/github-401s
Merge into: lp:brz/3.1
Diff against target: 88 lines (+29/-20)
3 files modified
breezy/plugins/github/hoster.py (+9/-3)
breezy/plugins/propose/cmds.py (+17/-14)
breezy/transport/http/__init__.py (+3/-3)
To merge this branch: bzr merge lp:~jelmer/brz/github-401s
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+388429@code.launchpad.net

Commit message

Raise UnexpectedHttpStatus rather than InvalidHttpResponse.

Description of the change

Raise UnexpectedHttpStatus rather than InvalidHttpResponse.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/plugins/github/hoster.py'
--- breezy/plugins/github/hoster.py 2020-07-30 18:45:47 +0000
+++ breezy/plugins/github/hoster.py 2020-07-30 21:38:23 +0000
@@ -280,9 +280,15 @@
280 'Accept': 'application/vnd.github.v3+json'}280 'Accept': 'application/vnd.github.v3+json'}
281 if self._token:281 if self._token:
282 headers['Authorization'] = 'token %s' % self._token282 headers['Authorization'] = 'token %s' % self._token
283 response = self.transport.request(283 try:
284 method, urlutils.join(self.transport.base, path),284 response = self.transport.request(
285 headers=headers, body=body, retries=3)285 method, urlutils.join(self.transport.base, path),
286 headers=headers, body=body, retries=3)
287 except UnexpectedHttpStatus as e:
288 if e.code == 401:
289 raise GitHubLoginRequired(self)
290 else:
291 raise
286 if response.status == 401:292 if response.status == 401:
287 raise GitHubLoginRequired(self)293 raise GitHubLoginRequired(self)
288 return response294 return response
289295
=== modified file 'breezy/plugins/propose/cmds.py'
--- breezy/plugins/propose/cmds.py 2020-07-30 18:15:12 +0000
+++ breezy/plugins/propose/cmds.py 2020-07-30 21:38:23 +0000
@@ -37,7 +37,7 @@
37 RegistryOption,37 RegistryOption,
38 )38 )
39from ...sixish import text_type39from ...sixish import text_type
40from ...trace import note40from ...trace import note, warning
41from ... import (41from ... import (
42 propose as _mod_propose,42 propose as _mod_propose,
43 )43 )
@@ -271,19 +271,22 @@
271271
272 def run(self, status='open', verbose=False):272 def run(self, status='open', verbose=False):
273 for instance in _mod_propose.iter_hoster_instances():273 for instance in _mod_propose.iter_hoster_instances():
274 for mp in instance.iter_my_proposals(status=status):274 try:
275 self.outf.write('%s\n' % mp.url)275 for mp in instance.iter_my_proposals(status=status):
276 if verbose:276 self.outf.write('%s\n' % mp.url)
277 self.outf.write(277 if verbose:
278 '(Merging %s into %s)\n' %278 self.outf.write(
279 (mp.get_source_branch_url(),279 '(Merging %s into %s)\n' %
280 mp.get_target_branch_url()))280 (mp.get_source_branch_url(),
281 description = mp.get_description()281 mp.get_target_branch_url()))
282 if description:282 description = mp.get_description()
283 self.outf.writelines(283 if description:
284 ['\t%s\n' % l284 self.outf.writelines(
285 for l in description.splitlines()])285 ['\t%s\n' % l
286 self.outf.write('\n')286 for l in description.splitlines()])
287 self.outf.write('\n')
288 except _mod_propose.HosterLoginRequired as e:
289 warning('Skipping %r, login required.', instance)
287290
288291
289class cmd_land_merge_proposal(Command):292class cmd_land_merge_proposal(Command):
290293
=== modified file 'breezy/transport/http/__init__.py'
--- breezy/transport/http/__init__.py 2020-07-28 01:24:51 +0000
+++ breezy/transport/http/__init__.py 2020-07-30 21:38:23 +0000
@@ -1865,9 +1865,9 @@
1865 'Server refuses to fulfill the request (403 Forbidden)'1865 'Server refuses to fulfill the request (403 Forbidden)'
1866 ' for %s' % req.get_full_url())1866 ' for %s' % req.get_full_url())
1867 else:1867 else:
1868 raise errors.InvalidHttpResponse(req.get_full_url(),1868 raise errors.UnexpectedHttpStatus(
1869 'Unable to handle http code %d: %s'1869 req.get_full_url(), code,
1870 % (code, msg))1870 'Unable to handle http code: %s' % msg)
18711871
18721872
1873class Opener(object):1873class Opener(object):

Subscribers

People subscribed via source and target branches