6 _boundary_line_regex
= re
.compile(r
'^---')
7 _diff_head_regex
= re
.compile(r
'^diff --git ')
8 _index_line_regex
= re
.compile(r
'^index ([a-f0-9]{7,})\.\.([a-f0-9]{7,}) ')
10 class PatchError(Exception):
15 def __init__(self
, data
):
16 self
.blobs_pre
= set()
17 self
.blobs_post
= set()
22 def _parse(self
, data
):
26 for line
in data
.splitlines(True):
28 m
= _index_line_regex
.match(line
)
30 self
.blobs_pre
.add(m
.group(1))
31 self
.blobs_post
.add(m
.group(2))
33 if _diff_head_regex
.match(line
):
38 if _boundary_line_regex
.match(line
):
42 self
.notes
= ''.join(notes
)
45 print 'trying to apply patch-%x' % id(self
)
46 output
, ret
= git('am', input=self
.data
)
50 git('reset', '--hard')