##// END OF EJS Templates
mdiff: speed up showfunc for large diffs...
Brodie Rao -
r15141:16dc9a32 default
parent child Browse files
Show More
@@ -157,6 +157,7 def _unidiff(t1, t2, l1, l2, opts=defaul
157 157 return 0
158 158 return ret
159 159
160 lastfunc = [0, '']
160 161 def yieldhunk(hunk):
161 162 (astart, a2, bstart, b2, delta) = hunk
162 163 aend = contextend(a2, len(l1))
@@ -165,13 +166,19 def _unidiff(t1, t2, l1, l2, opts=defaul
165 166
166 167 func = ""
167 168 if opts.showfunc:
168 # walk backwards from the start of the context
169 # to find a line starting with an alphanumeric char.
170 for x in xrange(astart - 1, -1, -1):
171 t = l1[x].rstrip()
172 if funcre.match(t):
173 func = ' ' + t[:40]
169 lastpos, func = lastfunc
170 # walk backwards from the start of the context up to the start of
171 # the previous hunk context until we find a line starting with an
172 # alphanumeric char.
173 for i in xrange(astart - 1, lastpos - 1, -1):
174 if l1[i][0].isalnum():
175 func = ' ' + l1[i].rstrip()[:40]
176 lastfunc[1] = func
174 177 break
178 # by recording this hunk's starting point as the next place to
179 # start looking for function lines, we avoid reading any line in
180 # the file more than once.
181 lastfunc[0] = astart
175 182
176 183 yield "@@ -%d,%d +%d,%d @@%s\n" % (astart + 1, alen,
177 184 bstart + 1, blen, func)
@@ -180,9 +187,6 def _unidiff(t1, t2, l1, l2, opts=defaul
180 187 for x in xrange(a2, aend):
181 188 yield ' ' + l1[x]
182 189
183 if opts.showfunc:
184 funcre = re.compile('\w')
185
186 190 # bdiff.blocks gives us the matching sequences in the files. The loop
187 191 # below finds the spaces between those matching sequences and translates
188 192 # them into diff output.
General Comments 0
You need to be logged in to leave comments. Login now