From patchwork Sun Dec 30 06:00:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 208711 X-Patchwork-Delegate: stephen.finucane@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id DE89F2C00D6 for ; Sun, 30 Dec 2012 17:00:54 +1100 (EST) Received: from mail-qc0-f201.google.com (mail-qc0-f201.google.com [209.85.216.201]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D5B142C00D0 for ; Sun, 30 Dec 2012 17:00:47 +1100 (EST) Received: by mail-qc0-f201.google.com with SMTP id a6so1232532qch.4 for ; Sat, 29 Dec 2012 22:00:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=No200qDH7R7aDl689taHfl1ssufL3xGyNjtCwUtF9Bo=; b=nthN9wfzWiKDbLDW3wjHlZNkzS09EBVnUm5JMbJK/V3MhbKTnIDP2vgrpV1Ia34kH+ Te4DFnXlSaGQmJ0MEBVSxHpLMhN/nkVIJ6OHTkvjt6GMCG3CiDXv+X+ApOLri/JrydDI ssWpGh08y+h9YJjj7LfKTFIrhjb3B1zZMxcY9cIIidxQJ0XyiZZiBwPIRiSmK4OKFXxm u1iGx8kRolrH4Z1cteDZD7O4VGVMttAl++UiBt6Jscrs34aK1Nw8td/Ue7FLbwRNLesM yw9oEKmvNoMOXgJep5Irrs4uzjbAqLVTQVw9tkSNMAs97JFUII5nT5LcGd19ivUQ27ea jSYw== X-Received: by 10.236.150.97 with SMTP id y61mr17998309yhj.25.1356847244459; Sat, 29 Dec 2012 22:00:44 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id i27si2958601yhe.4.2012.12.29.22.00.44 (version=TLSv1/SSLv3 cipher=AES128-SHA); Sat, 29 Dec 2012 22:00:44 -0800 (PST) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.73.80]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 5BD0982004A; Sat, 29 Dec 2012 22:00:44 -0800 (PST) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 0FCB680F1B; Sat, 29 Dec 2012 22:00:44 -0800 (PST) From: Doug Anderson To: patchwork@lists.ozlabs.org Subject: [PATCH 2/3] xmlrpc: Export the "to_series" method in patch objects Date: Sat, 29 Dec 2012 22:00:26 -0800 Message-Id: <1356847227-8917-3-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1356847227-8917-1-git-send-email-dianders@chromium.org> References: <1356037567-10048-1-git-send-email-dianders@chromium.org> <1356847227-8917-1-git-send-email-dianders@chromium.org> X-Gm-Message-State: ALoCoQluR2MfRDyvpwKqyCHgD2iqwLHOVYsCpYafR5Eon/2GryHgZYfmPY2K7LcEl1lqVcbBWoSlnMarqYK5j/rZWpPg9Dk9yF5EcjuTTvdTZlAEWTVzyaTSz6vLQNBtdiepcs0O0YvJjs3LXT2f6msyaP1zcbAPSXguw5p4Ddxy8znZPxmb34skbhjHMdOdHmpXcs97yEViFghBHh1difuK2JiRgxQz6g== Cc: Simon Glass , Jeremy Kerr , Mauro Carvalho Chehab X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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: