Mercurial > hgbook
annotate en/ch11-template.xml @ 743:3b864df20e3b
Update Chinese translation
author | Dongsheng Song <dongsheng.song@gmail.com> |
---|---|
date | Wed, 18 Mar 2009 18:13:05 +0800 |
parents | cfdb601a3c8b |
children | d0160b0b1a9e |
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 |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
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"?> |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
5 <title>Customising the output of Mercurial</title> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
6 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
7 <para>Mercurial provides a powerful mechanism to let you control how |
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 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
10 command, or to customise the entire appearance of the built-in web |
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 |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
13 <sect1 id="sec.style"> |
658
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
16 <para>Packaged with Mercurial are some output styles that you can |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
21 <para>Before we take a look at Mercurial's bundled styles, let's |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
26 <para>This is somewhat informative, but it takes up a lot of |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
33 <para>The <literal>changelog</literal> style hints at the |
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 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
40 <para>You will not be shocked to learn that Mercurial's default |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
46 <para>You can modify the output style that Mercurial will use |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
47 for every command by editing your <filename role="special"> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
48 /.hgrc</filename>\ file, naming the style you would prefer |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
49 to use.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
50 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
51 <programlisting>[ui] style = compact</programlisting> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
52 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
53 <para>If you write a style of your own, you can use it by either |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 Mercurial install directory).</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
58 |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
61 <sect1> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
62 <title>Commands that support styles and templates</title> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
63 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
64 <para>All of Mercurial's |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
65 <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
|
66 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
|
67 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
|
68 <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
|
69 role="hg-cmd">hg tip</command>.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
70 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
71 <para>As I write this manual, these are so far the only commands |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
72 that support styles and templates. Since these are the most |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
73 important commands that need customisable output, there has been |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
74 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
|
75 and template support to other commands.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
76 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
77 </sect1> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
78 <sect1> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
79 <title>The basics of templating</title> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
80 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
81 <para>At its simplest, a Mercurial template is a piece of text. |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
82 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
|
83 <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
|
84 necessary.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
85 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
86 <para>Before we continue, let's look again at a simple example of |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
87 Mercurial's normal output.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
88 |
666
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
89 &interaction.template.simple.normal; |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
90 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
91 <para>Now, let's run the same command, but using a template to |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
92 change its output.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
93 |
666
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
94 &interaction.template.simple.simplest; |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
95 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
96 <para>The example above illustrates the simplest possible |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
97 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
|
98 each changeset. The <option |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 changeset.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
103 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
104 <para>Notice that the template string above ends with the text |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
105 <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
|
106 <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
|
107 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
|
108 newline, Mercurial will run each piece of output together. See |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
109 section <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
|
110 of escape sequences.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
111 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
112 <para>A template that prints a fixed string of text all the time |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
113 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
|
114 complex.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
115 |
666
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
116 &interaction.template.simple.simplesub; |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
117 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
118 <para>As you can see, the string |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
119 <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
|
120 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
|
121 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
|
122 braces (<quote><literal>{</literal></quote> and |
660
21c62e09b99f
Typo and spelling corrections. Removed tex tags.
Ori Avtalion <ori@avtalion.name>
parents:
658
diff
changeset
|
123 <quote><literal>}</literal></quote>), it will try to replace the braces |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
124 and text with the expansion of whatever is inside. To print a |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
125 literal curly brace, you must escape it, as described in section |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
126 <xref |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
127 linkend="sec.template.escape"/>.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
128 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
129 </sect1> |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
130 <sect1 id="sec.template.keyword"> |
658
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
133 <para>You can start writing simple templates immediately using the |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
137 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
141 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
147 <listitem><para><literal role="template-keyword">date</literal>: |
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 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
151 appropriately. See section <xref |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
152 linkend="sec.template.filter"/> for more information |
658
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
158 <listitem><para><literal role="template-keyword">desc</literal>: |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
161 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
166 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
170 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
174 <listitem><para><literal role="template-keyword">node</literal>: |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
178 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
182 <listitem><para><literal role="template-keyword">rev</literal>: |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
186 <listitem><para><literal role="template-keyword">tags</literal>: |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
189 </listitem></itemizedlist> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
190 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
191 <para>A few simple experiments will show us what to expect when we |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
192 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
|
193 |
666
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
194 &interaction.template.simple.keywords; |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
195 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
196 <para>As we noted above, the date keyword does not produce |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
197 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
|
198 involves using a <emphasis>filter</emphasis>, about which more |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
199 in section <xref |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
200 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; |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
203 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
204 </sect1> |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
205 <sect1 id="sec.template.escape"> |
658
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 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
208 <para>Mercurial's templating engine recognises the most commonly |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
215 <listitem><para><literal>\textbackslash\textbackslash</literal>: |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
219 <listitem><para><literal>\textbackslash n</literal>: Newline, |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
222 <listitem><para><literal>\textbackslash r</literal>: Carriage |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
225 <listitem><para><literal>\textbackslash t</literal>: Tab, ASCII |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
228 <listitem><para><literal>\textbackslash v</literal>: Vertical |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
231 <listitem><para><literal>\textbackslash {</literal>: Open curly |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
235 <listitem><para><literal>\textbackslash }</literal>: Close curly |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
240 <para>As indicated above, if you want the expansion of a template |
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> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
245 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
246 </sect1> |
724
cfdb601a3c8b
Fix imagedata fileref in xml files, and replace ':' with '.' in id attribute
Dongsheng Song <dongsheng.song@gmail.com>
parents:
671
diff
changeset
|
247 <sect1 id="sec.template.filter"> |
658
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
250 <para>Some of the results of template expansion are not |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
257 <para>Below is a list of the most commonly used filters that |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
264 <listitem><para><literal |
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><br/></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<br/>\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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
271 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
278 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
287 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
295 <listitem><para><literal |
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 <bos@serpentine.com></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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
305 <listitem><para><literal |
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 <bos@serpentine.com></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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
314 <listitem><para><literal |
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>&</literal></quote>, |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
318 <quote><literal><</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>></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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
322 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
330 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
334 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
339 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
346 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
353 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
361 <listitem><para><literal |
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 <bos@serpentine.com></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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
370 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
377 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
382 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
388 <listitem><para><literal role="template-filter">strip</literal>: |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
392 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
397 <listitem><para><literal |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
404 <listitem><para><literal |
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 <bos@serpentine.com></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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
412 </listitem></itemizedlist> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
413 |
666
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
414 &interaction.template.simple.manyfilters; |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
415 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
416 <note> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
417 <para> If you try to apply a filter to a piece of data that it |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
418 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
|
419 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
|
420 <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
|
421 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
|
422 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
|
423 </note> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
424 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
425 <sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
426 <title>Combining filters</title> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
427 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
428 <para>It is easy to combine filters to yield output in the form |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
429 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
|
430 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
|
431 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
|
432 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
|
433 characters wide).</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
434 |
666
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
435 &interaction.template.simple.combine; |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
436 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
437 <para>Note the use of <quote><literal>\t</literal></quote> (a |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
438 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
|
439 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
|
440 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
|
441 lines <emphasis>except</emphasis> the first.</para> |
80
ea951cfb5cd9
Much template-related content.
Bryan O'Sullivan <bos@serpentine.com>
parents:
76
diff
changeset
|
442 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
443 <para>Keep in mind that the order of filters in a chain is |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
444 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
|
445 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
|
446 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
|
447 gives very different results from |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
448 <literal>tabindent|fill68</literal>.</para> |
76
df88df78288d
Add template chapter to build.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
449 |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
450 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
451 </sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
452 </sect1> |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
456 <para>A command line template provides a quick and simple way to |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
461 <para>More than that, using a style file unlocks the power of |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
469 <para>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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
473 <para>This tells Mercurial, <quote>if you're printing a |
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> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
476 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
477 </sect2> |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
481 <para>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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
484 <listitem><para>The file is processed one line at a |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
487 <listitem><para>Leading and trailing white space are |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
490 <listitem><para>Empty lines are skipped.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
491 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
492 <listitem><para>If a line starts with either of the characters |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
497 <listitem><para>A line starts with a keyword. This must start |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
503 <listitem><para>The next element must be an |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
508 <listitem><para>If the rest of the line starts and ends with |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
512 <listitem><para>If the rest of the line <emphasis>does |
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> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
517 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
518 </sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
519 </sect1> |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
523 <para>To illustrate how to write a style file, we will construct a |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
532 <para>If Mercurial encounters a problem in a style file you are |
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 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
538 <para>Notice that <filename>broken.style</filename> attempts to |
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 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
545 <para>This error message looks intimidating, but it is not too |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
549 <listitem><para>The first component is simply Mercurial's way |
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> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
551 <programlisting>___abort___: broken.style:1: parse |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
552 error</programlisting> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
553 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
554 <listitem><para>Next comes the name of the style file that |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
555 contains the error.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
556 <programlisting> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
557 abort: ___broken.style___:1: parse error |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
558 </programlisting> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
559 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
560 <listitem><para>Following the file name is the line number |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
561 where the error was encountered.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
562 <programlisting>abort: broken.style:___1___: parse |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
563 error</programlisting> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
564 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
565 <listitem><para>Finally, a description of what went |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
566 wrong.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
567 <programlisting>abort: broken.style:1: ___parse |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
568 error___</programlisting> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
569 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
570 <listitem><para>The description of the problem is not always |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
571 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
|
572 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
|
573 line in the style file and see what is wrong.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
574 </listitem></itemizedlist> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
575 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
576 </sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
577 <sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
578 <title>Uniquely identifying a repository</title> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
579 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
580 <para>If you would like to be able to identify a Mercurial |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
581 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
|
582 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
|
583 repository.</para> |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
584 |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
585 &interaction.template.svnstyle.id; |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
586 |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
587 <para>This is not guaranteed to be unique, but it is |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
588 nevertheless useful in many cases.</para> |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
589 <itemizedlist> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
590 <listitem><para>It will not work in a completely empty |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
591 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
|
592 revision zero.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
593 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
594 <listitem><para>Neither will it work in the (extremely rare) |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
595 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
|
596 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
|
597 repositories around.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
598 </listitem></itemizedlist> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
599 <para>Here are some uses to which you could put this |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
600 identifier:</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
601 <itemizedlist> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
602 <listitem><para>As a key into a table for a database that |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
603 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
|
604 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
605 <listitem><para>As half of a {<emphasis>repository |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 the build later if necessary.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
610 </listitem></itemizedlist> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
611 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
612 </sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
613 <sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
614 <title>Mimicking Subversion's output</title> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
615 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
616 <para>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
|
617 another revision control tool, Subversion.</para> |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
618 |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
619 &interaction.template.svnstyle.short; |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
620 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
621 <para>Since Subversion's output style is fairly simple, it is |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
622 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
|
623 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
|
624 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
|
625 |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
626 &interaction.template.svnstyle.template; |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
627 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
628 <para>There are a few small ways in which this template deviates |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
629 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
|
630 <itemizedlist> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
631 <listitem><para>Subversion prints a <quote>readable</quote> |
660
21c62e09b99f
Typo and spelling corrections. Removed tex tags.
Ori Avtalion <ori@avtalion.name>
parents:
658
diff
changeset
|
632 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
|
633 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
|
634 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
|
635 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
|
636 zone.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
637 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
638 <listitem><para>We emulate Subversion's printing of |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
639 <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
|
640 <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
|
641 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
|
642 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
|
643 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
|
644 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
|
645 Subversion.</para> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
646 </listitem> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
647 <listitem><para>Subversion's output includes a count in the |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 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
|
652 </listitem></itemizedlist> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
653 <para>It took me no more than a minute or two of work to replace |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
654 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
|
655 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
|
656 file simply refers to the template.</para> |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
657 |
8fcd44708f41
Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents:
660
diff
changeset
|
658 &interaction.template.svnstyle.style; |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
659 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
660 <para>We could have included the text of the template file |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
661 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
|
662 replacing the newlines with |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
663 <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
|
664 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
|
665 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
|
666 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
|
667 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
|
668 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
|
669 a template instead.</para> |
83
b476081a9c04
Much progress in template chapter.
Bryan O'Sullivan <bos@serpentine.com>
parents:
80
diff
changeset
|
670 |
658
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
671 </sect2> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
672 </sect1> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
673 </chapter> |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
674 |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
675 <!-- |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
676 local variables: |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
677 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
|
678 end: |
b90b024729f1
WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
649
diff
changeset
|
679 --> |