Index: patch.py =================================================================== --- patch.py (revision 203) +++ patch.py (working copy) @@ -166,17 +166,27 @@ self.desc='' self.text=[] -# def apply(self, estream): -# """ write hunk data into enumerable stream -# return strings one by one until hunk is -# over -# -# enumerable stream are tuples (lineno, line) -# where lineno starts with 0 -# """ -# pass + def apply(self, estream): + """ write hunk data into enumerable stream + return strings one by one until hunk is + over + enumerable stream are tuples (lineno, line) + where lineno starts with 0 + """ + if type(estream) is not type([]): + return estream + header = "@@ -{0},{1} +{2},{3} @@{4}".format(self.startsrc, self.linessrc, + self.starttgt, self.linestgt, + self.desc) + estream.append((0, header + '\n')) + estream.extend(enumerate(self.text, 1)) + return estream + def __str__(self): + return ''.join([line for _, line in self.apply([])]) + + class Patch(object): """ Patch for a single file """ def __init__(self):