hgbook

changeset 696:9e33729cafae

Add a multiline template example.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue Apr 28 23:33:11 2009 -0700 (2009-04-28)
parents fd2e83ffb165
children c8d662d3cb40
files en/ch10-template.xml en/examples/auto-snippets.xml en/examples/ch10/multiline
line diff
     1.1 --- a/en/ch10-template.xml	Tue Apr 28 23:14:14 2009 -0700
     1.2 +++ b/en/ch10-template.xml	Tue Apr 28 23:33:11 2009 -0700
     1.3 @@ -2,12 +2,12 @@
     1.4  
     1.5  <chapter id="chap:template">
     1.6    <?dbhtml filename="customizing-the-output-of-mercurial.html"?>
     1.7 -  <title>Customising the output of Mercurial</title>
     1.8 +  <title>Customizing the output of Mercurial</title>
     1.9  
    1.10    <para id="x_578">Mercurial provides a powerful mechanism to let you control how
    1.11      it displays information.  The mechanism is based on templates.
    1.12      You can use templates to generate specific output for a single
    1.13 -    command, or to customise the entire appearance of the built-in web
    1.14 +    command, or to customize the entire appearance of the built-in web
    1.15      interface.</para>
    1.16  
    1.17    <sect1 id="sec:style">
    1.18 @@ -71,11 +71,11 @@
    1.19  
    1.20      <para id="x_581">As I write this manual, these are so far the only commands
    1.21        that support styles and templates.  Since these are the most
    1.22 -      important commands that need customisable output, there has been
    1.23 +      important commands that need customizable output, there has been
    1.24        little pressure from the Mercurial user community to add style
    1.25        and template support to other commands.</para>
    1.26 -
    1.27 -  </sect1>
    1.28 +  </sect1>
    1.29 +
    1.30    <sect1>
    1.31      <title>The basics of templating</title>
    1.32  
    1.33 @@ -186,12 +186,13 @@
    1.34        <listitem><para id="x_594"><literal role="template-keyword">tags</literal>:
    1.35  	  List of strings.  Any tags associated with the
    1.36  	  changeset.</para>
    1.37 -      </listitem></itemizedlist>
    1.38 +      </listitem>
    1.39 +    </itemizedlist>
    1.40  
    1.41      <para id="x_595">A few simple experiments will show us what to expect when we
    1.42        use these keywords; you can see the results below.</para>
    1.43  
    1.44 -&interaction.template.simple.keywords;
    1.45 +    &interaction.template.simple.keywords;
    1.46  
    1.47      <para id="x_596">As we noted above, the date keyword does not produce
    1.48        human-readable output, so we must treat it specially.  This
    1.49 @@ -227,11 +228,11 @@
    1.50        <listitem><para id="x_59c"><literal>\v</literal>: Vertical
    1.51  	  tab, ASCII 13.</para>
    1.52        </listitem>
    1.53 -      <listitem><para id="x_59d"><literal>{</literal>: Open curly
    1.54 +      <listitem><para id="x_59d"><literal>\{</literal>: Open curly
    1.55  	  brace, <quote><literal>{</literal></quote>, ASCII
    1.56  	  173.</para>
    1.57        </listitem>
    1.58 -      <listitem><para id="x_59e"><literal>}</literal>: Close curly
    1.59 +      <listitem><para id="x_59e"><literal>\}</literal>: Close curly
    1.60  	  brace, <quote><literal>}</literal></quote>, ASCII
    1.61  	  175.</para>
    1.62        </listitem></itemizedlist>
    1.63 @@ -408,7 +409,8 @@
    1.64  	  example, <quote><literal>Bryan O'Sullivan
    1.65  	      &lt;bos@serpentine.com&gt;</literal></quote> becomes
    1.66  	  <quote><literal>bos</literal></quote>.</para>
    1.67 -      </listitem></itemizedlist>
    1.68 +      </listitem>
    1.69 +    </itemizedlist>
    1.70  
    1.71      &interaction.template.simple.manyfilters;
    1.72  
    1.73 @@ -471,8 +473,8 @@
    1.74        <para id="x_5be">This tells Mercurial, <quote>if you're printing a
    1.75  	  changeset, use the text on the right as the
    1.76  	  template</quote>.</para>
    1.77 -
    1.78 -    </sect2>
    1.79 +    </sect2>
    1.80 +
    1.81      <sect2>
    1.82        <title>Style file syntax</title>
    1.83  
    1.84 @@ -564,7 +566,8 @@
    1.85  	    clear (as in this case), but even when it is cryptic, it
    1.86  	    is almost always trivial to visually inspect the offending
    1.87  	    line in the style file and see what is wrong.</para>
    1.88 -	</listitem></itemizedlist>
    1.89 +	</listitem>
    1.90 +      </itemizedlist>
    1.91      </sect2>
    1.92  
    1.93      <sect2>
    1.94 @@ -577,8 +580,8 @@
    1.95  
    1.96        &interaction.template.svnstyle.id;
    1.97  
    1.98 -      <para id="x_5d2">This is not guaranteed to be unique, but it is
    1.99 -	nevertheless useful in many cases.</para>
   1.100 +      <para id="x_5d2">This is likely to be unique, and so it is
   1.101 +	useful in many cases.  There are a few caveats.</para>
   1.102        <itemizedlist>
   1.103  	<listitem><para id="x_5d3">It will not work in a completely empty
   1.104  	    repository, because such a repository does not have a
   1.105 @@ -600,7 +603,18 @@
   1.106  	    Save this information away when you run an automated build
   1.107  	    or other activity, so that you can <quote>replay</quote>
   1.108  	    the build later if necessary.</para>
   1.109 -	</listitem></itemizedlist>
   1.110 +	</listitem>
   1.111 +      </itemizedlist>
   1.112 +    </sect2>
   1.113 +
   1.114 +    <sect2>
   1.115 +      <title>Listing files on multiple lines</title>
   1.116 +
   1.117 +      <para id="x_714">Suppose we want to list the files changed by a changeset,
   1.118 +	one per line, with a little indentation before each file
   1.119 +	name.</para>
   1.120 +
   1.121 +      &interaction.ch10-multiline.go;
   1.122      </sect2>
   1.123  
   1.124      <sect2>
     2.1 --- a/en/examples/auto-snippets.xml	Tue Apr 28 23:14:14 2009 -0700
     2.2 +++ b/en/examples/auto-snippets.xml	Tue Apr 28 23:33:11 2009 -0700
     2.3 @@ -68,6 +68,7 @@
     2.4  <!ENTITY interaction.ch04-resolve.right SYSTEM "results/ch04-resolve.right.lxo">
     2.5  <!ENTITY interaction.ch09-hook.ws.better SYSTEM "results/ch09-hook.ws.better.lxo">
     2.6  <!ENTITY interaction.ch09-hook.ws.simple SYSTEM "results/ch09-hook.ws.simple.lxo">
     2.7 +<!ENTITY interaction.ch10-multiline.go SYSTEM "results/ch10-multiline.go.lxo">
     2.8  <!ENTITY interaction.ch11-qdelete.convert SYSTEM "results/ch11-qdelete.convert.lxo">
     2.9  <!ENTITY interaction.ch11-qdelete.go SYSTEM "results/ch11-qdelete.go.lxo">
    2.10  <!ENTITY interaction.ch11-qdelete.import SYSTEM "results/ch11-qdelete.import.lxo">
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/en/examples/ch10/multiline	Tue Apr 28 23:33:11 2009 -0700
     3.3 @@ -0,0 +1,13 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +hg init
     3.7 +echo a > test.c
     3.8 +hg ci -Am'First commit'
     3.9 +
    3.10 +#$ name: go
    3.11 +
    3.12 +cat > multiline << EOF
    3.13 +changeset = "Changed in {node|short}:\n{files}"
    3.14 +file = "  {file}\n"
    3.15 +EOF
    3.16 +hg log --style multiline