##// 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 b' def _unidiff(t1, t2, l1, l2, opts=defaul'
157 return 0
157 return 0
158 return ret
158 return ret
159
159
160 lastfunc = [0, '']
160 def yieldhunk(hunk):
161 def yieldhunk(hunk):
161 (astart, a2, bstart, b2, delta) = hunk
162 (astart, a2, bstart, b2, delta) = hunk
162 aend = contextend(a2, len(l1))
163 aend = contextend(a2, len(l1))
@@ -165,13 +166,19 b' def _unidiff(t1, t2, l1, l2, opts=defaul'
165
166
166 func = ""
167 func = ""
167 if opts.showfunc:
168 if opts.showfunc:
168 # walk backwards from the start of the context
169 lastpos, func = lastfunc
169 # to find a line starting with an alphanumeric char.
170 # walk backwards from the start of the context up to the start of
170 for x in xrange(astart - 1, -1, -1):
171 # the previous hunk context until we find a line starting with an
171 t = l1[x].rstrip()
172 # alphanumeric char.
172 if funcre.match(t):
173 for i in xrange(astart - 1, lastpos - 1, -1):
173 func = ' ' + t[:40]
174 if l1[i][0].isalnum():
175 func = ' ' + l1[i].rstrip()[:40]
176 lastfunc[1] = func
174 break
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 yield "@@ -%d,%d +%d,%d @@%s\n" % (astart + 1, alen,
183 yield "@@ -%d,%d +%d,%d @@%s\n" % (astart + 1, alen,
177 bstart + 1, blen, func)
184 bstart + 1, blen, func)
@@ -180,9 +187,6 b' def _unidiff(t1, t2, l1, l2, opts=defaul'
180 for x in xrange(a2, aend):
187 for x in xrange(a2, aend):
181 yield ' ' + l1[x]
188 yield ' ' + l1[x]
182
189
183 if opts.showfunc:
184 funcre = re.compile('\w')
185
186 # bdiff.blocks gives us the matching sequences in the files. The loop
190 # bdiff.blocks gives us the matching sequences in the files. The loop
187 # below finds the spaces between those matching sequences and translates
191 # below finds the spaces between those matching sequences and translates
188 # them into diff output.
192 # them into diff output.
General Comments 0
You need to be logged in to leave comments. Login now