[PATCH 3/3] pwclient: Add command to find a whole series of patches

Doug Anderson dianders at chromium.org
Sun Dec 30 17:00:27 EST 2012


Add a new filter option '-r' that uses the newly created XMLRPC method
to list all patches in a series.

Signed-off-by: Doug Anderson <dianders at chromium.org>
---
 apps/patchwork/bin/pwclient |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient
index 5fce359..f3f4134 100755
--- a/apps/patchwork/bin/pwclient
+++ b/apps/patchwork/bin/pwclient
@@ -129,7 +129,8 @@ def usage():
         -w <who>      : Filter by submitter (name, e-mail substring search)
         -d <who>      : Filter by delegate (name, e-mail substring search)
         -n <max #>    : Restrict number of results
-        -m <messageid>: Filter by Message-Id\n""")
+        -m <messageid>: Filter by Message-Id
+        -r <ID>       : Filter by patches in the same series as <ID>\n""")
     sys.stderr.write("""\nActions that take an ID argument can also be \
 invoked with:
         -h <hash>     : Lookup by patch hash\n""")
@@ -170,9 +171,20 @@ def list_patches(patches):
     for patch in patches:
         print("%-7d %-12s %s" % (patch['id'], patch['state'], patch['name']))
 
-def action_list(rpc, filter, submitter_str, delegate_str):
+def action_list(rpc, filter, submitter_str, delegate_str, series_str):
     filter.resolve_ids(rpc)
 
+    if series_str != "":
+        try:
+            patch_id = int(series_str)
+        except:
+            sys.stderr.write("Invalid patch ID given\n")
+            sys.exit(1)
+
+        patches = rpc.patch_to_series(patch_id)
+        list_patches(patches)
+        return
+
     if submitter_str != "":
         ids = person_ids_by_name(rpc, submitter_str)
         if len(ids) == 0:
@@ -329,7 +341,7 @@ auth_actions = ['update']
 
 def main():
     try:
-        opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:m:')
+        opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:m:r:')
     except getopt.GetoptError, err:
         print str(err)
         usage()
@@ -346,6 +358,7 @@ def main():
     project_str = ""
     commit_str = ""
     state_str = ""
+    series_str = ""
     hash_str = ""
     msgid_str = ""
     url = DEFAULT_URL
@@ -363,6 +376,8 @@ def main():
     for name, value in opts:
         if name == '-s':
             state_str = value
+        elif name == '-r':
+            series_str = value
         elif name == '-p':
             project_str = value
         elif name == '-w':
@@ -433,7 +448,7 @@ def main():
     if action == 'list' or action == 'search':
         if len(args) > 0:
             filt.add("name__icontains", args[0])
-        action_list(rpc, filt, submitter_str, delegate_str)
+        action_list(rpc, filt, submitter_str, delegate_str, series_str)
 
     elif action.startswith('project'):
         action_projects(rpc)
-- 
1.7.7.3



More information about the Patchwork mailing list