comparison tests/test-command-template.t @ 22766:0ded0f0b1c04

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'
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Fri, 03 Oct 2014 19:48:56 -0400
parents 1e2f54a149e8
children 1533e642262d
comparison
equal deleted inserted replaced
22765:55dcc7fb731c 22766:0ded0f0b1c04
102 $ cmp log.out style.out || diff -u log.out style.out 102 $ cmp log.out style.out || diff -u log.out style.out
103 103
104 $ hg log --debug > log.out 104 $ hg log --debug > log.out
105 $ hg log --debug --style default > style.out 105 $ hg log --debug --style default > style.out
106 $ cmp log.out style.out || diff -u log.out style.out 106 $ cmp log.out style.out || diff -u log.out style.out
107
108 Default style should also preserve color information (issue2866):
109
110 $ cp $HGRCPATH $HGRCPATH-bak
111 $ cat <<EOF >> $HGRCPATH
112 > [extensions]
113 > color=
114 > EOF
115
116 $ hg --color=debug log > log.out
117 $ hg --color=debug log --style default > style.out
118 $ cmp log.out style.out || diff -u log.out style.out
119 $ hg --color=debug -v log > log.out
120 $ hg --color=debug -v log --style default > style.out
121 $ cmp log.out style.out || diff -u log.out style.out
122 $ hg --color=debug --debug log > log.out
123 $ hg --color=debug --debug log --style default > style.out
124 $ cmp log.out style.out || diff -u log.out style.out
125
126 $ mv $HGRCPATH-bak $HGRCPATH
107 127
108 Revision with no copies (used to print a traceback): 128 Revision with no copies (used to print a traceback):
109 129
110 $ hg tip -v --template '\n' 130 $ hg tip -v --template '\n'
111 131