##// END OF EJS Templates
annotate: optimize line counting...
Matt Mackall -
r29223:c04ad3d3 default
parent child Browse files
Show More
@@ -930,16 +930,20 b' class basefilectx(object):'
930 930 this returns fixed value(False is used) as linenumber,
931 931 if "linenumber" parameter is "False".'''
932 932
933 def lines(text):
934 if text.endswith("\n"):
935 return text.count("\n")
936 return text.count("\n") + 1
937
933 938 if linenumber is None:
934 939 def decorate(text, rev):
935 return ([rev] * len(text.splitlines()), text)
940 return ([rev] * lines(text), text)
936 941 elif linenumber:
937 942 def decorate(text, rev):
938 size = len(text.splitlines())
939 return ([(rev, i) for i in xrange(1, size + 1)], text)
943 return ([(rev, i) for i in xrange(1, lines(text) + 1)], text)
940 944 else:
941 945 def decorate(text, rev):
942 return ([(rev, False)] * len(text.splitlines()), text)
946 return ([(rev, False)] * lines(text), text)
943 947
944 948 def pair(parent, child):
945 949 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
General Comments 0
You need to be logged in to leave comments. Login now