Mercurial > hg
comparison mercurial/diffhelper.py @ 38783:e7aa113b14f7
global: use pycompat.xrange()
On Python 3, our module importer automatically rewrites xrange()
to pycompat.xrange().
We want to move away from the custom importer on Python 3.
This commit converts all instances of xrange() to use
pycompat.xrange().
Differential Revision: https://phab.mercurial-scm.org/D4032
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 01 Aug 2018 13:00:45 -0700 |
parents | 86e7a57449fa |
children | 57875cf423c9 |
comparison
equal
deleted
inserted
replaced
38782:7eba8f83129b | 38783:e7aa113b14f7 |
---|---|
9 | 9 |
10 from .i18n import _ | 10 from .i18n import _ |
11 | 11 |
12 from . import ( | 12 from . import ( |
13 error, | 13 error, |
14 pycompat, | |
14 ) | 15 ) |
15 | 16 |
16 def addlines(fp, hunk, lena, lenb, a, b): | 17 def addlines(fp, hunk, lena, lenb, a, b): |
17 """Read lines from fp into the hunk | 18 """Read lines from fp into the hunk |
18 | 19 |
24 todoa = lena - len(a) | 25 todoa = lena - len(a) |
25 todob = lenb - len(b) | 26 todob = lenb - len(b) |
26 num = max(todoa, todob) | 27 num = max(todoa, todob) |
27 if num == 0: | 28 if num == 0: |
28 break | 29 break |
29 for i in xrange(num): | 30 for i in pycompat.xrange(num): |
30 s = fp.readline() | 31 s = fp.readline() |
31 if not s: | 32 if not s: |
32 raise error.ParseError(_('incomplete hunk')) | 33 raise error.ParseError(_('incomplete hunk')) |
33 if s == "\\ No newline at end of file\n": | 34 if s == "\\ No newline at end of file\n": |
34 fixnewline(hunk, a, b) | 35 fixnewline(hunk, a, b) |
69 """ | 70 """ |
70 alen = len(a) | 71 alen = len(a) |
71 blen = len(b) | 72 blen = len(b) |
72 if alen > blen - bstart or bstart < 0: | 73 if alen > blen - bstart or bstart < 0: |
73 return False | 74 return False |
74 for i in xrange(alen): | 75 for i in pycompat.xrange(alen): |
75 if a[i][1:] != b[i + bstart]: | 76 if a[i][1:] != b[i + bstart]: |
76 return False | 77 return False |
77 return True | 78 return True |