1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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):
|