mercurial/templatefilters.py
changeset 49292 d44e3c45f0e4
parent 49086 51aed118f9dc
child 49505 c96ed4029fda
equal deleted inserted replaced
49291:44b26349127b 49292:d44e3c45f0e4
   138             a = b[: len(a)]
   138             a = b[: len(a)]
   139         elif len(b) > len(a):
   139         elif len(b) > len(a):
   140             b = b[: len(a)]
   140             b = b[: len(a)]
   141         if a == b:
   141         if a == b:
   142             return a
   142             return a
   143         for i in pycompat.xrange(len(a)):
   143         for i in range(len(a)):
   144             if a[i] != b[i]:
   144             if a[i] != b[i]:
   145                 return a[:i]
   145                 return a[:i]
   146         return a
   146         return a
   147 
   147 
   148     try:
   148     try:
   309     lines = text.splitlines()
   309     lines = text.splitlines()
   310     num_lines = len(lines)
   310     num_lines = len(lines)
   311     endswithnewline = text[-1:] == b'\n'
   311     endswithnewline = text[-1:] == b'\n'
   312 
   312 
   313     def indenter():
   313     def indenter():
   314         for i in pycompat.xrange(num_lines):
   314         for i in range(num_lines):
   315             l = lines[i]
   315             l = lines[i]
   316             if l.strip():
   316             if l.strip():
   317                 yield prefix if i else firstline
   317                 yield prefix if i else firstline
   318             yield l
   318             yield l
   319             if i < num_lines - 1 or endswithnewline:
   319             if i < num_lines - 1 or endswithnewline: