Show More
@@ -240,14 +240,32 b' class filectx(object):' | |||
|
240 | 240 | return [filectx(self._repo, self._path, fileid=x, |
|
241 | 241 | filelog=self._filelog) for x in c] |
|
242 | 242 | |
|
243 | def annotate(self, follow=False): | |
|
243 | def annotate(self, follow=False, linenumber=None): | |
|
244 | 244 | '''returns a list of tuples of (ctx, line) for each line |
|
245 | 245 | in the file, where ctx is the filectx of the node where |
|
246 |
that line was last changed |
|
|
246 | that line was last changed. | |
|
247 | This returns tuples of ((ctx, linenumber), line) for each line, | |
|
248 | if "linenumber" parameter is NOT "None". | |
|
249 | In such tuples, linenumber means one at the first appearance | |
|
250 | in the managed file. | |
|
251 | To reduce annotation cost, | |
|
252 | this returns fixed value(False is used) as linenumber, | |
|
253 | if "linenumber" parameter is "False".''' | |
|
247 | 254 | |
|
248 | def decorate(text, rev): | |
|
255 | def decorate_compat(text, rev): | |
|
249 | 256 | return ([rev] * len(text.splitlines()), text) |
|
250 | 257 | |
|
258 | def without_linenumber(text, rev): | |
|
259 | return ([(rev, False)] * len(text.splitlines()), text) | |
|
260 | ||
|
261 | def with_linenumber(text, rev): | |
|
262 | size = len(text.splitlines()) | |
|
263 | return ([(rev, i) for i in xrange(1, size + 1)], text) | |
|
264 | ||
|
265 | decorate = (((linenumber is None) and decorate_compat) or | |
|
266 | (linenumber and with_linenumber) or | |
|
267 | without_linenumber) | |
|
268 | ||
|
251 | 269 | def pair(parent, child): |
|
252 | 270 | for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): |
|
253 | 271 | child[0][b1:b2] = parent[0][a1:a2] |
General Comments 0
You need to be logged in to leave comments.
Login now