contrib/perf.py
changeset 41156 f36fd52dae8f
parent 41002 e88ced97151d
child 41365 876494fd967d
equal deleted inserted replaced
41155:8c222bec97da 41156:f36fd52dae8f
  1836         revs = list(orig.revs(startrev, stoprev))
  1836         revs = list(orig.revs(startrev, stoprev))
  1837         total = len(revs)
  1837         total = len(revs)
  1838         topic = 'adding'
  1838         topic = 'adding'
  1839         if runidx is not None:
  1839         if runidx is not None:
  1840             topic += ' (run #%d)' % runidx
  1840             topic += ' (run #%d)' % runidx
       
  1841          # Support both old and new progress API
       
  1842         if util.safehasattr(ui, 'makeprogress'):
       
  1843             progress = ui.makeprogress(topic, unit='revs', total=total)
       
  1844             def updateprogress(pos):
       
  1845                 progress.update(pos)
       
  1846             def completeprogress():
       
  1847                 progress.complete()
       
  1848         else:
       
  1849             def updateprogress(pos):
       
  1850                 ui.progress(topic, pos, unit='revs', total=total)
       
  1851             def completeprogress():
       
  1852                 ui.progress(topic, None, unit='revs', total=total)
       
  1853 
  1841         for idx, rev in enumerate(revs):
  1854         for idx, rev in enumerate(revs):
  1842             ui.progress(topic, idx, unit='revs', total=total)
  1855             updateprogress(idx)
  1843             addargs, addkwargs = _getrevisionseed(orig, rev, tr, source)
  1856             addargs, addkwargs = _getrevisionseed(orig, rev, tr, source)
  1844             if clearcaches:
  1857             if clearcaches:
  1845                 dest.index.clearcaches()
  1858                 dest.index.clearcaches()
  1846                 dest.clearcaches()
  1859                 dest.clearcaches()
  1847             with timeone() as r:
  1860             with timeone() as r:
  1848                 dest.addrawrevision(*addargs, **addkwargs)
  1861                 dest.addrawrevision(*addargs, **addkwargs)
  1849             timings.append((rev, r[0]))
  1862             timings.append((rev, r[0]))
  1850         ui.progress(topic, total, unit='revs', total=total)
  1863         updateprogress(total)
  1851         ui.progress(topic, None, unit='revs', total=total)
  1864         completeprogress()
  1852     return timings
  1865     return timings
  1853 
  1866 
  1854 def _getrevisionseed(orig, rev, tr, source):
  1867 def _getrevisionseed(orig, rev, tr, source):
  1855     from mercurial.node import nullid
  1868     from mercurial.node import nullid
  1856 
  1869