~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to patches.py

Move selection code into HunkSelector class

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#    You should have received a copy of the GNU General Public License
15
15
#    along with this program; if not, write to the Free Software
16
16
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
import sys
 
17
 
18
18
class PatchSyntax(Exception):
19
19
    def __init__(self, msg):
20
20
        Exception.__init__(self, msg)
226
226
        self.newname = newname
227
227
        self.hunks = []
228
228
 
 
229
    def get_header(self):
 
230
        return "--- %s\n+++ %s\n" % (self.oldname, self.newname)
 
231
 
229
232
    def __str__(self):
230
 
        ret =  "--- %s\n+++ %s\n" % (self.oldname, self.newname) 
 
233
        ret =  self.get_header()
231
234
        ret += "".join([str(h) for h in self.hunks])
232
235
        return ret
233
236
 
275
278
        patch.hunks.append(hunk)
276
279
    return patch
277
280
 
278
 
def parse_patches(iter_lines):
 
281
def parse_patches(lines):
279
282
    def parse(lines):
280
283
        if len(lines) > 0:
281
284
            return [ parse_patch(lines.__iter__()) ]
282
285
        else:
283
286
            return []
284
287
 
 
288
    iter_lines = lines.__iter__()
285
289
    patches = []
286
290
    saved_lines = []
287
291
    while True: