Show More
@@ -369,6 +369,11 b' class annotateline(object):' | |||
|
369 | 369 | # Whether this annotation was the result of a skip-annotate. |
|
370 | 370 | skip = attr.ib(default=False) |
|
371 | 371 | |
|
372 | def _countlines(text): | |
|
373 | if text.endswith("\n"): | |
|
374 | return text.count("\n") | |
|
375 | return text.count("\n") + int(bool(text)) | |
|
376 | ||
|
372 | 377 | def _annotatepair(parents, childfctx, child, skipchild, diffopts): |
|
373 | 378 | r''' |
|
374 | 379 | Given parent and child fctxes and annotate data for parents, for all lines |
@@ -436,18 +441,13 b' def annotate(base, parents, linenumber=F' | |||
|
436 | 441 | `parents(fctx)` is a function returning a list of parent filectxs. |
|
437 | 442 | """ |
|
438 | 443 | |
|
439 | def lines(text): | |
|
440 | if text.endswith("\n"): | |
|
441 | return text.count("\n") | |
|
442 | return text.count("\n") + int(bool(text)) | |
|
443 | ||
|
444 | 444 | if linenumber: |
|
445 | 445 | def decorate(text, rev): |
|
446 | 446 | return ([annotateline(fctx=rev, lineno=i) |
|
447 | for i in xrange(1, lines(text) + 1)], text) | |
|
447 | for i in xrange(1, _countlines(text) + 1)], text) | |
|
448 | 448 | else: |
|
449 | 449 | def decorate(text, rev): |
|
450 | return ([annotateline(fctx=rev)] * lines(text), text) | |
|
450 | return ([annotateline(fctx=rev)] * _countlines(text), text) | |
|
451 | 451 | |
|
452 | 452 | # This algorithm would prefer to be recursive, but Python is a |
|
453 | 453 | # bit recursion-hostile. Instead we do an iterative |
General Comments 0
You need to be logged in to leave comments.
Login now