78 # <4.7. |
78 # <4.7. |
79 try: |
79 try: |
80 queue = pycompat.queue |
80 queue = pycompat.queue |
81 except (AttributeError, ImportError): |
81 except (AttributeError, ImportError): |
82 queue = util.queue |
82 queue = util.queue |
|
83 |
|
84 try: |
|
85 from mercurial import logcmdutil |
|
86 makelogtemplater = logcmdutil.maketemplater |
|
87 except (AttributeError, ImportError): |
|
88 try: |
|
89 makelogtemplater = cmdutil.makelogtemplater |
|
90 except (AttributeError, ImportError): |
|
91 makelogtemplater = None |
83 |
92 |
84 # for "historical portability": |
93 # for "historical portability": |
85 # define util.safehasattr forcibly, because util.safehasattr has been |
94 # define util.safehasattr forcibly, because util.safehasattr has been |
86 # available since 1.9.3 (or 94b200a11cf7) |
95 # available since 1.9.3 (or 94b200a11cf7) |
87 _undefined = object() |
96 _undefined = object() |
899 |
908 |
900 @command('perftemplating', |
909 @command('perftemplating', |
901 [('r', 'rev', [], 'revisions to run the template on'), |
910 [('r', 'rev', [], 'revisions to run the template on'), |
902 ] + formatteropts) |
911 ] + formatteropts) |
903 def perftemplating(ui, repo, **opts): |
912 def perftemplating(ui, repo, **opts): |
|
913 if makelogtemplater is None: |
|
914 ui.write_err('incompatible Mercurial version') |
|
915 return 1 |
|
916 |
904 nullui = ui.copy() |
917 nullui = ui.copy() |
905 nullui.fout = open(os.devnull, 'wb') |
918 nullui.fout = open(os.devnull, 'wb') |
906 nullui.disablepager() |
919 nullui.disablepager() |
907 revs = opts.get('rev') |
920 revs = opts.get('rev') |
|
921 if not revs: |
|
922 revs = ['all()'] |
|
923 revs = list(scmutil.revrange(repo, revs)) |
|
924 |
|
925 template = ('{date|shortdate} [{rev}:{node|short}]' |
|
926 ' {author|person}: {desc|firstline}\n') |
|
927 displayer = makelogtemplater(nullui, repo, template) |
908 def format(): |
928 def format(): |
909 commands.log(nullui, repo, rev=revs, date='', user='', |
929 for r in revs: |
910 template='{date|shortdate} [{rev}:{node|short}]' |
930 ctx = repo[r] |
911 ' {author|person}: {desc|firstline}\n') |
931 displayer.show(ctx) |
|
932 displayer.flush(ctx) |
912 |
933 |
913 timer, fm = gettimer(ui, opts) |
934 timer, fm = gettimer(ui, opts) |
914 timer(format) |
935 timer(format) |
915 fm.end() |
936 fm.end() |
916 |
937 |