Merge ~cjwatson/turnip:simplify-hookrpc-mp-url into turnip:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 87c305c8ec67eca7548b9c6854c64d92750a5125
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/turnip:simplify-hookrpc-mp-url
Merge into: turnip:master
Diff against target: 40 lines (+6/-23)
1 file modified
turnip/pack/hookrpc.py (+6/-23)
Reviewer Review Type Date Requested Status
Simone Pelosi Approve
Review via email: mp+448585@code.launchpad.net

Commit message

Simplify getMergeProposalURL fault handling

Description of the change

The XML-RPC fault handling for `getMergeProposalURL` was apparently copied from `checkRefPermissions`, and included some specific handling of `NOT_FOUND` and `UNAUTHORIZED` exceptions that isn't needed here; all it did in this case was change the logging behaviour slightly. Simplify it.

To post a comment you must log in.
Revision history for this message
Simone Pelosi (pelpsi) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/turnip/pack/hookrpc.py b/turnip/pack/hookrpc.py
2index 6ec1a06..8b98c86 100644
3--- a/turnip/pack/hookrpc.py
4+++ b/turnip/pack/hookrpc.py
5@@ -271,29 +271,12 @@ class HookRPCHandler(object):
6 self.virtinfo_timeout, self.reactor)
7 except xmlrpc.Fault as e:
8 code = translate_xmlrpc_fault(e.faultCode)
9- if code in (
10- TurnipFaultCode.NOT_FOUND,
11- TurnipFaultCode.UNAUTHORIZED,
12- ):
13- # These faults can happen with unlucky timing: a NOT_FOUND
14- # fault can happen if the repository was removed from disk
15- # between translatePath and checkRefPermissions (although
16- # that's impossible in practice with Launchpad's
17- # implementation); similarly, an UNAUTHORIZED fault can
18- # happen if the user's access to the repository was removed
19- # between translatePath and checkRefPermissions. Just
20- # treat this as if the user has no permissions on any ref.
21- log_context.log.info(
22- "getMergeProposalURL virtinfo raised Unauthorized: "
23- "auth_params={auth_params}, ref_path={ref_path}",
24- auth_params=auth_params, branch=branch)
25- else:
26- log_context.log.info(
27- "getMergeProposalURL virtinfo raised "
28- "{fault_code} {fault_string}: "
29- "auth_params={auth_params}, ref_path={ref_path}",
30- fault_code=code.name, fault_string=e.faultString,
31- auth_params=auth_params, branch=branch)
32+ log_context.log.info(
33+ "getMergeProposalURL virtinfo raised "
34+ "{fault_code} {fault_string}: "
35+ "auth_params={auth_params}, ref_path={ref_path}",
36+ fault_code=code.name, fault_string=e.faultString,
37+ auth_params=auth_params, branch=branch)
38 except defer.TimeoutError:
39 log_context.log.info(
40 "getMergeProposalURL timed out: ref_path={path}", path=path)

Subscribers

People subscribed via source and target branches