log: rewrite default template to use labels (issue2866)
This is a complete rewrite of the default template to use labels. This
seems ultimately useless to me in most cases. The biggest benefit of
this patch to me seems to be a fairly complicated example of the
templating engine. It was a lot of hard work to figure out the precise
acceptable syntax, since it's almost undocumented. Hat tip to Steve
Losh's smartlog template, which helped me figure out a lot of the
syntax. Hopefully later I can use the present default log template
as an example for documenting the templating engine.
A test is attached. My goal was to match the --color=debug output,
which may differ slightly in newlines from the actual ANSI escape
codes output. I consider this an acceptable invisible deviation.
There seems to be a considerable slowdown with this rewrite.
Before:
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.882s
user 0m0.812s
sys 0m0.064s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.872s
user 0m0.796s
sys 0m0.068s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.917s
user 0m0.836s
sys 0m0.076s
After:
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.480s
user 0m1.392s
sys 0m0.072s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.500s
user 0m1.400s
sys 0m0.088s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.462s
user 0m1.364s
sys 0m0.092s
Following the maxim, "make it work, profile, make it faster, in that
order", I deem this slowdown acceptable for now.
I suspect but have not confirmed that a big slowdown comes from
calling keywords twice in the file templates, once to test the
existence of output and again to actually list the output. If so, a
simple speedup might be to improve the templating engine to cache
keywords when called more than once on the same revision.
TODO: I found a bug while working on this. The following stack traces:
hg log -r . -T '{ifcontains(phase, "secret public", "lol", "omg")}\n'
2014-10-04 03:48:56 +04:00
|
|
|
# Base templates. Due to name clashes with existing keywords, we have
|
|
|
|
# to replace some keywords with 'lkeyword', for 'labelled keyword'
|
|
|
|
changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}\n'
|
2015-03-14 16:34:27 +03:00
|
|
|
changeset_quiet = '{lnode}'
|
log: rewrite default template to use labels (issue2866)
This is a complete rewrite of the default template to use labels. This
seems ultimately useless to me in most cases. The biggest benefit of
this patch to me seems to be a fairly complicated example of the
templating engine. It was a lot of hard work to figure out the precise
acceptable syntax, since it's almost undocumented. Hat tip to Steve
Losh's smartlog template, which helped me figure out a lot of the
syntax. Hopefully later I can use the present default log template
as an example for documenting the templating engine.
A test is attached. My goal was to match the --color=debug output,
which may differ slightly in newlines from the actual ANSI escape
codes output. I consider this an acceptable invisible deviation.
There seems to be a considerable slowdown with this rewrite.
Before:
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.882s
user 0m0.812s
sys 0m0.064s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.872s
user 0m0.796s
sys 0m0.068s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.917s
user 0m0.836s
sys 0m0.076s
After:
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.480s
user 0m1.392s
sys 0m0.072s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.500s
user 0m1.400s
sys 0m0.088s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.462s
user 0m1.364s
sys 0m0.092s
Following the maxim, "make it work, profile, make it faster, in that
order", I deem this slowdown acceptable for now.
I suspect but have not confirmed that a big slowdown comes from
calling keywords twice in the file templates, once to test the
existence of output and again to actually list the output. If so, a
simple speedup might be to improve the templating engine to cache
keywords when called more than once on the same revision.
TODO: I found a bug while working on this. The following stack traces:
hg log -r . -T '{ifcontains(phase, "secret public", "lol", "omg")}\n'
2014-10-04 03:48:56 +04:00
|
|
|
changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
|
|
|
|
changeset_debug = '{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n'
|
|
|
|
|
|
|
|
# File templates
|
|
|
|
lfiles = '{if(files,
|
|
|
|
label("ui.note log.files",
|
|
|
|
"files: {files}\n"))}'
|
|
|
|
|
|
|
|
lfile_mods = '{if(file_mods,
|
|
|
|
label("ui.debug log.files",
|
|
|
|
"files: {file_mods}\n"))}'
|
|
|
|
|
|
|
|
lfile_adds = '{if(file_adds,
|
|
|
|
label("ui.debug log.files",
|
|
|
|
"files+: {file_adds}\n"))}'
|
|
|
|
|
|
|
|
lfile_dels = '{if(file_dels,
|
|
|
|
label("ui.debug log.files",
|
|
|
|
"files-: {file_dels}\n"))}'
|
|
|
|
|
|
|
|
lfile_copies_switch = '{if(file_copies_switch,
|
|
|
|
label("ui.note log.copies",
|
|
|
|
"copies: {file_copies_switch
|
|
|
|
% ' {name} ({source})'}\n"))}'
|
|
|
|
|
|
|
|
# General templates
|
|
|
|
cset = '{label("log.changeset changeset.{phase}",
|
|
|
|
"changeset: {rev}:{node|short}")}\n'
|
|
|
|
|
|
|
|
lphase = '{label("log.phase",
|
|
|
|
"phase: {phase}")}\n'
|
|
|
|
|
|
|
|
fullcset = '{label("log.changeset changeset.{phase}",
|
|
|
|
"changeset: {rev}:{node}")}\n'
|
|
|
|
|
|
|
|
parent = '{label("log.parent changeset.{phase}",
|
|
|
|
"parent: {rev}:{node|formatnode}")}\n'
|
|
|
|
|
2015-03-14 16:34:27 +03:00
|
|
|
lnode = '{label("log.node",
|
log: rewrite default template to use labels (issue2866)
This is a complete rewrite of the default template to use labels. This
seems ultimately useless to me in most cases. The biggest benefit of
this patch to me seems to be a fairly complicated example of the
templating engine. It was a lot of hard work to figure out the precise
acceptable syntax, since it's almost undocumented. Hat tip to Steve
Losh's smartlog template, which helped me figure out a lot of the
syntax. Hopefully later I can use the present default log template
as an example for documenting the templating engine.
A test is attached. My goal was to match the --color=debug output,
which may differ slightly in newlines from the actual ANSI escape
codes output. I consider this an acceptable invisible deviation.
There seems to be a considerable slowdown with this rewrite.
Before:
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.882s
user 0m0.812s
sys 0m0.064s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.872s
user 0m0.796s
sys 0m0.068s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.917s
user 0m0.836s
sys 0m0.076s
After:
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.480s
user 0m1.392s
sys 0m0.072s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.500s
user 0m1.400s
sys 0m0.088s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.462s
user 0m1.364s
sys 0m0.092s
Following the maxim, "make it work, profile, make it faster, in that
order", I deem this slowdown acceptable for now.
I suspect but have not confirmed that a big slowdown comes from
calling keywords twice in the file templates, once to test the
existence of output and again to actually list the output. If so, a
simple speedup might be to improve the templating engine to cache
keywords when called more than once on the same revision.
TODO: I found a bug while working on this. The following stack traces:
hg log -r . -T '{ifcontains(phase, "secret public", "lol", "omg")}\n'
2014-10-04 03:48:56 +04:00
|
|
|
"{rev}:{node|short}")}\n'
|
|
|
|
|
|
|
|
manifest = '{label("ui.debug log.manifest",
|
|
|
|
"manifest: {rev}:{node}")}\n'
|
|
|
|
|
|
|
|
branch = '{label("log.branch",
|
|
|
|
"branch: {branch}")}\n'
|
|
|
|
|
|
|
|
tag = '{label("log.tag",
|
|
|
|
"tag: {tag}")}\n'
|
|
|
|
|
|
|
|
bookmark = '{label("log.bookmark",
|
|
|
|
"bookmark: {bookmark}")}\n'
|
|
|
|
|
|
|
|
user = '{label("log.user",
|
|
|
|
"user: {author}")}\n'
|
|
|
|
|
2015-03-27 16:12:53 +03:00
|
|
|
summary = '{if(desc|strip, "{label('log.summary',
|
|
|
|
'summary: {desc|firstline}')}\n")}'
|
log: rewrite default template to use labels (issue2866)
This is a complete rewrite of the default template to use labels. This
seems ultimately useless to me in most cases. The biggest benefit of
this patch to me seems to be a fairly complicated example of the
templating engine. It was a lot of hard work to figure out the precise
acceptable syntax, since it's almost undocumented. Hat tip to Steve
Losh's smartlog template, which helped me figure out a lot of the
syntax. Hopefully later I can use the present default log template
as an example for documenting the templating engine.
A test is attached. My goal was to match the --color=debug output,
which may differ slightly in newlines from the actual ANSI escape
codes output. I consider this an acceptable invisible deviation.
There seems to be a considerable slowdown with this rewrite.
Before:
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.882s
user 0m0.812s
sys 0m0.064s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.872s
user 0m0.796s
sys 0m0.068s
$ time hg log -T default -r .~100::. > /dev/null
real 0m0.917s
user 0m0.836s
sys 0m0.076s
After:
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.480s
user 0m1.392s
sys 0m0.072s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.500s
user 0m1.400s
sys 0m0.088s
$ time hg log -T default -r .~100::. > /dev/null
real 0m1.462s
user 0m1.364s
sys 0m0.092s
Following the maxim, "make it work, profile, make it faster, in that
order", I deem this slowdown acceptable for now.
I suspect but have not confirmed that a big slowdown comes from
calling keywords twice in the file templates, once to test the
existence of output and again to actually list the output. If so, a
simple speedup might be to improve the templating engine to cache
keywords when called more than once on the same revision.
TODO: I found a bug while working on this. The following stack traces:
hg log -r . -T '{ifcontains(phase, "secret public", "lol", "omg")}\n'
2014-10-04 03:48:56 +04:00
|
|
|
|
|
|
|
ldate = '{label("log.date",
|
|
|
|
"date: {date|date}")}\n'
|
|
|
|
|
|
|
|
extra = '{label("ui.debug log.extra",
|
|
|
|
"extra: {key}={value|stringescape}")}\n'
|
|
|
|
|
2015-03-27 16:12:53 +03:00
|
|
|
description = '{if(desc|strip, "{label('ui.note log.description',
|
|
|
|
'description:')}
|
|
|
|
{label('ui.note log.description',
|
|
|
|
'{desc|strip}')}\n\n")}'
|
2015-06-10 22:35:05 +03:00
|
|
|
|
|
|
|
status = '{status} {path}\n{if(copy, " {copy}\n")}'
|