Mercurial > dotfiles
comparison unixSoft/bin/apply-patchbomb @ 185:b5d71972aa72
apply-patchbomb: script to apply patchbomb from selected messages in Mail.app.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 30 Jan 2010 12:21:00 -0600 |
parents | |
children | e8170eba88cd |
comparison
equal
deleted
inserted
replaced
184:efa2bfc73d2d | 185:b5d71972aa72 |
---|---|
1 #!/usr/bin/python | |
2 # shebang for system python explicitly so we're sure to have pyobjc and | |
3 # the scripting bridge. | |
4 """apply-patchbomb: apply selected messages in Mail.app to an hg repo in pwd. | |
5 | |
6 This uses the scripting bridge to talk to Mail and subprocess to pass the | |
7 patch to Mercurial on stdin. | |
8 """ | |
9 | |
10 | |
11 import ScriptingBridge | |
12 import subprocess | |
13 | |
14 def main(): | |
15 mail = ScriptingBridge.SBApplication.applicationWithBundleIdentifier_( | |
16 'com.apple.Mail') | |
17 messages = list(sorted(mail.selection(), | |
18 cmp=lambda x,y: cmp(x.subject(), y.subject()))) | |
19 for m in messages: | |
20 print 'Applying', m.subject() | |
21 p = subprocess.Popen(['hg', 'import', '-'], stdin=subprocess.PIPE) | |
22 p.stdin.write(m.source()) | |
23 p.stdin.close() | |
24 if p.wait() != 0: | |
25 print 'hg import failed, bailing' | |
26 break | |
27 | |
28 if __name__ == '__main__': | |
29 main() |