[PATCH 3/3] pwclient: add list-bundle-patches command
Aristeu Sergio Rozanski Filho
aris at ruivo.org
Fri Mar 20 03:57:22 EST 2009
This patch adds list-bundle-patches to pwclient and bundle_list_patches() to
xmlrpc interface.
Signed-off-by: Aristeu Rozanski <aris at redhat.com>
---
apps/patchwork/bin/pwclient | 24 ++++++++++++++++++++++++
apps/patchwork/views/xmlrpc.py | 10 ++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 7fc2d94..69ccc92 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -112,6 +112,7 @@ def usage():
search [str] : Same as 'list'
list-bundles : List available bundles. Can be filtered by -p <project>
get-bundle <ID> : Get information about a single bundle
+ list-bundle-patches <ID> : List patches in a given bundle
view <ID> : View a patch
update [-s state] [-c commit-ref] <ID>
: Update patch\n""")
@@ -302,6 +303,21 @@ def action_get_bundle(rpc, bundle_id):
if len(bundle) > 0:
print("%i\t%s\t%i\t%s" % (bundle['id'], bundle['name'], bundle['n_patches'], bundle['public_url']))
+def action_list_bundle_patches(rpc, bundle_id):
+ if not bundle_id.isdigit():
+ bundle = rpc.bundle_get_byname(bundle_id)
+ try:
+ id = bundle['id']
+ except:
+ sys.stderr.write("Unable to find %s\n" % bundle_id)
+ sys.exit(1)
+ bundle_id = id
+
+ patches = rpc.bundle_list_patches(bundle_id)
+
+ for patch in patches:
+ print patch['id']
+
def patch_id_from_hash(rpc, hash):
patch = rpc.patch_get_by_hash(hash)
if patch == {}:
@@ -466,6 +482,14 @@ def main():
sys.exit(1)
action_get_bundle(rpc, bundle_id)
+ elif action == 'list-bundle-patches':
+ try:
+ bundle_id = args[0]
+ except:
+ sys.stderr.write("No bundle ID given\n");
+ sys.exit(1);
+ action_list_bundle_patches(rpc, bundle_id)
+
else:
sys.stderr.write("Unknown action '%s'\n" % action)
usage()
diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py
index d36a120..b7318c2 100644
--- a/apps/patchwork/views/xmlrpc.py
+++ b/apps/patchwork/views/xmlrpc.py
@@ -461,3 +461,13 @@ def bundle_get_byname(bundle_name):
except:
return {}
+ at xmlrpc_method(False)
+def bundle_list_patches(bundle_id):
+ """List the patches under a given Bundle"""
+ try:
+ bundle = Bundle.objects.get(id = bundle_id)
+ patches = bundle.patches.all()
+ return map(patch_to_dict, patches)
+ except:
+ return []
+
--
1.6.2
More information about the Patchwork
mailing list