##// END OF EJS Templates
synthrepo: use pycompat.xrange...
Gregory Szorc -
r43274:c07812bd default
parent child Browse files
Show More
@@ -58,6 +58,7 b' from mercurial import ('
58 58 error,
59 59 hg,
60 60 patch,
61 pycompat,
61 62 registrar,
62 63 scmutil,
63 64 )
@@ -365,7 +366,7 b' def synthesize(ui, repo, descpath, **opt'
365 366 return True
366 367
367 368 progress = ui.makeprogress(_synthesizing, unit=_files, total=initcount)
368 for i in xrange(0, initcount):
369 for i in pycompat.xrange(0, initcount):
369 370 progress.update(i)
370 371
371 372 path = pickpath()
@@ -398,7 +399,7 b' def synthesize(ui, repo, descpath, **opt'
398 399 count = int(opts['count'])
399 400 heads = set(map(repo.changelog.rev, repo.heads()))
400 401 progress = ui.makeprogress(_synthesizing, unit=_changesets, total=count)
401 for i in xrange(count):
402 for i in pycompat.xrange(count):
402 403 progress.update(i)
403 404
404 405 node = repo.changelog.node
@@ -432,8 +433,8 b' def synthesize(ui, repo, descpath, **opt'
432 433 mfk = mf.keys()
433 434 changes = {}
434 435 if mfk:
435 for __ in xrange(pick(fileschanged)):
436 for __ in xrange(10):
436 for __ in pycompat.xrange(pick(fileschanged)):
437 for __ in pycompat.xrange(10):
437 438 fctx = pctx.filectx(random.choice(mfk))
438 439 path = fctx.path()
439 440 if not (path in nevertouch or fctx.isbinary() or
@@ -441,23 +442,23 b' def synthesize(ui, repo, descpath, **opt'
441 442 break
442 443 lines = fctx.data().splitlines()
443 444 add, remove = pick(lineschanged)
444 for __ in xrange(remove):
445 for __ in pycompat.xrange(remove):
445 446 if not lines:
446 447 break
447 448 del lines[random.randrange(0, len(lines))]
448 for __ in xrange(add):
449 for __ in pycompat.xrange(add):
449 450 lines.insert(random.randint(0, len(lines)), makeline())
450 451 path = fctx.path()
451 452 changes[path] = '\n'.join(lines) + '\n'
452 for __ in xrange(pick(filesremoved)):
453 for __ in xrange(10):
453 for __ in pycompat.xrange(pick(filesremoved)):
454 for __ in pycompat.xrange(10):
454 455 path = random.choice(mfk)
455 456 if path not in changes:
456 457 break
457 458 if filesadded:
458 459 dirs = list(pctx.dirs())
459 460 dirs.insert(0, '')
460 for __ in xrange(pick(filesadded)):
461 for __ in pycompat.xrange(pick(filesadded)):
461 462 pathstr = ''
462 463 while pathstr in dirs:
463 464 path = [random.choice(dirs)]
@@ -465,8 +466,9 b' def synthesize(ui, repo, descpath, **opt'
465 466 path.append(random.choice(words))
466 467 path.append(random.choice(words))
467 468 pathstr = '/'.join(filter(None, path))
468 data = '\n'.join(makeline()
469 for __ in xrange(pick(linesinfilesadded))) + '\n'
469 data = '\n'.join(
470 makeline()
471 for __ in pycompat.xrange(pick(linesinfilesadded))) + '\n'
470 472 changes[pathstr] = data
471 473 def filectxfn(repo, memctx, path):
472 474 if path not in changes:
General Comments 0
You need to be logged in to leave comments. Login now