##// 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 this returns fixed value(False is used) as linenumber,
930 this returns fixed value(False is used) as linenumber,
931 if "linenumber" parameter is "False".'''
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 if linenumber is None:
938 if linenumber is None:
934 def decorate(text, rev):
939 def decorate(text, rev):
935 return ([rev] * len(text.splitlines()), text)
940 return ([rev] * lines(text), text)
936 elif linenumber:
941 elif linenumber:
937 def decorate(text, rev):
942 def decorate(text, rev):
938 size = len(text.splitlines())
943 return ([(rev, i) for i in xrange(1, lines(text) + 1)], text)
939 return ([(rev, i) for i in xrange(1, size + 1)], text)
940 else:
944 else:
941 def decorate(text, rev):
945 def decorate(text, rev):
942 return ([(rev, False)] * len(text.splitlines()), text)
946 return ([(rev, False)] * lines(text), text)
943
947
944 def pair(parent, child):
948 def pair(parent, child):
945 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
949 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts,
General Comments 0
You need to be logged in to leave comments. Login now