Patchwork D6907: synthrepo: use pycompat.xrange

login
register
mail settings
Submitter phabricator
Date Sept. 29, 2019, 4:13 a.m.
Message ID <differential-rev-PHID-DREV-iher5skariouwij44y6o-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41827/
State Superseded
Headers show

Comments

phabricator - Sept. 29, 2019, 4:13 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This silences some test-check-pyflakes.t warnings on Python 3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6907

AFFECTED FILES
  contrib/synthrepo.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py
--- a/contrib/synthrepo.py
+++ b/contrib/synthrepo.py
@@ -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: