synthrepo: use pycompat.xrange
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 28 Sep 2019 21:13:27 -0700
changeset 43004 c07812bdd568
parent 43003 bbf77341a956
child 43005 7eac24de491d
synthrepo: use pycompat.xrange This silences some test-check-pyflakes.t warnings on Python 3. Differential Revision: https://phab.mercurial-scm.org/D6907
contrib/synthrepo.py
--- a/contrib/synthrepo.py	Fri Sep 27 00:40:52 2019 +0200
+++ b/contrib/synthrepo.py	Sat Sep 28 21:13:27 2019 -0700
@@ -58,6 +58,7 @@
     error,
     hg,
     patch,
+    pycompat,
     registrar,
     scmutil,
 )
@@ -365,7 +366,7 @@
             return True
 
         progress = ui.makeprogress(_synthesizing, unit=_files, total=initcount)
-        for i in xrange(0, initcount):
+        for i in pycompat.xrange(0, initcount):
             progress.update(i)
 
             path = pickpath()
@@ -398,7 +399,7 @@
     count = int(opts['count'])
     heads = set(map(repo.changelog.rev, repo.heads()))
     progress = ui.makeprogress(_synthesizing, unit=_changesets, total=count)
-    for i in xrange(count):
+    for i in pycompat.xrange(count):
         progress.update(i)
 
         node = repo.changelog.node
@@ -432,8 +433,8 @@
         mfk = mf.keys()
         changes = {}
         if mfk:
-            for __ in xrange(pick(fileschanged)):
-                for __ in xrange(10):
+            for __ in pycompat.xrange(pick(fileschanged)):
+                for __ in pycompat.xrange(10):
                     fctx = pctx.filectx(random.choice(mfk))
                     path = fctx.path()
                     if not (path in nevertouch or fctx.isbinary() or
@@ -441,23 +442,23 @@
                         break
                 lines = fctx.data().splitlines()
                 add, remove = pick(lineschanged)
-                for __ in xrange(remove):
+                for __ in pycompat.xrange(remove):
                     if not lines:
                         break
                     del lines[random.randrange(0, len(lines))]
-                for __ in xrange(add):
+                for __ in pycompat.xrange(add):
                     lines.insert(random.randint(0, len(lines)), makeline())
                 path = fctx.path()
                 changes[path] = '\n'.join(lines) + '\n'
-            for __ in xrange(pick(filesremoved)):
-                for __ in xrange(10):
+            for __ in pycompat.xrange(pick(filesremoved)):
+                for __ in pycompat.xrange(10):
                     path = random.choice(mfk)
                     if path not in changes:
                         break
         if filesadded:
             dirs = list(pctx.dirs())
             dirs.insert(0, '')
-        for __ in xrange(pick(filesadded)):
+        for __ in pycompat.xrange(pick(filesadded)):
             pathstr = ''
             while pathstr in dirs:
                 path = [random.choice(dirs)]
@@ -465,8 +466,9 @@
                     path.append(random.choice(words))
                 path.append(random.choice(words))
                 pathstr = '/'.join(filter(None, path))
-            data = '\n'.join(makeline()
-                             for __ in xrange(pick(linesinfilesadded))) + '\n'
+            data = '\n'.join(
+                makeline()
+                for __ in pycompat.xrange(pick(linesinfilesadded))) + '\n'
             changes[pathstr] = data
         def filectxfn(repo, memctx, path):
             if path not in changes: