summaryrefslogtreecommitdiff
path: root/lib/splitpatch.py
blob: 09e5814d4f69b8bf641ac13941f41a72198c43f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import patch, sys

ps = patch.fromfile(sys.argv[1])
f = open('INFO', 'w')
f.write(''.join(ps.items[0].header))
f.close()

for p in ps.items:
    s = p.source[2:].replace('/', '_')
    f = open(s, 'w')
    f.write('--- %s\n' % p.source)
    f.write('+++ %s\n' % p.target)
    for h in p.hunks:
        f.write('@@ -%d,%d +%d,%d @@\n' % (
          h.startsrc, h.linessrc,
          h.starttgt, h.linestgt))
        f.write(''.join(h.text))
    f.close()