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
diff --git a/turnip/pack/hookrpc.py b/turnip/pack/hookrpc.py
index 6ec1a06..8b98c86 100644
--- a/turnip/pack/hookrpc.py
+++ b/turnip/pack/hookrpc.py
@@ -271,29 +271,12 @@ class HookRPCHandler(object):
271 self.virtinfo_timeout, self.reactor)271 self.virtinfo_timeout, self.reactor)
272 except xmlrpc.Fault as e:272 except xmlrpc.Fault as e:
273 code = translate_xmlrpc_fault(e.faultCode)273 code = translate_xmlrpc_fault(e.faultCode)
274 if code in (274 log_context.log.info(
275 TurnipFaultCode.NOT_FOUND,275 "getMergeProposalURL virtinfo raised "
276 TurnipFaultCode.UNAUTHORIZED,276 "{fault_code} {fault_string}: "
277 ):277 "auth_params={auth_params}, ref_path={ref_path}",
278 # These faults can happen with unlucky timing: a NOT_FOUND278 fault_code=code.name, fault_string=e.faultString,
279 # fault can happen if the repository was removed from disk279 auth_params=auth_params, branch=branch)
280 # between translatePath and checkRefPermissions (although
281 # that's impossible in practice with Launchpad's
282 # implementation); similarly, an UNAUTHORIZED fault can
283 # happen if the user's access to the repository was removed
284 # between translatePath and checkRefPermissions. Just
285 # treat this as if the user has no permissions on any ref.
286 log_context.log.info(
287 "getMergeProposalURL virtinfo raised Unauthorized: "
288 "auth_params={auth_params}, ref_path={ref_path}",
289 auth_params=auth_params, branch=branch)
290 else:
291 log_context.log.info(
292 "getMergeProposalURL virtinfo raised "
293 "{fault_code} {fault_string}: "
294 "auth_params={auth_params}, ref_path={ref_path}",
295 fault_code=code.name, fault_string=e.faultString,
296 auth_params=auth_params, branch=branch)
297 except defer.TimeoutError:280 except defer.TimeoutError:
298 log_context.log.info(281 log_context.log.info(
299 "getMergeProposalURL timed out: ref_path={path}", path=path)282 "getMergeProposalURL timed out: ref_path={path}", path=path)

Subscribers

People subscribed via source and target branches