4 # Copyright © 2009 Germán Póo-Caamaño <gpoo@gnome.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Library General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 from patterns
import patterns
23 class LogPatchSplitter
:
25 LogPatchSplitters provides a iterator to extract every
26 changeset from a git log output.
30 patches = LogPatchSplitter(sys.stdin)
36 def __init__(self
, fd
):
45 patch
= self
.__grab
_patch
__()
50 def __grab_patch__(self
):
52 Extract a patch from the file descriptor and the
53 patch is returned as a list of lines.
57 line
= self
.buffer or self
.fd
.readline()
60 if line
.startswith('commit '):
63 line
= self
.fd
.readline()
68 line
= self
.fd
.readline()
70 # If this line starts a new commit, drop out.
71 if line
.startswith ('commit '):
77 line
= self
.fd
.readline()
82 if __name__
== '__main__':
83 patches
= LogPatchSplitter(sys
.stdin
)
86 print('---------- NEW PATCH ----------')