##// END OF EJS Templates
Allow filectx.annotate to return the line number of first appearance.
FUJIWARA Katsunori -
r4856:e45c5120 default
parent child Browse files
Show More
@@ -240,14 +240,32 b' class filectx(object):'
240 return [filectx(self._repo, self._path, fileid=x,
240 return [filectx(self._repo, self._path, fileid=x,
241 filelog=self._filelog) for x in c]
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 '''returns a list of tuples of (ctx, line) for each line
244 '''returns a list of tuples of (ctx, line) for each line
245 in the file, where ctx is the filectx of the node where
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 return ([rev] * len(text.splitlines()), text)
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 def pair(parent, child):
269 def pair(parent, child):
252 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]):
270 for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]):
253 child[0][b1:b2] = parent[0][a1:a2]
271 child[0][b1:b2] = parent[0][a1:a2]
General Comments 0
You need to be logged in to leave comments. Login now