summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavid decotigny <david.decotigny@google.com>2011-11-22 09:12:48 +0000
committerJeremy Kerr <jk@ozlabs.org>2011-11-25 18:11:24 +0800
commitfa999187bfc23bc0d674875c554c360601f8f6b4 (patch)
tree897221eeb02b1f9d807223a3715c365c2bbc7c9e
parentf6e0464d987dc00fa5e9e31972c98196be4fb6b9 (diff)
downloadpatchwork-fa999187bfc23bc0d674875c554c360601f8f6b4.tar.bz2
patchwork-fa999187bfc23bc0d674875c554c360601f8f6b4.tar.xz
patchwork: new pwclient git-am action
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 <david.decotigny@google.com>
-rwxr-xr-xapps/patchwork/bin/pwclient23
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 <action> is one of:\n")
sys.stderr.write(
""" apply <ID> : Apply a patch (in the current dir, using -p1)
+ git-am <ID> : Apply a patch to current git branch using "git am"
get <ID> : 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])