summaryrefslogtreecommitdiffstats
path: root/apps/patchwork/bin/pwclient
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2014-11-22 21:49:53 -0800
committerJeremy Kerr <jk@ozlabs.org>2015-03-22 21:08:30 +0800
commit968f33eff4be769159771d7b5db4444a8112b227 (patch)
tree2294bac67fe0881db340dcfb041aca928c611e5a /apps/patchwork/bin/pwclient
parent235238fdfbfbf4e201a36c0ea57576bf63bc3536 (diff)
downloadpatchwork-968f33eff4be769159771d7b5db4444a8112b227.tar.bz2
patchwork-968f33eff4be769159771d7b5db4444a8112b227.tar.xz
pwclient: support 'archived' filtering and updating
Examples: # Mark patch as uperseded and archived pwclient update -s Superseded -a yes <ID> # 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 <computersforpeace@gmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/bin/pwclient')
-rwxr-xr-xapps/patchwork/bin/pwclient19
1 files 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)
@@ -371,6 +374,10 @@ def main():
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: