mercurial/context.py
changeset 29223 c04ad3d3c651
parent 29021 92d37fb3f1aa
child 29527 576ff900fcc7
equal deleted inserted replaced
29222:ed4bd789fc55 29223:c04ad3d3c651
   928         in the managed file.
   928         in the managed file.
   929         To reduce annotation cost,
   929         To reduce annotation cost,
   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,
   946                                      refine=True)
   950                                      refine=True)
   947             for (a1, a2, b1, b2), t in blocks:
   951             for (a1, a2, b1, b2), t in blocks: