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>
sys.stderr.write("Error: No patch content found\n")
sys.exit(1)
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" % \
patch = rpc.patch_get(patch_id)
if patch == {}:
sys.stderr.write("Error getting information on patch ID %d\n" % \
if commit:
params['commit_ref'] = commit
if commit:
params['commit_ref'] = commit
+ if archived:
+ params['archived'] = archived == 'yes'
+
success = False
try:
success = rpc.patch_set(patch_id, params)
success = False
try:
success = rpc.patch_set(patch_id, params)
'-s', metavar='STATE',
help='''Filter by patch state (e.g., 'New', 'Accepted', etc.)'''
)
'-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)'''
filter_parser.add_argument(
'-p', metavar='PROJECT',
help='''Filter by project name (see 'projects' for list)'''
required=True,
help='''Set patch state (e.g., 'Accepted', 'Superseded' etc.)'''
)
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,
update_parser.set_defaults(subcmd='update')
list_parser = subparsers.add_parser("list",
add_help=False,
commit_str = None
url = DEFAULT_URL
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')
state_str = args.get('s')
project_str = args.get('p')
submitter_str = args.get('w')
if state_str:
filt.add("state", state_str)
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)
if msgid_str:
filt.add("msgid", msgid_str)
elif action == 'update':
for patch_id in non_empty(h, patch_ids):
action_update_patch(rpc, patch_id, state = state_str,
elif action == 'update':
for patch_id in non_empty(h, patch_ids):
action_update_patch(rpc, patch_id, state = state_str,
+ archived = archived_str, commit = commit_str