Mercurial > public > mercurial-scm > hg-stable
diff tests/test-ancestor.py @ 49293:56f98406831b
py3: remove xrange() compatibility code
Some code used its own xrange() compatibility code instead of
pycompat.xrange().
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sun, 29 May 2022 15:32:43 +0200 |
parents | 642e31cb55f0 |
children | 003c0732c055 |
line wrap: on
line diff
--- a/tests/test-ancestor.py Sun May 29 15:17:27 2022 +0200 +++ b/tests/test-ancestor.py Sun May 29 15:32:43 2022 +0200 @@ -18,7 +18,6 @@ if pycompat.ispy3: long = int - xrange = range def buildgraph(rng, nodes=100, rootprob=0.05, mergeprob=0.2, prevprob=0.7): @@ -30,7 +29,7 @@ return value is a graph represented as an adjacency list. """ graph = [None] * nodes - for i in xrange(nodes): + for i in range(nodes): if i == 0 or rng.random() < rootprob: graph[i] = [nullrev] elif i == 1: @@ -53,7 +52,7 @@ def buildancestorsets(graph): ancs = [None] * len(graph) - for i in xrange(len(graph)): + for i in range(len(graph)): ancs[i] = {i} if graph[i] == [nullrev]: continue @@ -114,11 +113,11 @@ nerrs[0] += 1 gerrs[0] += 1 - for g in xrange(graphcount): + for g in range(graphcount): graph = buildgraph(rng) ancs = buildancestorsets(graph) gerrs = [0] - for _ in xrange(testcount): + for _ in range(testcount): # start from nullrev to include it as a possibility graphnodes = range(nullrev, len(graph)) bases = samplerevs(graphnodes) @@ -128,7 +127,7 @@ # reference slow algorithm naiveinc = naiveincrementalmissingancestors(ancs, bases) seq = [] - for _ in xrange(inccount): + for _ in range(inccount): if rng.random() < 0.2: newbases = samplerevs(graphnodes) seq.append(('addbases', newbases)) @@ -215,7 +214,7 @@ """ for i, (bases, revs) in enumerate( ( - ({1, 2, 3, 4, 7}, set(xrange(10))), + ({1, 2, 3, 4, 7}, set(range(10))), ({10}, set({11, 12, 13, 14})), ({7}, set({1, 2, 3, 4, 5})), )