From patchwork Tue Nov 22 19:12:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: david decotigny X-Patchwork-Id: 127647 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 F208F1007FA for ; Fri, 25 Nov 2011 20:23:59 +1100 (EST) Received: from mail-vx0-f201.google.com (mail-vx0-f201.google.com [209.85.220.201]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id C174E1007D2 for ; Wed, 23 Nov 2011 06:13:12 +1100 (EST) Received: by vcbfy13 with SMTP id fy13so108917vcb.2 for ; Tue, 22 Nov 2011 11:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=from:to:cc:subject:date:message-id:x-mailer:organization :x-system-of-record; bh=zRYC6QstgPhT2pv5Prd+6rPtNwmSarkxGyiRhUaON0M=; b=mOzzTgYzQgEH/og6wOmD3IkjsRC5APgFoBz0IYuvXIlNmnxdDxJ8fPhWuTuOcCS5dJ M6Cm9zPho7U6sZigIihA== Received: by 10.236.170.198 with SMTP id p46mr35416256yhl.8.1321989185885; Tue, 22 Nov 2011 11:13:05 -0800 (PST) Received: by 10.236.170.198 with SMTP id p46mr35415962yhl.8.1321989183624; Tue, 22 Nov 2011 11:13:03 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id y7si4984135yha.4.2011.11.22.11.13.03 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 22 Nov 2011 11:13:03 -0800 (PST) Received: from wpaz1.hot.corp.google.com (wpaz1.hot.corp.google.com [172.24.198.65]) by wpzn3.hot.corp.google.com (Postfix) with ESMTPS id 101A210004D for ; Tue, 22 Nov 2011 11:13:03 -0800 (PST) Received: from decotigny.mtv.corp.google.com (decotigny.mtv.corp.google.com [172.18.64.159]) by wpaz1.hot.corp.google.com with ESMTP id pAMJD1Nc025943; Tue, 22 Nov 2011 11:13:01 -0800 Received: by decotigny.mtv.corp.google.com (Postfix, from userid 128857) id 083CE21A15; Tue, 22 Nov 2011 11:13:00 -0800 (PST) From: David Decotigny To: patchwork@lists.ozlabs.org Subject: [PATCH] patchwork: new pwclient git-am action Date: Tue, 22 Nov 2011 11:12:48 -0800 Message-Id: X-Mailer: git-send-email 1.7.3.1 Organization: Google, Inc. X-System-Of-Record: true X-Mailman-Approved-At: Fri, 25 Nov 2011 20:23:59 +1100 Cc: David Decotigny 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: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org This commit adds a new "pwclient git-am" action which applies given patch ID on the current git branch using "git am". It's convenient to keep track and authorship of patches applied locally from a patchwork server. Signed-off-by: David Decotigny --- apps/patchwork/bin/pwclient | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient index 9d8cad9..4c47b11 100755 --- a/apps/patchwork/bin/pwclient +++ b/apps/patchwork/bin/pwclient @@ -111,6 +111,7 @@ def usage(): sys.stderr.write("Where is one of:\n") sys.stderr.write( """ apply : Apply a patch (in the current dir, using -p1) + git-am : Apply a patch to current git branch using "git am" get : Download a patch and save it locally projects : List all projects states : Show list of potential patch states @@ -250,17 +251,24 @@ def action_get(rpc, patch_id): sys.stderr.write("Failed to write to %s\n" % fname) sys.exit(1) -def action_apply(rpc, patch_id): +def action_apply(rpc, patch_id, apply_cmd=None): patch = rpc.patch_get(patch_id) if patch == {}: sys.stderr.write("Error getting information on patch ID %d\n" % \ patch_id) sys.exit(1) - print "Applying patch #%d to current directory" % patch_id + + if apply_cmd is None: + print "Applying patch #%d to current directory" % patch_id + apply_cmd = ['patch', '-p1'] + else: + print "Applying patch #%d using %s" % ( + patch_id, repr(' '.join(apply_cmd))) + print "Description: %s" % patch['name'] s = rpc.patch_get_mbox(patch_id) if len(s) > 0: - proc = subprocess.Popen(['patch', '-p1'], stdin = subprocess.PIPE) + proc = subprocess.Popen(apply_cmd, stdin = subprocess.PIPE) proc.communicate(s) else: sys.stderr.write("Error: No patch content found\n") @@ -446,6 +454,15 @@ def main(): action_apply(rpc, patch_id) + elif action == 'git-am': + try: + patch_id = patch_id or int(args[0]) + except: + sys.stderr.write("Invalid patch ID given\n") + sys.exit(1) + + action_apply(rpc, patch_id, ['git', 'am']) + elif action == 'update': try: patch_id = patch_id or int(args[0])