comparison mercurial/dagop.py @ 49284:d44e3c45f0e4

py3: replace `pycompat.xrange` by `range`
author Manuel Jacob <me@manueljacob.de>
date Sun, 29 May 2022 15:17:27 +0200
parents 642e31cb55f0
children a0d88b021a98
comparison
equal deleted inserted replaced
49283:44b26349127b 49284:d44e3c45f0e4
201 201
202 202
203 def _builddescendantsmap(repo, startrev, followfirst): 203 def _builddescendantsmap(repo, startrev, followfirst):
204 """Build map of 'rev -> child revs', offset from startrev""" 204 """Build map of 'rev -> child revs', offset from startrev"""
205 cl = repo.changelog 205 cl = repo.changelog
206 descmap = [[] for _rev in pycompat.xrange(startrev, len(cl))] 206 descmap = [[] for _rev in range(startrev, len(cl))]
207 for currev in cl.revs(startrev + 1): 207 for currev in cl.revs(startrev + 1):
208 p1rev, p2rev = cl.parentrevs(currev) 208 p1rev, p2rev = cl.parentrevs(currev)
209 if p1rev >= startrev: 209 if p1rev >= startrev:
210 descmap[p1rev - startrev].append(currev) 210 descmap[p1rev - startrev].append(currev)
211 if not followfirst and p2rev != nullrev and p2rev >= startrev: 211 if not followfirst and p2rev != nullrev and p2rev >= startrev:
723 # First, replace as much as possible without repeating the last line. 723 # First, replace as much as possible without repeating the last line.
724 remaining = [(parent, []) for parent, _blocks in pblocks] 724 remaining = [(parent, []) for parent, _blocks in pblocks]
725 for idx, (parent, blocks) in enumerate(pblocks): 725 for idx, (parent, blocks) in enumerate(pblocks):
726 for (a1, a2, b1, b2), _t in blocks: 726 for (a1, a2, b1, b2), _t in blocks:
727 if a2 - a1 >= b2 - b1: 727 if a2 - a1 >= b2 - b1:
728 for bk in pycompat.xrange(b1, b2): 728 for bk in range(b1, b2):
729 if child.fctxs[bk] == childfctx: 729 if child.fctxs[bk] == childfctx:
730 ak = min(a1 + (bk - b1), a2 - 1) 730 ak = min(a1 + (bk - b1), a2 - 1)
731 child.fctxs[bk] = parent.fctxs[ak] 731 child.fctxs[bk] = parent.fctxs[ak]
732 child.linenos[bk] = parent.linenos[ak] 732 child.linenos[bk] = parent.linenos[ak]
733 child.skips[bk] = True 733 child.skips[bk] = True
736 736
737 # Then, look at anything left, which might involve repeating the last 737 # Then, look at anything left, which might involve repeating the last
738 # line. 738 # line.
739 for parent, blocks in remaining: 739 for parent, blocks in remaining:
740 for a1, a2, b1, b2 in blocks: 740 for a1, a2, b1, b2 in blocks:
741 for bk in pycompat.xrange(b1, b2): 741 for bk in range(b1, b2):
742 if child.fctxs[bk] == childfctx: 742 if child.fctxs[bk] == childfctx:
743 ak = min(a1 + (bk - b1), a2 - 1) 743 ak = min(a1 + (bk - b1), a2 - 1)
744 child.fctxs[bk] = parent.fctxs[ak] 744 child.fctxs[bk] = parent.fctxs[ak]
745 child.linenos[bk] = parent.linenos[ak] 745 child.linenos[bk] = parent.linenos[ak]
746 child.skips[bk] = True 746 child.skips[bk] = True