From patchwork Sun Dec 30 06:00:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/3] xmlrpc: Export the "to_series" method in patch objects Date: Sat, 29 Dec 2012 20:00:26 -0000 From: Doug Anderson X-Patchwork-Id: 208711 Message-Id: <1356847227-8917-3-git-send-email-dianders@chromium.org> To: patchwork@lists.ozlabs.org Cc: Simon Glass , Jeremy Kerr , Mauro Carvalho Chehab A follow-on CL will add support in pwclient to call this XMLRPC method to allow listing all of the patches in a series. Signed-off-by: Doug Anderson --- apps/patchwork/views/xmlrpc.py | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py index a69c858..36ed605 100644 --- a/apps/patchwork/views/xmlrpc.py +++ b/apps/patchwork/views/xmlrpc.py @@ -419,6 +419,28 @@ def patch_set(user, patch_id, params): raise @xmlrpc_method(False) +def patch_to_series(patch_id): + """Take a patch ID and return a list of patches in the same series. + + This uses some heuristics to do its job so might not be perfect. + See the function in the Patch model for details. + + @patch_id: The patch ID that's part of the series. + @return: A list of patches in the series. + """ + # Get the patch. + patch = Patch.objects.filter(id=patch_id) + if not patch: + return [] + patch = patch[0] + + # Make a series. + patches = patch.to_series() + + # Convert to dict for xmlrpc. + return [patch_to_dict(p) for p in patches] + +@xmlrpc_method(False) def state_list(search_str="", max_count=0): """Get a list of state structures matching the given search string.""" try: