annotate en/ch11-template.xml @ 838:d1f676a6a4b3 default tip

update mq chapter. propagate ef53d025f410.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 03 Dec 2009 01:26:08 +0900
parents acf9dc5f088d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
1 <!-- vim: set filetype=docbkxml shiftwidth=2 autoindent expandtab tw=77 : -->
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
2
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
3 <chapter id="chap:template">
671
13513d2a128d Add sensible names to chapters.
Bryan O'Sullivan <bos@serpentine.com>
parents: 666
diff changeset
4 <?dbhtml filename="customizing-the-output-of-mercurial.html"?>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
5 <title>Customizing the output of Mercurial</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
6
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
7 <para id="x_578">Mercurial provides a powerful mechanism to let you control how
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
8 it displays information. The mechanism is based on templates.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
9 You can use templates to generate specific output for a single
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
10 command, or to customize the entire appearance of the built-in web
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
11 interface.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
12
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
13 <sect1 id="sec:style">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
14 <title>Using precanned output styles</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
15
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
16 <para id="x_579">Packaged with Mercurial are some output styles that you can
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
17 use immediately. A style is simply a precanned template that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
18 someone wrote and installed somewhere that Mercurial can
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
19 find.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
20
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
21 <para id="x_57a">Before we take a look at Mercurial's bundled styles, let's
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
22 review its normal output.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
23
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
24 &interaction.template.simple.normal;
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
25
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
26 <para id="x_57b">This is somewhat informative, but it takes up a lot of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
27 space&emdash;five lines of output per changeset. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
28 <literal>compact</literal> style reduces this to three lines,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
29 presented in a sparse manner.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
30
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
31 &interaction.template.simple.compact;
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
32
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
33 <para id="x_57c">The <literal>changelog</literal> style hints at the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
34 expressive power of Mercurial's templating engine. This style
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
35 attempts to follow the GNU Project's changelog
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
36 guidelines<citation>web:changelog</citation>.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
37
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
38 &interaction.template.simple.changelog;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
39
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
40 <para id="x_57d">You will not be shocked to learn that Mercurial's default
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
41 output style is named <literal>default</literal>.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
42
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
43 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
44 <title>Setting a default style</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
45
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
46 <para id="x_57e">You can modify the output style that Mercurial will use
680
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
47 for every command by editing your <filename
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
48 role="special">~/.hgrc</filename> file, naming the style
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
49 you would prefer to use.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
50
680
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
51 <programlisting>[ui]
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
52 style = compact</programlisting>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
53
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
54 <para id="x_57f">If you write a style of your own, you can use it by either
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
55 providing the path to your style file, or copying your style
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
56 file into a location where Mercurial can find it (typically
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
57 the <literal>templates</literal> subdirectory of your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
58 Mercurial install directory).</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
59 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
60 </sect1>
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
61
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
62 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
63 <title>Commands that support styles and templates</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
64
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
65 <para id="x_580">All of Mercurial's
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
66 <quote><literal>log</literal>-like</quote> commands let you use
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
67 styles and templates: <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
68 incoming</command>, <command role="hg-cmd">hg log</command>,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
69 <command role="hg-cmd">hg outgoing</command>, and <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
70 role="hg-cmd">hg tip</command>.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
71
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
72 <para id="x_581">As I write this manual, these are so far the only commands
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
73 that support styles and templates. Since these are the most
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
74 important commands that need customizable output, there has been
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
75 little pressure from the Mercurial user community to add style
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
76 and template support to other commands.</para>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
77 </sect1>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
78
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
79 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
80 <title>The basics of templating</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
81
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
82 <para id="x_582">At its simplest, a Mercurial template is a piece of text.
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
83 Some of the text never changes, while other parts are
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
84 <emphasis>expanded</emphasis>, or replaced with new text, when
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
85 necessary.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
86
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
87 <para id="x_583">Before we continue, let's look again at a simple example of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
88 Mercurial's normal output.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
89
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
90 &interaction.template.simple.normal;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
91
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
92 <para id="x_584">Now, let's run the same command, but using a template to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
93 change its output.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
94
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
95 &interaction.template.simple.simplest;
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
96
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
97 <para id="x_585">The example above illustrates the simplest possible
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
98 template; it's just a piece of static text, printed once for
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
99 each changeset. The <option
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
100 role="hg-opt-log">--template</option> option to the <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
101 role="hg-cmd">hg log</command> command tells Mercurial to use
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
102 the given text as the template when printing each
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
103 changeset.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
104
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
105 <para id="x_586">Notice that the template string above ends with the text
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
106 <quote><literal>\n</literal></quote>. This is an
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
107 <emphasis>escape sequence</emphasis>, telling Mercurial to print
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
108 a newline at the end of each template item. If you omit this
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
109 newline, Mercurial will run each piece of output together. See
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
110 <xref linkend="sec:template:escape"/> for more details
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
111 of escape sequences.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
112
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
113 <para id="x_587">A template that prints a fixed string of text all the time
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
114 isn't very useful; let's try something a bit more
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
115 complex.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
116
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
117 &interaction.template.simple.simplesub;
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
118
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
119 <para id="x_588">As you can see, the string
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
120 <quote><literal>{desc}</literal></quote> in the template has
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
121 been replaced in the output with the description of each
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
122 changeset. Every time Mercurial finds text enclosed in curly
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
123 braces (<quote><literal>{</literal></quote> and
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
124 <quote><literal>}</literal></quote>), it will try to replace the
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
125 braces and text with the expansion of whatever is inside. To
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
126 print a literal curly brace, you must escape it, as described in
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
127 <xref linkend="sec:template:escape"/>.</para>
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
128 </sect1>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
129
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
130 <sect1 id="sec:template:keyword">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
131 <title>Common template keywords</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
132
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
133 <para id="x_589">You can start writing simple templates immediately using the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
134 keywords below.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
135
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
136 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
137 <listitem><para id="x_58a"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
138 role="template-keyword">author</literal>: String. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
139 unmodified author of the changeset.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
140 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
141 <listitem><para id="x_58b"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
142 role="template-keyword">branches</literal>: String. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
143 name of the branch on which the changeset was committed.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
144 Will be empty if the branch name was
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
145 <literal>default</literal>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
146 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
147 <listitem><para id="x_58c"><literal role="template-keyword">date</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
148 Date information. The date when the changeset was
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
149 committed. This is <emphasis>not</emphasis> human-readable;
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
150 you must pass it through a filter that will render it
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
151 appropriately. See <xref
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
152 linkend="sec:template:filter"/> for more information
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
153 on filters. The date is expressed as a pair of numbers. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
154 first number is a Unix UTC timestamp (seconds since January
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
155 1, 1970); the second is the offset of the committer's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
156 timezone from UTC, in seconds.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
157 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
158 <listitem><para id="x_58d"><literal role="template-keyword">desc</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
159 String. The text of the changeset description.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
160 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
161 <listitem><para id="x_58e"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
162 role="template-keyword">files</literal>: List of strings.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
163 All files modified, added, or removed by this
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
164 changeset.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
165 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
166 <listitem><para id="x_58f"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
167 role="template-keyword">file_adds</literal>: List of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
168 strings. Files added by this changeset.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
169 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
170 <listitem><para id="x_590"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
171 role="template-keyword">file_dels</literal>: List of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
172 strings. Files removed by this changeset.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
173 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
174 <listitem><para id="x_591"><literal role="template-keyword">node</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
175 String. The changeset identification hash, as a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
176 40-character hexadecimal string.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
177 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
178 <listitem><para id="x_592"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
179 role="template-keyword">parents</literal>: List of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
180 strings. The parents of the changeset.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
181 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
182 <listitem><para id="x_593"><literal role="template-keyword">rev</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
183 Integer. The repository-local changeset revision
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
184 number.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
185 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
186 <listitem><para id="x_594"><literal role="template-keyword">tags</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
187 List of strings. Any tags associated with the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
188 changeset.</para>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
189 </listitem>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
190 </itemizedlist>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
191
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
192 <para id="x_595">A few simple experiments will show us what to expect when we
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
193 use these keywords; you can see the results below.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
194
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
195 &interaction.template.simple.keywords;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
196
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
197 <para id="x_596">As we noted above, the date keyword does not produce
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
198 human-readable output, so we must treat it specially. This
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
199 involves using a <emphasis>filter</emphasis>, about which more
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
200 in <xref linkend="sec:template:filter"/>.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
201
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
202 &interaction.template.simple.datekeyword;
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
203 </sect1>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
204
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
205 <sect1 id="sec:template:escape">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
206 <title>Escape sequences</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
207
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
208 <para id="x_597">Mercurial's templating engine recognises the most commonly
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
209 used escape sequences in strings. When it sees a backslash
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
210 (<quote><literal>\</literal></quote>) character, it looks at the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
211 following character and substitutes the two characters with a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
212 single replacement, as described below.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
213
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
214 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
215 <listitem><para id="x_598"><literal>\</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
216 Backslash, <quote><literal>\</literal></quote>, ASCII
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
217 134.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
218 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
219 <listitem><para id="x_599"><literal>\n</literal>: Newline,
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
220 ASCII 12.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
221 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
222 <listitem><para id="x_59a"><literal>\r</literal>: Carriage
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
223 return, ASCII 15.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
224 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
225 <listitem><para id="x_59b"><literal>\t</literal>: Tab, ASCII
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
226 11.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
227 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
228 <listitem><para id="x_59c"><literal>\v</literal>: Vertical
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
229 tab, ASCII 13.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
230 </listitem>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
231 <listitem><para id="x_59d"><literal>\{</literal>: Open curly
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
232 brace, <quote><literal>{</literal></quote>, ASCII
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
233 173.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
234 </listitem>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
235 <listitem><para id="x_59e"><literal>\}</literal>: Close curly
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
236 brace, <quote><literal>}</literal></quote>, ASCII
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
237 175.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
238 </listitem></itemizedlist>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
239
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
240 <para id="x_59f">As indicated above, if you want the expansion of a template
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
241 to contain a literal <quote><literal>\</literal></quote>,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
242 <quote><literal>{</literal></quote>, or
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
243 <quote><literal>{</literal></quote> character, you must escape
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
244 it.</para>
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
245 </sect1>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
246
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
247 <sect1 id="sec:template:filter">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
248 <title>Filtering keywords to change their results</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
249
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
250 <para id="x_5a0">Some of the results of template expansion are not
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
251 immediately easy to use. Mercurial lets you specify an optional
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
252 chain of <emphasis>filters</emphasis> to modify the result of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
253 expanding a keyword. You have already seen a common filter,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
254 <literal role="template-kw-filt-date">isodate</literal>, in
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
255 action above, to make a date readable.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
256
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
257 <para id="x_5a1">Below is a list of the most commonly used filters that
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
258 Mercurial supports. While some filters can be applied to any
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
259 text, others can only be used in specific circumstances. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
260 name of each filter is followed first by an indication of where
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
261 it can be used, then a description of its effect.</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
262
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
263 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
264 <listitem><para id="x_5a2"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
265 role="template-filter">addbreaks</literal>: Any text. Add
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
266 an XHTML <quote><literal>&lt;br/&gt;</literal></quote> tag
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
267 before the end of every line except the last. For example,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
268 <quote><literal>foo\nbar</literal></quote> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
269 <quote><literal>foo&lt;br/&gt;\nbar</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
270 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
271 <listitem><para id="x_5a3"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
272 role="template-kw-filt-date">age</literal>: <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
273 role="template-keyword">date</literal> keyword. Render
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
274 the age of the date, relative to the current time. Yields a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
275 string like <quote><literal>10
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
276 minutes</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
277 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
278 <listitem><para id="x_5a4"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
279 role="template-filter">basename</literal>: Any text, but
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
280 most useful for the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
281 role="template-keyword">files</literal> keyword and its
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
282 relatives. Treat the text as a path, and return the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
283 basename. For example,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
284 <quote><literal>foo/bar/baz</literal></quote> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
285 <quote><literal>baz</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
286 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
287 <listitem><para id="x_5a5"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
288 role="template-kw-filt-date">date</literal>: <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
289 role="template-keyword">date</literal> keyword. Render a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
290 date in a similar format to the Unix <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
291 role="template-keyword">date</literal> command, but with
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
292 timezone included. Yields a string like <quote><literal>Mon
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
293 Sep 04 15:13:13 2006 -0700</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
294 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
295 <listitem><para id="x_5a6"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
296 role="template-kw-filt-author">domain</literal>: Any text,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
297 but most useful for the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
298 role="template-keyword">author</literal> keyword. Finds
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
299 the first string that looks like an email address, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
300 extract just the domain component. For example,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
301 <quote><literal>Bryan O'Sullivan
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
302 &lt;bos@serpentine.com&gt;</literal></quote> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
303 <quote><literal>serpentine.com</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
304 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
305 <listitem><para id="x_5a7"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
306 role="template-kw-filt-author">email</literal>: Any text,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
307 but most useful for the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
308 role="template-keyword">author</literal> keyword. Extract
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
309 the first string that looks like an email address. For
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
310 example, <quote><literal>Bryan O'Sullivan
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
311 &lt;bos@serpentine.com&gt;</literal></quote> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
312 <quote><literal>bos@serpentine.com</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
313 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
314 <listitem><para id="x_5a8"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
315 role="template-filter">escape</literal>: Any text.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
316 Replace the special XML/XHTML characters
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
317 <quote><literal>&amp;</literal></quote>,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
318 <quote><literal>&lt;</literal></quote> and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
319 <quote><literal>&gt;</literal></quote> with XML
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
320 entities.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
321 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
322 <listitem><para id="x_5a9"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
323 role="template-filter">fill68</literal>: Any text. Wrap
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
324 the text to fit in 68 columns. This is useful before you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
325 pass text through the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
326 role="template-filter">tabindent</literal> filter, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
327 still want it to fit in an 80-column fixed-font
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
328 window.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
329 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
330 <listitem><para id="x_5aa"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
331 role="template-filter">fill76</literal>: Any text. Wrap
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
332 the text to fit in 76 columns.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
333 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
334 <listitem><para id="x_5ab"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
335 role="template-filter">firstline</literal>: Any text.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
336 Yield the first line of text, without any trailing
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
337 newlines.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
338 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
339 <listitem><para id="x_5ac"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
340 role="template-kw-filt-date">hgdate</literal>: <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
341 role="template-keyword">date</literal> keyword. Render
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
342 the date as a pair of readable numbers. Yields a string
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
343 like <quote><literal>1157407993
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
344 25200</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
345 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
346 <listitem><para id="x_5ad"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
347 role="template-kw-filt-date">isodate</literal>: <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
348 role="template-keyword">date</literal> keyword. Render
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
349 the date as a text string in ISO 8601 format. Yields a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
350 string like <quote><literal>2006-09-04 15:13:13
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
351 -0700</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
352 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
353 <listitem><para id="x_5ae"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
354 role="template-filter">obfuscate</literal>: Any text, but
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
355 most useful for the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
356 role="template-keyword">author</literal> keyword. Yield
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
357 the input text rendered as a sequence of XML entities. This
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
358 helps to defeat some particularly stupid screen-scraping
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
359 email harvesting spambots.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
360 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
361 <listitem><para id="x_5af"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
362 role="template-kw-filt-author">person</literal>: Any text,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
363 but most useful for the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
364 role="template-keyword">author</literal> keyword. Yield
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
365 the text before an email address. For example,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
366 <quote><literal>Bryan O'Sullivan
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
367 &lt;bos@serpentine.com&gt;</literal></quote> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
368 <quote><literal>Bryan O'Sullivan</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
369 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
370 <listitem><para id="x_5b0"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
371 role="template-kw-filt-date">rfc822date</literal>:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
372 <literal role="template-keyword">date</literal> keyword.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
373 Render a date using the same format used in email headers.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
374 Yields a string like <quote><literal>Mon, 04 Sep 2006
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
375 15:13:13 -0700</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
376 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
377 <listitem><para id="x_5b1"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
378 role="template-kw-filt-node">short</literal>: Changeset
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
379 hash. Yield the short form of a changeset hash, i.e. a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
380 12-character hexadecimal string.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
381 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
382 <listitem><para id="x_5b2"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
383 role="template-kw-filt-date">shortdate</literal>: <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
384 role="template-keyword">date</literal> keyword. Render
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
385 the year, month, and day of the date. Yields a string like
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
386 <quote><literal>2006-09-04</literal></quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
387 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
388 <listitem><para id="x_5b3"><literal role="template-filter">strip</literal>:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
389 Any text. Strip all leading and trailing whitespace from
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
390 the string.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
391 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
392 <listitem><para id="x_5b4"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
393 role="template-filter">tabindent</literal>: Any text.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
394 Yield the text, with every line except the first starting
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
395 with a tab character.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
396 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
397 <listitem><para id="x_5b5"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
398 role="template-filter">urlescape</literal>: Any text.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
399 Escape all characters that are considered
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
400 <quote>special</quote> by URL parsers. For example,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
401 <literal>foo bar</literal> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
402 <literal>foo%20bar</literal>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
403 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
404 <listitem><para id="x_5b6"><literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
405 role="template-kw-filt-author">user</literal>: Any text,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
406 but most useful for the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
407 role="template-keyword">author</literal> keyword. Return
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
408 the <quote>user</quote> portion of an email address. For
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
409 example, <quote><literal>Bryan O'Sullivan
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
410 &lt;bos@serpentine.com&gt;</literal></quote> becomes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
411 <quote><literal>bos</literal></quote>.</para>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
412 </listitem>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
413 </itemizedlist>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
414
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
415 &interaction.template.simple.manyfilters;
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
416
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
417 <note>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
418 <para id="x_5b7"> If you try to apply a filter to a piece of data that it
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
419 cannot process, Mercurial will fail and print a Python
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
420 exception. For example, trying to run the output of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
421 <literal role="template-keyword">desc</literal> keyword into
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
422 the <literal role="template-kw-filt-date">isodate</literal>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
423 filter is not a good idea.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
424 </note>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
425
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
426 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
427 <title>Combining filters</title>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
428
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
429 <para id="x_5b8">It is easy to combine filters to yield output in the form
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
430 you would like. The following chain of filters tidies up a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
431 description, then makes sure that it fits cleanly into 68
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
432 columns, then indents it by a further 8 characters (at least
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
433 on Unix-like systems, where a tab is conventionally 8
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
434 characters wide).</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
435
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
436 &interaction.template.simple.combine;
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
437
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
438 <para id="x_5b9">Note the use of <quote><literal>\t</literal></quote> (a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
439 tab character) in the template to force the first line to be
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
440 indented; this is necessary since <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
441 role="template-keyword">tabindent</literal> indents all
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
442 lines <emphasis>except</emphasis> the first.</para>
80
ea951cfb5cd9 Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 76
diff changeset
443
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
444 <para id="x_5ba">Keep in mind that the order of filters in a chain is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
445 significant. The first filter is applied to the result of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
446 keyword; the second to the result of the first filter; and so
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
447 on. For example, using <literal>fill68|tabindent</literal>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
448 gives very different results from
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
449 <literal>tabindent|fill68</literal>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
450 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
451 </sect1>
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
452
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
453 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
454 <title>From templates to styles</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
455
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
456 <para id="x_5bb">A command line template provides a quick and simple way to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
457 format some output. Templates can become verbose, though, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
458 it's useful to be able to give a template a name. A style file
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
459 is a template with a name, stored in a file.</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
460
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
461 <para id="x_5bc">More than that, using a style file unlocks the power of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
462 Mercurial's templating engine in ways that are not possible
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
463 using the command line <option
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
464 role="hg-opt-log">--template</option> option.</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
465
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
466 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
467 <title>The simplest of style files</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
468
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
469 <para id="x_5bd">Our simple style file contains just one line:</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
470
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
471 &interaction.template.simple.rev;
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
472
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
473 <para id="x_5be">This tells Mercurial, <quote>if you're printing a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
474 changeset, use the text on the right as the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
475 template</quote>.</para>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
476 </sect2>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
477
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
478 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
479 <title>Style file syntax</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
480
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
481 <para id="x_5bf">The syntax rules for a style file are simple.</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
482
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
483 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
484 <listitem><para id="x_5c0">The file is processed one line at a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
485 time.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
486 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
487 <listitem><para id="x_5c1">Leading and trailing white space are
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
488 ignored.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
489 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
490 <listitem><para id="x_5c2">Empty lines are skipped.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
491 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
492 <listitem><para id="x_5c3">If a line starts with either of the characters
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
493 <quote><literal>#</literal></quote> or
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
494 <quote><literal>;</literal></quote>, the entire line is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
495 treated as a comment, and skipped as if empty.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
496 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
497 <listitem><para id="x_5c4">A line starts with a keyword. This must start
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
498 with an alphabetic character or underscore, and can
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
499 subsequently contain any alphanumeric character or
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
500 underscore. (In regexp notation, a keyword must match
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
501 <literal>[A-Za-z_][A-Za-z0-9_]*</literal>.)</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
502 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
503 <listitem><para id="x_5c5">The next element must be an
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
504 <quote><literal>=</literal></quote> character, which can
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
505 be preceded or followed by an arbitrary amount of white
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
506 space.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
507 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
508 <listitem><para id="x_5c6">If the rest of the line starts and ends with
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
509 matching quote characters (either single or double quote),
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
510 it is treated as a template body.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
511 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
512 <listitem><para id="x_5c7">If the rest of the line <emphasis>does
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
513 not</emphasis> start with a quote character, it is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
514 treated as the name of a file; the contents of this file
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
515 will be read and used as a template body.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
516 </listitem></itemizedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
517 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
518 </sect1>
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
519
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
520 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
521 <title>Style files by example</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
522
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
523 <para id="x_5c8">To illustrate how to write a style file, we will construct a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
524 few by example. Rather than provide a complete style file and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
525 walk through it, we'll mirror the usual process of developing a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
526 style file by starting with something very simple, and walking
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
527 through a series of successively more complete examples.</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
528
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
529 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
530 <title>Identifying mistakes in style files</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
531
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
532 <para id="x_5c9">If Mercurial encounters a problem in a style file you are
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
533 working on, it prints a terse error message that, once you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
534 figure out what it means, is actually quite useful.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
535
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
536 &interaction.template.svnstyle.syntax.input;
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
537
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
538 <para id="x_5ca">Notice that <filename>broken.style</filename> attempts to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
539 define a <literal>changeset</literal> keyword, but forgets to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
540 give any content for it. When instructed to use this style
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
541 file, Mercurial promptly complains.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
542
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
543 &interaction.template.svnstyle.syntax.error;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
544
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
545 <para id="x_5cb">This error message looks intimidating, but it is not too
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
546 hard to follow.</para>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
547
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
548 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
549 <listitem><para id="x_5cc">The first component is simply Mercurial's way
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
550 of saying <quote>I am giving up</quote>.</para>
680
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
551 <programlisting>___abort___: broken.style:1: parse error</programlisting>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
552 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
553 <listitem><para id="x_5cd">Next comes the name of the style file that
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
554 contains the error.</para>
680
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
555 <programlisting>abort: ___broken.style___:1: parse error</programlisting>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
556 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
557 <listitem><para id="x_5ce">Following the file name is the line number
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
558 where the error was encountered.</para>
680
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
559 <programlisting>abort: broken.style:___1___: parse error</programlisting>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
560 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
561 <listitem><para id="x_5cf">Finally, a description of what went
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
562 wrong.</para>
680
8366882f67f2 Fix up more formatting goop
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
563 <programlisting>abort: broken.style:1: ___parse error___</programlisting>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
564 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
565 <listitem><para id="x_5d0">The description of the problem is not always
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
566 clear (as in this case), but even when it is cryptic, it
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
567 is almost always trivial to visually inspect the offending
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
568 line in the style file and see what is wrong.</para>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
569 </listitem>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
570 </itemizedlist>
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
571 </sect2>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
572
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
573 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
574 <title>Uniquely identifying a repository</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
575
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
576 <para id="x_5d1">If you would like to be able to identify a Mercurial
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
577 repository <quote>fairly uniquely</quote> using a short string
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
578 as an identifier, you can use the first revision in the
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
579 repository.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
580
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
581 &interaction.template.svnstyle.id;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
582
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
583 <para id="x_5d2">This is likely to be unique, and so it is
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
584 useful in many cases. There are a few caveats.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
585 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
586 <listitem><para id="x_5d3">It will not work in a completely empty
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
587 repository, because such a repository does not have a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
588 revision zero.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
589 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
590 <listitem><para id="x_5d4">Neither will it work in the (extremely rare)
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
591 case where a repository is a merge of two or more formerly
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
592 independent repositories, and you still have those
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
593 repositories around.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
594 </listitem></itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
595 <para id="x_5d5">Here are some uses to which you could put this
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
596 identifier:</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
597 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
598 <listitem><para id="x_5d6">As a key into a table for a database that
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
599 manages repositories on a server.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
600 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
601 <listitem><para id="x_5d7">As half of a {<emphasis>repository
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
602 ID</emphasis>, <emphasis>revision ID</emphasis>} tuple.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
603 Save this information away when you run an automated build
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
604 or other activity, so that you can <quote>replay</quote>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
605 the build later if necessary.</para>
823
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
606 </listitem>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
607 </itemizedlist>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
608 </sect2>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
609
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
610 <sect2>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
611 <title>Listing files on multiple lines</title>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
612
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
613 <para id="x_714">Suppose we want to list the files changed by a changeset,
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
614 one per line, with a little indentation before each file
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
615 name.</para>
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
616
9e33729cafae Add a multiline template example.
Bryan O'Sullivan <bos@serpentine.com>
parents: 809
diff changeset
617 &interaction.ch10-multiline.go;
809
ef53d025f410 Mention qdelete and qimport -r.
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
618 </sect2>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
619
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
620 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
621 <title>Mimicking Subversion's output</title>
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
622
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
623 <para id="x_5d8">Let's try to emulate the default output format used by
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
624 another revision control tool, Subversion.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
625
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
626 &interaction.template.svnstyle.short;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
627
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
628 <para id="x_5d9">Since Subversion's output style is fairly simple, it is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
629 easy to copy-and-paste a hunk of its output into a file, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
630 replace the text produced above by Subversion with the
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
631 template values we'd like to see expanded.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
632
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
633 &interaction.template.svnstyle.template;
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
634
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
635 <para id="x_5da">There are a few small ways in which this template deviates
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
636 from the output produced by Subversion.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
637 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
638 <listitem><para id="x_5db">Subversion prints a <quote>readable</quote>
660
21c62e09b99f Typo and spelling corrections. Removed tex tags.
Ori Avtalion <ori@avtalion.name>
parents: 658
diff changeset
639 date (the <quote><literal>Wed, 27 Sep 2006</literal></quote> in the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
640 example output above) in parentheses. Mercurial's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
641 templating engine does not provide a way to display a date
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
642 in this format without also printing the time and time
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
643 zone.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
644 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
645 <listitem><para id="x_5dc">We emulate Subversion's printing of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
646 <quote>separator</quote> lines full of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
647 <quote><literal>-</literal></quote> characters by ending
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
648 the template with such a line. We use the templating
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
649 engine's <literal role="template-keyword">header</literal>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
650 keyword to print a separator line as the first line of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
651 output (see below), thus achieving similar output to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
652 Subversion.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
653 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
654 <listitem><para id="x_5dd">Subversion's output includes a count in the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
655 header of the number of lines in the commit message. We
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
656 cannot replicate this in Mercurial; the templating engine
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
657 does not currently provide a filter that counts the number
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
658 of lines the template generates.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
659 </listitem></itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
660 <para id="x_5de">It took me no more than a minute or two of work to replace
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
661 literal text from an example of Subversion's output with some
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
662 keywords and filters to give the template above. The style
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
663 file simply refers to the template.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
664
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 660
diff changeset
665 &interaction.template.svnstyle.style;
83
b476081a9c04 Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents: 80
diff changeset
666
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
667 <para id="x_5df">We could have included the text of the template file
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
668 directly in the style file by enclosing it in quotes and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
669 replacing the newlines with
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
670 <quote><literal>\n</literal></quote> sequences, but it would
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
671 have made the style file too difficult to read. Readability
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
672 is a good guide when you're trying to decide whether some text
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
673 belongs in a style file, or in a template file that the style
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
674 file points to. If the style file will look too big or
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
675 cluttered if you insert a literal piece of text, drop it into
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
676 a template instead.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
677 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
678 </sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
679 </chapter>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
680
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
681 <!--
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
682 local variables:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
683 sgml-parent-document: ("00book.xml" "book" "chapter")
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
684 end:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 649
diff changeset
685 -->