253 if idx < len(data): |
253 if idx < len(data): |
254 r2, t2 = data[idx] |
254 r2, t2 = data[idx] |
255 merge_after = r2[0] == rev + 1 and t2 == t |
255 merge_after = r2[0] == rev + 1 and t2 == t |
256 |
256 |
257 if merge_before and merge_after: |
257 if merge_before and merge_after: |
258 data[idx - 1] = (pycompat.xrange(r1[0], r2[-1] + 1), t) |
258 data[idx - 1] = (range(r1[0], r2[-1] + 1), t) |
259 data.pop(idx) |
259 data.pop(idx) |
260 elif merge_before: |
260 elif merge_before: |
261 data[idx - 1] = (pycompat.xrange(r1[0], rev + 1), t) |
261 data[idx - 1] = (range(r1[0], rev + 1), t) |
262 elif merge_after: |
262 elif merge_after: |
263 data[idx] = (pycompat.xrange(rev, r2[-1] + 1), t) |
263 data[idx] = (range(rev, r2[-1] + 1), t) |
264 else: |
264 else: |
265 data.insert(idx, (pycompat.xrange(rev, rev + 1), t)) |
265 data.insert(idx, (range(rev, rev + 1), t)) |
266 |
266 |
267 |
267 |
268 def _sortedrange_split(data, idx, rev, t): |
268 def _sortedrange_split(data, idx, rev, t): |
269 r1, t1 = data[idx] |
269 r1, t1 = data[idx] |
270 if t == t1: |
270 if t == t1: |
272 t = (t1[0], t[1]) |
272 t = (t1[0], t[1]) |
273 if len(r1) == 1: |
273 if len(r1) == 1: |
274 data.pop(idx) |
274 data.pop(idx) |
275 _sortedrange_insert(data, idx, rev, t) |
275 _sortedrange_insert(data, idx, rev, t) |
276 elif r1[0] == rev: |
276 elif r1[0] == rev: |
277 data[idx] = (pycompat.xrange(rev + 1, r1[-1] + 1), t1) |
277 data[idx] = (range(rev + 1, r1[-1] + 1), t1) |
278 _sortedrange_insert(data, idx, rev, t) |
278 _sortedrange_insert(data, idx, rev, t) |
279 elif r1[-1] == rev: |
279 elif r1[-1] == rev: |
280 data[idx] = (pycompat.xrange(r1[0], rev), t1) |
280 data[idx] = (range(r1[0], rev), t1) |
281 _sortedrange_insert(data, idx + 1, rev, t) |
281 _sortedrange_insert(data, idx + 1, rev, t) |
282 else: |
282 else: |
283 data[idx : idx + 1] = [ |
283 data[idx : idx + 1] = [ |
284 (pycompat.xrange(r1[0], rev), t1), |
284 (range(r1[0], rev), t1), |
285 (pycompat.xrange(rev, rev + 1), t), |
285 (range(rev, rev + 1), t), |
286 (pycompat.xrange(rev + 1, r1[-1] + 1), t1), |
286 (range(rev + 1, r1[-1] + 1), t1), |
287 ] |
287 ] |
288 |
288 |
289 |
289 |
290 def _trackphasechange(data, rev, old, new): |
290 def _trackphasechange(data, rev, old, new): |
291 """add a phase move to the <data> list of ranges |
291 """add a phase move to the <data> list of ranges |
331 high = mid |
331 high = mid |
332 else: |
332 else: |
333 low = mid + 1 |
333 low = mid + 1 |
334 |
334 |
335 if low == len(data): |
335 if low == len(data): |
336 data.append((pycompat.xrange(rev, rev + 1), t)) |
336 data.append((range(rev, rev + 1), t)) |
337 return |
337 return |
338 |
338 |
339 r1, t1 = data[low] |
339 r1, t1 = data[low] |
340 if r1[0] > rev: |
340 if r1[0] > rev: |
341 data.insert(low, (pycompat.xrange(rev, rev + 1), t)) |
341 data.insert(low, (range(rev, rev + 1), t)) |
342 else: |
342 else: |
343 data.insert(low + 1, (pycompat.xrange(rev, rev + 1), t)) |
343 data.insert(low + 1, (range(rev, rev + 1), t)) |
344 |
344 |
345 |
345 |
346 class phasecache: |
346 class phasecache: |
347 def __init__(self, repo, phasedefaults, _load=True): |
347 def __init__(self, repo, phasedefaults, _load=True): |
348 # type: (localrepo.localrepository, Optional[Phasedefaults], bool) -> None |
348 # type: (localrepo.localrepository, Optional[Phasedefaults], bool) -> None |
627 new = self.phaseroots[targetphase] |
627 new = self.phaseroots[targetphase] |
628 old = oldroots[targetphase] |
628 old = oldroots[targetphase] |
629 affected = set(repo.revs(b'(%ln::) - (%ln::)', new, old)) |
629 affected = set(repo.revs(b'(%ln::) - (%ln::)', new, old)) |
630 |
630 |
631 # find the phase of the affected revision |
631 # find the phase of the affected revision |
632 for phase in pycompat.xrange(targetphase, -1, -1): |
632 for phase in range(targetphase, -1, -1): |
633 if phase: |
633 if phase: |
634 roots = oldroots.get(phase, []) |
634 roots = oldroots.get(phase, []) |
635 revs = set(repo.revs(b'%ln::%ld', roots, affected)) |
635 revs = set(repo.revs(b'%ln::%ld', roots, affected)) |
636 affected -= revs |
636 affected -= revs |
637 else: # public phase |
637 else: # public phase |