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