# HG changeset patch # User Augie Fackler # Date 1410375170 14400 # Node ID 4e83916a43039c48c3c8fca6d0fd57c2745b23d3 # Parent 70e76c545606c50231160b90da8b4023d5731b91 patchpipe: tool to edit hg patches while piping them to 'hg import' diff --git a/unixSoft/bin/patchpipe b/unixSoft/bin/patchpipe new file mode 100755 --- /dev/null +++ b/unixSoft/bin/patchpipe @@ -0,0 +1,24 @@ +#!/usr/bin/env python +import os +import subprocess +import sys +import tempfile + +_PATCHHDR = '# HG changeset patch' + + +def main(argv): + tf = tempfile.NamedTemporaryFile(suffix='.diff') + d = sys.stdin.read() + if _PATCHHDR in d: + junk, d = d.split(_PATCHHDR, 1) + d = _PATCHHDR + d + tf.write(d) + tf.flush() + subprocess.check_call([os.environ['EDITOR'], tf.name], + stdout=sys.stderr) + sys.stdout.write(open(tf.name).read()) + + +if __name__ == '__main__': + main(argv=sys.argv)