Mercurial > dotfiles
comparison unixSoft/bin/patchpipe @ 344:4e83916a4303
patchpipe: tool to edit hg patches while piping them to 'hg import'
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Wed, 10 Sep 2014 14:52:50 -0400 |
| parents | |
| children | c7a9cd793e37 |
comparison
equal
deleted
inserted
replaced
| 343:70e76c545606 | 344:4e83916a4303 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 import os | |
| 3 import subprocess | |
| 4 import sys | |
| 5 import tempfile | |
| 6 | |
| 7 _PATCHHDR = '# HG changeset patch' | |
| 8 | |
| 9 | |
| 10 def main(argv): | |
| 11 tf = tempfile.NamedTemporaryFile(suffix='.diff') | |
| 12 d = sys.stdin.read() | |
| 13 if _PATCHHDR in d: | |
| 14 junk, d = d.split(_PATCHHDR, 1) | |
| 15 d = _PATCHHDR + d | |
| 16 tf.write(d) | |
| 17 tf.flush() | |
| 18 subprocess.check_call([os.environ['EDITOR'], tf.name], | |
| 19 stdout=sys.stderr) | |
| 20 sys.stdout.write(open(tf.name).read()) | |
| 21 | |
| 22 | |
| 23 if __name__ == '__main__': | |
| 24 main(argv=sys.argv) |
