comparison mercurial/dagop.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 b33b91ca2ec2
children 1c3184d7e882
comparison
equal deleted inserted replaced
38782:7eba8f83129b 38783:e7aa113b14f7
193 193
194 def _builddescendantsmap(repo, startrev, followfirst): 194 def _builddescendantsmap(repo, startrev, followfirst):
195 """Build map of 'rev -> child revs', offset from startrev""" 195 """Build map of 'rev -> child revs', offset from startrev"""
196 cl = repo.changelog 196 cl = repo.changelog
197 nullrev = node.nullrev 197 nullrev = node.nullrev
198 descmap = [[] for _rev in xrange(startrev, len(cl))] 198 descmap = [[] for _rev in pycompat.xrange(startrev, len(cl))]
199 for currev in cl.revs(startrev + 1): 199 for currev in cl.revs(startrev + 1):
200 p1rev, p2rev = cl.parentrevs(currev) 200 p1rev, p2rev = cl.parentrevs(currev)
201 if p1rev >= startrev: 201 if p1rev >= startrev:
202 descmap[p1rev - startrev].append(currev) 202 descmap[p1rev - startrev].append(currev)
203 if not followfirst and p2rev != nullrev and p2rev >= startrev: 203 if not followfirst and p2rev != nullrev and p2rev >= startrev:
433 # First, replace as much as possible without repeating the last line. 433 # First, replace as much as possible without repeating the last line.
434 remaining = [(parent, []) for parent, _blocks in pblocks] 434 remaining = [(parent, []) for parent, _blocks in pblocks]
435 for idx, (parent, blocks) in enumerate(pblocks): 435 for idx, (parent, blocks) in enumerate(pblocks):
436 for (a1, a2, b1, b2), _t in blocks: 436 for (a1, a2, b1, b2), _t in blocks:
437 if a2 - a1 >= b2 - b1: 437 if a2 - a1 >= b2 - b1:
438 for bk in xrange(b1, b2): 438 for bk in pycompat.xrange(b1, b2):
439 if child.fctxs[bk] == childfctx: 439 if child.fctxs[bk] == childfctx:
440 ak = min(a1 + (bk - b1), a2 - 1) 440 ak = min(a1 + (bk - b1), a2 - 1)
441 child.fctxs[bk] = parent.fctxs[ak] 441 child.fctxs[bk] = parent.fctxs[ak]
442 child.linenos[bk] = parent.linenos[ak] 442 child.linenos[bk] = parent.linenos[ak]
443 child.skips[bk] = True 443 child.skips[bk] = True
446 446
447 # Then, look at anything left, which might involve repeating the last 447 # Then, look at anything left, which might involve repeating the last
448 # line. 448 # line.
449 for parent, blocks in remaining: 449 for parent, blocks in remaining:
450 for a1, a2, b1, b2 in blocks: 450 for a1, a2, b1, b2 in blocks:
451 for bk in xrange(b1, b2): 451 for bk in pycompat.xrange(b1, b2):
452 if child.fctxs[bk] == childfctx: 452 if child.fctxs[bk] == childfctx:
453 ak = min(a1 + (bk - b1), a2 - 1) 453 ak = min(a1 + (bk - b1), a2 - 1)
454 child.fctxs[bk] = parent.fctxs[ak] 454 child.fctxs[bk] = parent.fctxs[ak]
455 child.linenos[bk] = parent.linenos[ak] 455 child.linenos[bk] = parent.linenos[ak]
456 child.skips[bk] = True 456 child.skips[bk] = True