From 968f33eff4be769159771d7b5db4444a8112b227 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Sat, 22 Nov 2014 21:49:53 -0800 Subject: pwclient: support 'archived' filtering and updating Examples: # Mark patch as uperseded and archived pwclient update -s Superseded -a yes # List all archived patches pwclient list -a yes Notably, we still leave the '-s' option as required for 'pwclient update'; so you can't *just* archive a patch without setting its state. I couldn't quite figure out the right argparse usage to represent that the user must include one or both of '-s' and '-a'. And of course, the server must have an updated xmlrpc that supports the 'archived' field for list filtering (recently patched), otherwise you'll just get an empty list. Signed-off-by: Brian Norris Signed-off-by: Jeremy Kerr --- apps/patchwork/bin/pwclient | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient index 70d4f82..0a477c2 100755 --- a/apps/patchwork/bin/pwclient +++ b/apps/patchwork/bin/pwclient @@ -274,7 +274,7 @@ def action_apply(rpc, patch_id, apply_cmd=None): sys.stderr.write("Error: No patch content found\n") sys.exit(1) -def action_update_patch(rpc, patch_id, state = None, commit = None): +def action_update_patch(rpc, patch_id, state = None, archived = None, commit = None): patch = rpc.patch_get(patch_id) if patch == {}: sys.stderr.write("Error getting information on patch ID %d\n" % \ @@ -293,6 +293,9 @@ def action_update_patch(rpc, patch_id, state = None, commit = None): if commit: params['commit_ref'] = commit + if archived: + params['archived'] = archived == 'yes' + success = False try: success = rpc.patch_set(patch_id, params) @@ -370,6 +373,10 @@ def main(): '-s', metavar='STATE', help='''Filter by patch state (e.g., 'New', 'Accepted', etc.)''' ) + filter_parser.add_argument( + '-a', choices=['yes','no'], + help='''Filter by patch archived state''' + ) filter_parser.add_argument( '-p', metavar='PROJECT', help='''Filter by project name (see 'projects' for list)''' @@ -486,6 +493,10 @@ def main(): required=True, help='''Set patch state (e.g., 'Accepted', 'Superseded' etc.)''' ) + update_parser.add_argument( + '-a', choices=['yes', 'no'], + help='''Set patch archived state''' + ) update_parser.set_defaults(subcmd='update') list_parser = subparsers.add_parser("list", add_help=False, @@ -525,6 +536,7 @@ def main(): commit_str = None url = DEFAULT_URL + archived_str = args.get('a') state_str = args.get('s') project_str = args.get('p') submitter_str = args.get('w') @@ -630,6 +642,9 @@ def main(): if state_str: filt.add("state", state_str) + if archived_str: + filt.add("archived", archived_str == 'yes') + if msgid_str: filt.add("msgid", msgid_str) @@ -702,7 +717,7 @@ def main(): elif action == 'update': for patch_id in non_empty(h, patch_ids): action_update_patch(rpc, patch_id, state = state_str, - commit = commit_str + archived = archived_str, commit = commit_str ) else: -- cgit v1.2.3