comparison contrib/synthrepo.py @ 38408:6540333acb95

synthrepo: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3809
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 18 Jun 2018 15:17:10 -0700
parents c6061cadb400
children ce65c25dc161
comparison
equal deleted inserted replaced
38407:164306d3f4b4 38408:6540333acb95
170 # If a mercurial repo is available, also model the commit history. 170 # If a mercurial repo is available, also model the commit history.
171 if repo: 171 if repo:
172 revs = scmutil.revrange(repo, revs) 172 revs = scmutil.revrange(repo, revs)
173 revs.sort() 173 revs.sort()
174 174
175 progress = ui.progress 175 progress = ui.makeprogress(_('analyzing'), unit=_('changesets'),
176 _analyzing = _('analyzing') 176 total=len(revs))
177 _changesets = _('changesets')
178 _total = len(revs)
179
180 for i, rev in enumerate(revs): 177 for i, rev in enumerate(revs):
181 progress(_analyzing, i, unit=_changesets, total=_total) 178 progress.update(i)
182 ctx = repo[rev] 179 ctx = repo[rev]
183 pl = ctx.parents() 180 pl = ctx.parents()
184 pctx = pl[0] 181 pctx = pl[0]
185 prev = pctx.rev() 182 prev = pctx.rev()
186 children[prev] += 1 183 children[prev] += 1
336 wlock = repo.wlock() 333 wlock = repo.wlock()
337 lock = repo.lock() 334 lock = repo.lock()
338 335
339 nevertouch = {'.hgsub', '.hgignore', '.hgtags'} 336 nevertouch = {'.hgsub', '.hgignore', '.hgtags'}
340 337
341 progress = ui.progress
342 _synthesizing = _('synthesizing') 338 _synthesizing = _('synthesizing')
343 _files = _('initial files') 339 _files = _('initial files')
344 _changesets = _('changesets') 340 _changesets = _('changesets')
345 341
346 # Synthesize a single initial revision adding files to the repo according 342 # Synthesize a single initial revision adding files to the repo according
360 if path in files: 356 if path in files:
361 return False 357 return False
362 path = os.path.dirname(path) 358 path = os.path.dirname(path)
363 return True 359 return True
364 360
361 progress = ui.makeprogress(_synthesizing, unit=_files, total=initcount)
365 for i in xrange(0, initcount): 362 for i in xrange(0, initcount):
366 ui.progress(_synthesizing, i, unit=_files, total=initcount) 363 progress.update(i)
367 364
368 path = pickpath() 365 path = pickpath()
369 while not validpath(path): 366 while not validpath(path):
370 path = pickpath() 367 path = pickpath()
371 data = '%s contents\n' % path 368 data = '%s contents\n' % path
376 dir = os.path.dirname(dir) 373 dir = os.path.dirname(dir)
377 374
378 def filectxfn(repo, memctx, path): 375 def filectxfn(repo, memctx, path):
379 return context.memfilectx(repo, memctx, path, files[path]) 376 return context.memfilectx(repo, memctx, path, files[path])
380 377
381 ui.progress(_synthesizing, None) 378 progress.complete()
382 message = 'synthesized wide repo with %d files' % (len(files),) 379 message = 'synthesized wide repo with %d files' % (len(files),)
383 mc = context.memctx(repo, [pctx.node(), nullid], message, 380 mc = context.memctx(repo, [pctx.node(), nullid], message,
384 files, filectxfn, ui.username(), 381 files, filectxfn, ui.username(),
385 '%d %d' % dateutil.makedate()) 382 '%d %d' % dateutil.makedate())
386 initnode = mc.commit() 383 initnode = mc.commit()
392 % (hexfn(initnode), len(files))) 389 % (hexfn(initnode), len(files)))
393 390
394 # Synthesize incremental revisions to the repository, adding repo depth. 391 # Synthesize incremental revisions to the repository, adding repo depth.
395 count = int(opts['count']) 392 count = int(opts['count'])
396 heads = set(map(repo.changelog.rev, repo.heads())) 393 heads = set(map(repo.changelog.rev, repo.heads()))
394 progress = ui.makeprogress(_synthesizing, unit=_changesets, total=count)
397 for i in xrange(count): 395 for i in xrange(count):
398 progress(_synthesizing, i, unit=_changesets, total=count) 396 progress.update(i)
399 397
400 node = repo.changelog.node 398 node = repo.changelog.node
401 revs = len(repo) 399 revs = len(repo)
402 400
403 def pickhead(heads, distance): 401 def pickhead(heads, distance):