contrib/perf.py
changeset 38258 ae6e02fcee24
parent 38257 a577a199983c
child 38273 9df777d7f061
equal deleted inserted replaced
38257:a577a199983c 38258:ae6e02fcee24
   907     fm.end()
   907     fm.end()
   908 
   908 
   909 @command('perftemplating',
   909 @command('perftemplating',
   910          [('r', 'rev', [], 'revisions to run the template on'),
   910          [('r', 'rev', [], 'revisions to run the template on'),
   911          ] + formatteropts)
   911          ] + formatteropts)
   912 def perftemplating(ui, repo, **opts):
   912 def perftemplating(ui, repo, testedtemplate=None, **opts):
       
   913     """test the rendering time of a given template"""
   913     if makelogtemplater is None:
   914     if makelogtemplater is None:
   914         ui.write_err('incompatible Mercurial version')
   915         ui.write_err('incompatible Mercurial version')
   915         return 1
   916         return 1
   916 
   917 
   917     nullui = ui.copy()
   918     nullui = ui.copy()
   920     revs = opts.get('rev')
   921     revs = opts.get('rev')
   921     if not revs:
   922     if not revs:
   922         revs = ['all()']
   923         revs = ['all()']
   923     revs = list(scmutil.revrange(repo, revs))
   924     revs = list(scmutil.revrange(repo, revs))
   924 
   925 
   925     template = ('{date|shortdate} [{rev}:{node|short}]'
   926     defaulttemplate = ('{date|shortdate} [{rev}:{node|short}]'
   926                 ' {author|person}: {desc|firstline}\n')
   927                        ' {author|person}: {desc|firstline}\n')
   927     displayer = makelogtemplater(nullui, repo, template)
   928     if testedtemplate is None:
       
   929         testedtemplate = defaulttemplate
       
   930     displayer = makelogtemplater(nullui, repo, testedtemplate)
   928     def format():
   931     def format():
   929         for r in revs:
   932         for r in revs:
   930             ctx = repo[r]
   933             ctx = repo[r]
   931             displayer.show(ctx)
   934             displayer.show(ctx)
   932             displayer.flush(ctx)
   935             displayer.flush(ctx)