From patchwork Tue May 15 21:31:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Myers X-Patchwork-Id: 159794 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 F23F7B6FBD for ; Thu, 17 May 2012 10:09:59 +1000 (EST) X-Greylist: delayed 559 seconds by postgrey-1.34 at bilbo; Wed, 16 May 2012 07:36:02 EST Received: from relay.sgi.com (relay1.sgi.com [192.48.179.29]) by ozlabs.org (Postfix) with ESMTP id CA1F6B6FBC for ; Wed, 16 May 2012 07:36:02 +1000 (EST) Received: from whiskey.americas.sgi.com (whiskey.americas.sgi.com [128.162.233.19]) by relay1.corp.sgi.com (Postfix) with ESMTP id 21C4A8F8070; Tue, 15 May 2012 14:26:40 -0700 (PDT) Received: by whiskey.americas.sgi.com (Postfix, from userid 4600) id 6A23D402073; Tue, 15 May 2012 16:31:09 -0500 (CDT) Date: Tue, 15 May 2012 16:31:09 -0500 From: Ben Myers To: Jeremy Kerr Subject: Re: search by messageid? Message-ID: <20120515213109.GC3963@sgi.com> References: <20120511194751.GD16099@sgi.com> <4FAD949F.409@ozlabs.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4FAD949F.409@ozlabs.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Thu, 17 May 2012 10:09:55 +1000 Cc: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Hey Jeremy, On Fri, May 11, 2012 at 03:37:19PM -0700, Jeremy Kerr wrote: > > Is it possible to find patches by messageid via the xmlrpc interface? I'm a > > mutt user and would like to be able to find the patch id given a message id in > > one of my hooks. > > > You could call patch_list() with a filter of {'msgid': some_message_id} > - this should return a (possibly empty) list of patches. Would that work > for you? Thanks for the help! I'm new to python so this maybe a little wonky but it seems to work for me: Regards, Ben ------------------- pwclient: add the Message-id to patches Add the Message-id to patches so that it is easy to reply to the patch on-list at a later date. Signed-off-by: Ben Myers Index: root/pwclient =================================================================== --- root.orig/pwclient +++ root/pwclient @@ -235,6 +235,7 @@ def action_get(rpc, patch_id): sys.exit(1) try: + f.write("Message-ID: %s\n" % patch['msgid']); f.write(s) f.close() print "Saved patch to %s" % fname ------------------ pwclient: lookup patch_id given Message-id Add a pwclient search option '-m' to look up a patch id given a Message-id. This is useful for automation and mailer hooks. Signed-off-by: Ben Myers Index: root/pwclient =================================================================== --- root.orig/pwclient +++ root/pwclient @@ -119,7 +119,8 @@ def usage(): -p : Filter by project name (see 'projects' for list) -w : Filter by submitter (name, e-mail substring search) -d : Filter by delegate (name, e-mail substring search) - -n : Restrict number of results\n""") + -n : Restrict number of results + -m : Filter by Message-id\n""") sys.stderr.write("""\nActions that take an ID argument can also be \ invoked with: -h : Lookup by patch hash\n""") @@ -294,11 +295,19 @@ def patch_id_from_hash(rpc, hash): return patch['id'] +def patch_id_from_msgid(rpc, msgid_str): + f = Filter(); + f.add("msgid", msgid_str) + patches = rpc.patch_list(f.d) + for patch in patches: + sys.stdout.write("%s\n" % patch['id']) + return patches + auth_actions = ['update'] def main(): try: - opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:') + opts, args = getopt.getopt(sys.argv[2:], 's:p:w:d:n:c:h:m:') except getopt.GetoptError, err: print str(err) usage() @@ -316,6 +325,7 @@ def main(): commit_str = "" state_str = "" hash_str = "" + msgid_str = "" url = DEFAULT_URL config = ConfigParser.ConfigParser() @@ -341,6 +351,8 @@ def main(): commit_str = value elif name == '-h': hash_str = value + elif name == '-m': + msgid_str = value elif name == '-n': try: filt.add("max_count", int(value)) @@ -389,6 +401,11 @@ def main(): sys.stderr.write("No patch has the hash provided") sys.exit(1) + if msgid_str: + patches = patch_id_from_msgid(rpc, msgid_str) + if not patches: + sys.exit(1) + return if action == 'list' or action == 'search': if len(args) > 0: