Mercurial > dotfiles
annotate unixSoft/bin/patchpipe @ 354:3d46ce32c14e
which-function-mode: only enable in emacs 24.4 and later
Emacs 24.3.x has a bug in which-function-mode that causes my emacs to
lock up for several seconds. Rather than tolerate that, just disable
which-function-mode on those systems.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Tue, 18 Nov 2014 17:17:36 -0500 |
parents | 4e83916a4303 |
children | c7a9cd793e37 |
rev | line source |
---|---|
344
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2 import os |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
3 import subprocess |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
4 import sys |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
5 import tempfile |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
6 |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
7 _PATCHHDR = '# HG changeset patch' |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
8 |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
9 |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
10 def main(argv): |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
11 tf = tempfile.NamedTemporaryFile(suffix='.diff') |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
12 d = sys.stdin.read() |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
13 if _PATCHHDR in d: |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
14 junk, d = d.split(_PATCHHDR, 1) |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
15 d = _PATCHHDR + d |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
16 tf.write(d) |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
17 tf.flush() |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
18 subprocess.check_call([os.environ['EDITOR'], tf.name], |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
19 stdout=sys.stderr) |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
20 sys.stdout.write(open(tf.name).read()) |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
21 |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
22 |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
23 if __name__ == '__main__': |
4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
24 main(argv=sys.argv) |