hgbook

changeset 647:d0160b0b1a9e

Merge with http://hg.serpentine.com/mercurial/book
author Dongsheng Song <dongsheng.song@gmail.com>
date Wed Mar 18 20:32:37 2009 +0800 (2009-03-18)
parents c2cefd9f9893 5bfa0df6aaed
children e0ac2341a861
files en/Makefile en/appB-mq-ref.xml en/ch00-preface.xml en/ch02-tour-basic.xml en/ch03-tour-merge.xml en/ch06-collab.xml en/ch08-branch.xml en/ch10-hook.xml en/ch11-template.xml en/ch12-mq.xml en/ch13-mq-collab.xml en/ch14-hgext.xml
line diff
     1.1 --- a/en/Makefile	Wed Mar 18 19:50:36 2009 +0800
     1.2 +++ b/en/Makefile	Wed Mar 18 20:32:37 2009 +0800
     1.3 @@ -35,7 +35,7 @@
     1.4  
     1.5  image-html := $(image-dot:%.dot=%.png) $(image-svg:%.svg=%.png) $(image-png)
     1.6  
     1.7 -example-sources := \
     1.8 +example-sources-by-name := \
     1.9  	backout \
    1.10  	bisect \
    1.11  	branching \
    1.12 @@ -67,6 +67,10 @@
    1.13  	tour \
    1.14  	tour-merge-conflict
    1.15  
    1.16 +example-sources := \
    1.17 +	$(example-sources-by-name:%=examples/%) \
    1.18 +	$(wildcard examples/ch*/*)
    1.19 +
    1.20  obj-web := html
    1.21  obj-websup := html/support
    1.22  
    1.23 @@ -162,11 +166,10 @@
    1.24  
    1.25  examples: $(example-prereqs) examples/.run
    1.26  
    1.27 -examples/.run: $(example-sources:%=examples/%.run)
    1.28 -	touch examples/.run
    1.29 +examples/.run: $(example-sources)
    1.30 +	cd examples && ./run-example
    1.31  
    1.32  examples/%.run: examples/% examples/run-example
    1.33 -	cd examples && ./run-example $(notdir $<)
    1.34  
    1.35  clean:
    1.36  	-rm -rf dist html $(image-dot:%.dot=%.pdf) $(image-dot:%.dot=%.png) \
     2.1 --- a/en/appB-mq-ref.xml	Wed Mar 18 19:50:36 2009 +0800
     2.2 +++ b/en/appB-mq-ref.xml	Wed Mar 18 20:32:37 2009 +0800
     2.3 @@ -38,11 +38,12 @@
     2.4  
     2.5        <para>This command is shorthand for <command role="hg-cmd">hg
     2.6  	  commit --cwd .hg/patches</command>.</para>
     2.7 -
     2.8 -      <para>\subsection{<command
     2.9 +    </sect2>
    2.10 +    <sect2>
    2.11 +	<title><command
    2.12  	  role="hg-ext-mq">qdelete</command>&emdash;delete a patch
    2.13  	from the <filename role="special">series</filename>
    2.14 -	file}</para>
    2.15 +	file}</title>
    2.16  
    2.17        <para>The <command role="hg-ext-mq">qdelete</command> command
    2.18  	removes the entry for a patch from the <filename
     3.1 --- a/en/ch00-preface.xml	Wed Mar 18 19:50:36 2009 +0800
     3.2 +++ b/en/ch00-preface.xml	Wed Mar 18 20:32:37 2009 +0800
     3.3 @@ -64,7 +64,7 @@
     3.4  
     3.5      <para>This book is licensed under the Open Publication License,
     3.6        and is produced entirely using Free Software tools.  It is
     3.7 -      typeset with \LaTeX{}; illustrations are drawn and rendered with
     3.8 +      typeset with DocBook XML.  Illustrations are drawn and rendered with
     3.9        <ulink url="http://www.inkscape.org/">Inkscape</ulink>.</para>
    3.10  
    3.11      <para>The complete source code for this book is published as a
     4.1 --- a/en/ch02-tour-basic.xml	Wed Mar 18 19:50:36 2009 +0800
     4.2 +++ b/en/ch02-tour-basic.xml	Wed Mar 18 20:32:37 2009 +0800
     4.3 @@ -551,7 +551,8 @@
     4.4  	    <filename role="special">.hgrc</filename> should look like
     4.5  	    this.</para>
     4.6  	<programlisting># This is a Mercurial configuration file.
     4.7 -[ui] username = Firstname Lastname
     4.8 +[ui]
     4.9 +username = Firstname Lastname
    4.10  &lt;email.address@domain.net&gt;</programlisting>
    4.11  
    4.12  	<para>The <quote><literal>[ui]</literal></quote> line begins a
    4.13 @@ -623,8 +624,8 @@
    4.14  
    4.15        <programlisting>
    4.16  changeset:   73:584af0e231be
    4.17 -user: Censored Person &lt;censored.person@example.org&gt;
    4.18 -date: Tue Sep 26 21:37:07 2006 -0700
    4.19 +user:        Censored Person &lt;censored.person@example.org&gt;
    4.20 +date:        Tue Sep 26 21:37:07 2006 -0700
    4.21  summary:     include buildmeister/commondefs. Add exports.</programlisting>
    4.22  
    4.23        <para>As far as the remainder of the contents of the
     5.1 --- a/en/ch03-tour-merge.xml	Wed Mar 18 19:50:36 2009 +0800
     5.2 +++ b/en/ch03-tour-merge.xml	Wed Mar 18 20:32:37 2009 +0800
     5.3 @@ -344,9 +344,9 @@
     5.4      <para>The process of merging changes as outlined above is
     5.5        straightforward, but requires running three commands in
     5.6        sequence.</para>
     5.7 -    <programlisting>
     5.8 -      hg pull hg merge hg commit -m 'Merged remote changes'
     5.9 -    </programlisting>
    5.10 +    <programlisting>hg pull
    5.11 +hg merge
    5.12 +hg commit -m 'Merged remote changes'</programlisting>
    5.13      <para>In the case of the final commit, you also need to enter a
    5.14        commit message, which is almost always going to be a piece of
    5.15        uninteresting <quote>boilerplate</quote> text.</para>
    5.16 @@ -383,9 +383,8 @@
    5.17        <literal role="rc-extensions">extensions</literal> section. Then
    5.18        add a line that simply reads <quote><literal>fetch
    5.19  	</literal></quote>.</para>
    5.20 -    <programlisting>
    5.21 -      [extensions] fetch =
    5.22 -    </programlisting>
    5.23 +    <programlisting>[extensions]
    5.24 +fetch =</programlisting>
    5.25      <para>(Normally, on the right-hand side of the
    5.26        <quote><literal>=</literal></quote> would appear the location of
    5.27        the extension, but since the <literal
     6.1 --- a/en/ch06-collab.xml	Wed Mar 18 19:50:36 2009 +0800
     6.2 +++ b/en/ch06-collab.xml	Wed Mar 18 20:32:37 2009 +0800
     6.3 @@ -539,8 +539,8 @@
     6.4  	</listitem>
     6.5  	<listitem><para>The <quote>:22</quote> identifies the port
     6.6  	    number to connect to the server on.  The default port is
     6.7 -	    22, so you only need to specify this part if you're
     6.8 -	    <emphasis>not</emphasis> using port 22.</para>
     6.9 +	    22, so you only need to specify a colon and port number if
    6.10 +	    you're <emphasis>not</emphasis> using port 22.</para>
    6.11  	</listitem>
    6.12  	<listitem><para>The remainder of the URL is the local path to
    6.13  	    the repository on the server.</para>
    6.14 @@ -595,19 +595,20 @@
    6.15  	<listitem><para>If you have a high tolerance for pain, you can
    6.16  	    use the Cygwin port of OpenSSH.</para>
    6.17  	</listitem></itemizedlist>
    6.18 -      <para>In either case, you'll need to edit your \hgini\ file to
    6.19 +      <para>In either case, you'll need to edit your <filename
    6.20 +      role="special">hg.ini</filename> file to
    6.21  	tell Mercurial where to find the actual client command.  For
    6.22  	example, if you're using PuTTY, you'll need to use the
    6.23  	<command>plink</command> command as a command-line ssh
    6.24  	client.</para>
    6.25 -      <programlisting>[ui] ssh = C:/path/to/plink.exe -ssh -i
    6.26 -	"C:/path/to/my/private/key"</programlisting>
    6.27 +      <programlisting>[ui]
    6.28 +ssh = C:/path/to/plink.exe -ssh -i "C:/path/to/my/private/key"</programlisting>
    6.29  
    6.30        <note>
    6.31  	<para>  The path to <command>plink</command> shouldn't contain
    6.32  	  any whitespace characters, or Mercurial may not be able to
    6.33  	  run it correctly (so putting it in <filename
    6.34 -	    class="directory">C:\\Program Files</filename> is probably
    6.35 +	    class="directory">C:\Program Files</filename> is probably
    6.36  	  not a good idea).</para>
    6.37        </note>
    6.38  
    6.39 @@ -784,7 +785,9 @@
    6.40  	your server, the next step is to ensure that Mercurial runs on
    6.41  	the server.  The following command should run
    6.42  	successfully:</para>
    6.43 +
    6.44        <programlisting>ssh myserver hg version</programlisting>
    6.45 +
    6.46        <para>If you see an error message instead of normal <command
    6.47  	  role="hg-cmd">hg version</command> output, this is usually
    6.48  	because you haven't installed Mercurial to <filename
    6.49 @@ -841,17 +844,19 @@
    6.50        <para>Both <command>ssh</command> and <command>plink</command>
    6.51  	accept a <option role="cmd-opt-ssh">-C</option> option which
    6.52  	turns on compression.  You can easily edit your <filename
    6.53 -	  role="special"> /.hgrc</filename>\ to enable compression for
    6.54 +	  role="special">~/.hgrc</filename> to enable compression for
    6.55  	all of Mercurial's uses of the ssh protocol.</para>
    6.56 -      <programlisting>[ui] ssh = ssh -C</programlisting>
    6.57 +      <programlisting>[ui]
    6.58 +ssh = ssh -C</programlisting>
    6.59  
    6.60        <para>If you use <command>ssh</command>, you can configure it to
    6.61  	always use compression when talking to your server.  To do
    6.62  	this, edit your <filename
    6.63  	  role="special">.ssh/config</filename> file (which may not
    6.64  	yet exist), as follows.</para>
    6.65 -      <programlisting>Host hg Compression yes HostName
    6.66 -	hg.example.com</programlisting>
    6.67 +      <programlisting>Host hg
    6.68 +  Compression yes
    6.69 +  HostName hg.example.com</programlisting>
    6.70        <para>This defines an alias, <literal>hg</literal>.  When you
    6.71  	use it on the <command>ssh</command> command line or in a
    6.72  	Mercurial <literal>ssh</literal>-protocol URL, it will cause
    6.73 @@ -926,8 +931,7 @@
    6.74  	directory, from which they can serve up web pages.  A file
    6.75  	named <filename>foo</filename> in this directory will be
    6.76  	accessible at a URL of the form
    6.77 -	<literal>http://www.example.com/\
    6.78 -	  {</literal>username/foo}.</para>
    6.79 +	<literal>http://www.example.com/username/foo</literal>.</para>
    6.80  
    6.81        <para>To get started, find the <filename
    6.82  	  role="special">hgweb.cgi</filename> script that should be
    6.83 @@ -939,8 +943,8 @@
    6.84        <para>You'll need to copy this script into your <filename
    6.85  	  class="directory">public_html</filename> directory, and
    6.86  	ensure that it's executable.</para>
    6.87 -      <programlisting>cp .../hgweb.cgi ~/public_html chmod 755
    6.88 -	~/public_html/hgweb.cgi</programlisting>
    6.89 +      <programlisting>cp .../hgweb.cgi ~/public_html
    6.90 +chmod 755 ~/public_html/hgweb.cgi</programlisting>
    6.91        <para>The <literal>755</literal> argument to
    6.92  	<command>chmod</command> is a little more general than just
    6.93  	making the script executable: it ensures that the script is
    6.94 @@ -989,9 +993,9 @@
    6.95  	    class="directory">public_html</filename> directory, and
    6.96  	  read files under the latter too.  Here's a quick recipe to
    6.97  	  help you to make your permissions more appropriate.</para>
    6.98 -	<programlisting>chmod 755 ~ find ~/public_html -type d -print0
    6.99 -	  | xargs -0r chmod 755 find ~/public_html -type f -print0 |
   6.100 -	  xargs -0r chmod 644</programlisting>
   6.101 +	<programlisting>chmod 755 ~
   6.102 +find ~/public_html -type d -print0 | xargs -0r chmod 755
   6.103 +find ~/public_html -type f -print0 | xargs -0r chmod 644</programlisting>
   6.104  
   6.105  	<para>The other possibility with permissions is that you might
   6.106  	  get a completely empty window when you try to load the
   6.107 @@ -1004,13 +1008,9 @@
   6.108  	  of CGI programs in your per-user web directory.  Here's
   6.109  	  Apache's default per-user configuration from my Fedora
   6.110  	  system.</para>
   6.111 -	<programlisting>&lt;Directory /home/*/public_html&gt;
   6.112 -	  AllowOverride FileInfo AuthConfig Limit Options MultiViews
   6.113 -	  Indexes SymLinksIfOwnerMatch IncludesNoExec &lt;Limit GET
   6.114 -	  POST OPTIONS&gt; Order allow,deny Allow from all
   6.115 -	  &lt;/Limit&gt; &lt;LimitExcept GET POST OPTIONS&gt; Order
   6.116 -	  deny,allow Deny from all &lt;/LimitExcept&gt;
   6.117 -	  &lt;/Directory&gt;</programlisting>
   6.118 +
   6.119 +	&ch06-apache-config.lst;
   6.120 +
   6.121  	<para>If you find a similar-looking
   6.122  	  <literal>Directory</literal> group in your Apache
   6.123  	  configuration, the directive to look at inside it is
   6.124 @@ -1076,8 +1076,8 @@
   6.125  	  <literal>mod_userdir</literal>, both of which were disabled
   6.126  	  by default on my system.  I then added a few lines to the
   6.127  	  end of the config file, to configure these modules.</para>
   6.128 -	<programlisting>userdir.path = "public_html" cgi.assign = (
   6.129 -	  ".cgi" =&gt; "" )</programlisting>
   6.130 +	<programlisting>userdir.path = "public_html"
   6.131 +cgi.assign = (".cgi" =&gt; "" )</programlisting>
   6.132  	<para>With this done, <literal>lighttpd</literal> ran
   6.133  	  immediately for me.  If I had configured
   6.134  	  <literal>lighttpd</literal> before Apache, I'd almost
   6.135 @@ -1112,8 +1112,8 @@
   6.136        <para>You'll need to copy this script into your <filename
   6.137  	  class="directory">public_html</filename> directory, and
   6.138  	ensure that it's executable.</para>
   6.139 -      <programlisting>cp .../hgwebdir.cgi ~/public_html chmod 755
   6.140 -	~/public_html ~/public_html/hgwebdir.cgi</programlisting>
   6.141 +      <programlisting>cp .../hgwebdir.cgi ~/public_html
   6.142 +chmod 755 ~/public_html ~/public_html/hgwebdir.cgi</programlisting>
   6.143        <para>With basic configuration out of the way, try to visit
   6.144  	<ulink url="http://myhostname/
   6.145  	  myuser/hgwebdir.cgi">http://myhostname/
   6.146 @@ -1139,8 +1139,8 @@
   6.147  	publish <emphasis>every</emphasis> repository under the
   6.148  	directories you name.  The section should look like
   6.149  	this:</para>
   6.150 -      <programlisting>[collections] /my/root =
   6.151 -	/my/root</programlisting>
   6.152 +      <programlisting>[collections]
   6.153 +/my/root = /my/root</programlisting>
   6.154        <para>Mercurial interprets this by looking at the directory name
   6.155  	on the <emphasis>right</emphasis> hand side of the
   6.156  	<quote><literal>=</literal></quote> sign; finding repositories
   6.157 @@ -1199,8 +1199,9 @@
   6.158  	  to publish a specific list of repositories.  To do so,
   6.159  	  create a <literal>paths</literal> section, with contents of
   6.160  	  the following form.</para>
   6.161 -	<programlisting>[paths] repo1 = /my/path/to/some/repo repo2 =
   6.162 -	  /some/path/to/another</programlisting>
   6.163 +	<programlisting>[paths]
   6.164 +repo1 = /my/path/to/some/repo
   6.165 +repo2 = /some/path/to/another</programlisting>
   6.166  	<para>In this case, the virtual path (the component that will
   6.167  	  appear in a URL) is on the left hand side of each
   6.168  	  definition, while the path to the repository is on the
   6.169 @@ -1234,7 +1235,7 @@
   6.170  	you'll need to add an <envar
   6.171  	  role="rc-item-web">allow_archive</envar> item to the
   6.172  	<literal role="rc-web">web</literal> section of your <filename
   6.173 -	  role="special"> /.hgrc</filename>.</para>
   6.174 +	  role="special">~/.hgrc</filename>.</para>
   6.175  
   6.176      </sect2>
   6.177      <sect2>
   6.178 @@ -1277,8 +1278,8 @@
   6.179  	    <envar role="rc-item-web">allow_archive</envar> entry at
   6.180  	    all, this feature will be disabled.  Here is an example of
   6.181  	    how to enable all three supported formats.</para>
   6.182 -	  <programlisting>[web] allow_archive = bz2 gz
   6.183 -	    zip</programlisting>
   6.184 +	  <programlisting>[web]
   6.185 +allow_archive = bz2 gz zip</programlisting>
   6.186  	</listitem>
   6.187  	<listitem><para><envar role="rc-item-web">allowpull</envar>:
   6.188  	    Boolean.  Determines whether the web interface allows
   6.189 @@ -1296,9 +1297,9 @@
   6.190  	    address of a person or mailing list.  It often makes sense
   6.191  	    to place this entry in a repository's own <filename
   6.192  	      role="special">.hg/hgrc</filename> file, but it can make
   6.193 -	    sense to use in a global <filename role="special">
   6.194 -	      /.hgrc</filename>\ if every repository has a single
   6.195 -	    maintainer.</para>
   6.196 +	    sense to use in a global <filename
   6.197 +	      role="special">~/.hgrc</filename> if every repository
   6.198 +	    has a single maintainer.</para>
   6.199  	</listitem>
   6.200  	<listitem><para><envar role="rc-item-web">maxchanges</envar>:
   6.201  	    Integer.  The default maximum number of changesets to
   6.202 @@ -1323,7 +1324,8 @@
   6.203  	    <xref linkend="chap.template"/> for details.
   6.204  	    Here, you can see how to enable the
   6.205  	    <literal>gitweb</literal> style.</para>
   6.206 -	  <programlisting>[web] style = gitweb</programlisting>
   6.207 +	  <programlisting>[web]
   6.208 +style = gitweb</programlisting>
   6.209  	</listitem>
   6.210  	<listitem><para><envar role="rc-item-web">templates</envar>:
   6.211  	    Path.  The directory in which to search for template
   6.212 @@ -1335,7 +1337,7 @@
   6.213  	configuration items in a <literal role="rc-web">web</literal>
   6.214  	section of the <filename
   6.215  	  role="special">hgweb.config</filename> file instead of a
   6.216 -	<filename role="special"> /.hgrc</filename>\ file, for
   6.217 +	<filename role="special">~/.hgrc</filename> file, for
   6.218  	convenience.  These items are <envar
   6.219  	  role="rc-item-web">motd</envar> and <envar
   6.220  	  role="rc-item-web">style</envar>.</para>
   6.221 @@ -1346,8 +1348,7 @@
   6.222  	<para>A few <literal role="rc-web">web</literal> configuration
   6.223  	  items ought to be placed in a repository's local <filename
   6.224  	    role="special">.hg/hgrc</filename>, rather than a user's
   6.225 -	  or global <filename role="special">
   6.226 -	    /.hgrc</filename>.</para>
   6.227 +	  or global <filename role="special">~/.hgrc</filename>.</para>
   6.228  	<itemizedlist>
   6.229  	  <listitem><para><envar
   6.230  		role="rc-item-web">description</envar>: String.  A
   6.231 @@ -1367,7 +1368,7 @@
   6.232  
   6.233  	<para>Some of the items in the <literal
   6.234  	    role="rc-web">web</literal> section of a <filename
   6.235 -	    role="special"> /.hgrc</filename>\ file are only for use
   6.236 +	    role="special">~/.hgrc</filename> file are only for use
   6.237  	  with the <command role="hg-cmd">hg serve</command>
   6.238  	  command.</para>
   6.239  	<itemizedlist>
   6.240 @@ -1401,8 +1402,8 @@
   6.241  
   6.242        </sect3>
   6.243        <sect3>
   6.244 -	<title>Choosing the right <filename role="special">
   6.245 -	    /.hgrc</filename>\ file to add <literal
   6.246 +	<title>Choosing the right <filename
   6.247 +	    role="special">~/.hgrc</filename> file to add <literal
   6.248  	    role="rc-web">web</literal> items to</title>
   6.249  
   6.250  	<para>It is important to remember that a web server like
   6.251 @@ -1413,16 +1414,15 @@
   6.252  	  under that user ID.</para>
   6.253  
   6.254  	<para>If you add <literal role="rc-web">web</literal> items to
   6.255 -	  your own personal <filename role="special">
   6.256 -	    /.hgrc</filename>\ file, CGI scripts won't read that
   6.257 -	  <filename role="special"> /.hgrc</filename>\ file.  Those
   6.258 +	  your own personal <filename role="special">~/.hgrc</filename> file, CGI scripts won't read that
   6.259 +	  <filename role="special">~/.hgrc</filename> file.  Those
   6.260  	  settings will thus only affect the behaviour of the <command
   6.261  	    role="hg-cmd">hg serve</command> command when you run it.
   6.262  	  To cause CGI scripts to see your settings, either create a
   6.263 -	  <filename role="special"> /.hgrc</filename>\ file in the
   6.264 +	  <filename role="special">~/.hgrc</filename> file in the
   6.265  	  home directory of the user ID that runs your web server, or
   6.266  	  add those settings to a system-wide <filename
   6.267 -	    role="special"> /.hgrc</filename>\ file.</para>
   6.268 +	    role="special">~/.hgrc</filename> file.</para>
   6.269  
   6.270  
   6.271        </sect3>
     7.1 --- a/en/ch08-branch.xml	Wed Mar 18 19:50:36 2009 +0800
     7.2 +++ b/en/ch08-branch.xml	Wed Mar 18 20:32:37 2009 +0800
     7.3 @@ -520,8 +520,8 @@
     7.4        <quote>stable</quote> branch.  Such a hook might look like this
     7.5        inside the shared repo's <filename role="special">
     7.6  	/.hgrc</filename>.</para>
     7.7 -    <programlisting>[hooks] pretxnchangegroup.branch = hg heads
     7.8 -      --template '{branches} ' | grep mybranch</programlisting>
     7.9 +    <programlisting>[hooks]
    7.10 +pretxnchangegroup.branch = hg heads --template '{branches} ' | grep mybranch</programlisting>
    7.11  
    7.12    </sect1>
    7.13  </chapter>
     8.1 --- a/en/ch10-hook.xml	Wed Mar 18 19:50:36 2009 +0800
     8.2 +++ b/en/ch10-hook.xml	Wed Mar 18 20:32:37 2009 +0800
     8.3 @@ -115,7 +115,7 @@
     8.4        <para>In some cases, you may be exposed to hooks that you did
     8.5  	not install yourself.  If you work with Mercurial on an
     8.6  	unfamiliar system, Mercurial will run hooks defined in that
     8.7 -	system's global <filename role="special"> /.hgrc</filename>\
     8.8 +	system's global <filename role="special">~/.hgrc</filename>
     8.9  	file.
    8.10        </para>
    8.11  
    8.12 @@ -175,8 +175,7 @@
    8.13        <para>In a corporate intranet, this is somewhat easier to
    8.14  	control, as you can for example provide a
    8.15  	<quote>standard</quote> installation of Mercurial on an NFS
    8.16 -	filesystem, and use a site-wide <filename role="special">
    8.17 -	  /.hgrc</filename>\ file to define hooks that all users will
    8.18 +	filesystem, and use a site-wide <filename role="special">~/.hgrc</filename> file to define hooks that all users will
    8.19  	see.  However, this too has its limits; see below.
    8.20        </para>
    8.21  
    8.22 @@ -190,7 +189,7 @@
    8.23        </para>
    8.24  
    8.25        <para>If you deploy a system- or site-wide <filename
    8.26 -	  role="special"> /.hgrc</filename>\ file that defines some
    8.27 +	  role="special">~/.hgrc</filename> file that defines some
    8.28  	hooks, you should thus understand that your users can disable
    8.29  	or override those hooks.
    8.30        </para>
    8.31 @@ -203,7 +202,7 @@
    8.32  	want others to be able to work around.  For example, you may
    8.33  	have a requirement that every changeset must pass a rigorous
    8.34  	set of tests.  Defining this requirement via a hook in a
    8.35 -	site-wide <filename role="special"> /.hgrc</filename>\ won't
    8.36 +	site-wide <filename role="special">~/.hgrc</filename> won't
    8.37  	work for remote users on laptops, and of course local users
    8.38  	can subvert it at will by overriding the hook.
    8.39        </para>
    8.40 @@ -359,7 +358,7 @@
    8.41  
    8.42      <para>You add an entry to the <literal
    8.43  	role="rc-hooks">hooks</literal> section of your <filename
    8.44 -	role="special"> /.hgrc</filename>.  On the left is the name of
    8.45 +	role="special">~/.hgrc</filename>.  On the left is the name of
    8.46        the event to trigger on; on the right is the action to take.  As
    8.47        you can see, you can run an arbitrary shell command in a hook.
    8.48        Mercurial passes extra information to the hook using environment
    8.49 @@ -533,7 +532,7 @@
    8.50        <title>Writing an external hook</title>
    8.51  
    8.52        <para>When you define an external hook in your <filename
    8.53 -	  role="special"> /.hgrc</filename>\ and the hook is run, its
    8.54 +	  role="special">~/.hgrc</filename> and the hook is run, its
    8.55  	value is passed to your shell, which interprets it.  This
    8.56  	means that you can use normal shell constructs in the body of
    8.57  	the hook.
    8.58 @@ -561,7 +560,7 @@
    8.59      <sect2>
    8.60        <title>Telling Mercurial to use an in-process hook</title>
    8.61  
    8.62 -      <para>The <filename role="special"> /.hgrc</filename>\ syntax
    8.63 +      <para>The <filename role="special">~/.hgrc</filename> syntax
    8.64  	for defining an in-process hook is slightly different than for
    8.65  	an executable hook.  The value of the hook must start with the
    8.66  	text <quote><literal>python:</literal></quote>, and continue
    8.67 @@ -575,12 +574,12 @@
    8.68  	  work</quote>.
    8.69        </para>
    8.70  
    8.71 -      <para>The following <filename role="special"> /.hgrc</filename>\
    8.72 +      <para>The following <filename role="special">~/.hgrc</filename>
    8.73  	example snippet illustrates the syntax and meaning of the
    8.74  	notions we just described.
    8.75        </para>
    8.76 -      <programlisting>[hooks] commit.example =
    8.77 -	python:mymodule.submodule.myhook</programlisting>
    8.78 +      <programlisting>[hooks]
    8.79 +commit.example = python:mymodule.submodule.myhook</programlisting>
    8.80        <para>When Mercurial runs the <literal>commit.example</literal>
    8.81  	hook, it imports <literal>mymodule.submodule</literal>, looks
    8.82  	for the callable object named <literal>myhook</literal>, and
    8.83 @@ -595,7 +594,7 @@
    8.84  	the basic shape of the hook API:
    8.85        </para>
    8.86        <programlisting>def myhook(ui, repo, **kwargs):
    8.87 -	pass</programlisting>
    8.88 +    pass</programlisting>
    8.89        <para>The first argument to a Python hook is always a <literal
    8.90  	  role="py-mod-mercurial.ui">ui</literal> object.  The second
    8.91  	is a repository object; at the moment, it is always an
    8.92 @@ -745,8 +744,8 @@
    8.93  	  changeset, and roll back a group of changesets if they
    8.94  	  modify <quote>forbidden</quote> files.  Example:
    8.95  	</para>
    8.96 -	<programlisting>[hooks] pretxnchangegroup.acl =
    8.97 -	  python:hgext.acl.hook</programlisting>
    8.98 +	<programlisting>[hooks]
    8.99 +pretxnchangegroup.acl = python:hgext.acl.hook</programlisting>
   8.100  
   8.101  	<para>The <literal role="hg-ext">acl</literal> extension is
   8.102  	  configured using three sections.
   8.103 @@ -813,8 +812,10 @@
   8.104  	  to any file or directory except <filename
   8.105  	    class="directory">source/sensitive</filename>.
   8.106  	</para>
   8.107 -	<programlisting>[acl.allow] docs/** = docwriter [acl.deny]
   8.108 -	  source/sensitive/** = intern</programlisting>
   8.109 +	<programlisting>[acl.allow]
   8.110 +docs/** = docwriter
   8.111 +[acl.deny]
   8.112 +source/sensitive/** = intern</programlisting>
   8.113  
   8.114        </sect3>
   8.115        <sect3>
   8.116 @@ -827,9 +828,10 @@
   8.117  	  possible) to pass in the <option
   8.118  	    role="hg-opt-global">--debug</option> option, don't forget
   8.119  	  that you can enable debugging output in your <filename
   8.120 -	    role="special"> /.hgrc</filename>:
   8.121 -	</para>
   8.122 -	<programlisting>[ui] debug = true</programlisting>
   8.123 +	    role="special">~/.hgrc</filename>:
   8.124 +	</para>
   8.125 +	<programlisting>[ui]
   8.126 +debug = true</programlisting>
   8.127  	<para>With this enabled, the <literal
   8.128  	    role="hg-ext">acl</literal> hook will print enough
   8.129  	  information to let you figure out why it is allowing or
   8.130 @@ -893,12 +895,12 @@
   8.131  	  hook</title>
   8.132  
   8.133  	<para>You should configure this hook in your server's
   8.134 -	  <filename role="special"> /.hgrc</filename>\ as an <literal
   8.135 +	  <filename role="special">~/.hgrc</filename> as an <literal
   8.136  	    role="hook">incoming</literal> hook, for example as
   8.137  	  follows:
   8.138  	</para>
   8.139 -	<programlisting>[hooks] incoming.bugzilla =
   8.140 -	  python:hgext.bugzilla.hook</programlisting>
   8.141 +	<programlisting>[hooks]
   8.142 +incoming.bugzilla = python:hgext.bugzilla.hook</programlisting>
   8.143  
   8.144  	<para>Because of the specialised nature of this hook, and
   8.145  	  because Bugzilla was not written with this kind of
   8.146 @@ -915,7 +917,7 @@
   8.147  
   8.148  	<para>Configuration information for this hook lives in the
   8.149  	  <literal role="rc-bugzilla">bugzilla</literal> section of
   8.150 -	  your <filename role="special"> /.hgrc</filename>.
   8.151 +	  your <filename role="special">~/.hgrc</filename>.
   8.152  	</para>
   8.153  	<itemizedlist>
   8.154  	  <listitem><para><envar
   8.155 @@ -950,7 +952,7 @@
   8.156  	      password for the user you configured above.  This is
   8.157  	      stored as plain text, so you should make sure that
   8.158  	      unauthorised users cannot read the <filename
   8.159 -		role="special"> /.hgrc</filename>\ file where you
   8.160 +		role="special">~/.hgrc</filename> file where you
   8.161  	      store this information.
   8.162  	    </para>
   8.163  	  </listitem>
   8.164 @@ -1005,8 +1007,8 @@
   8.165  	  email address on the left, and a Bugzilla user name on the
   8.166  	  right.
   8.167  	</para>
   8.168 -	<programlisting>[usermap] jane.user@example.com =
   8.169 -	  jane</programlisting>
   8.170 +	<programlisting>[usermap]
   8.171 +jane.user@example.com = jane</programlisting>
   8.172  	<para>You can either keep the <literal
   8.173  	    role="rc-usermap">usermap</literal> data in a normal
   8.174  	  <filename role="special">~/.hgrc</filename>, or tell the
   8.175 @@ -1017,18 +1019,17 @@
   8.176  	  a user-modifiable repository.  This makes it possible to let
   8.177  	  your users maintain their own <envar
   8.178  	    role="rc-item-bugzilla">usermap</envar> entries.  The main
   8.179 -	  <filename role="special"> /.hgrc</filename>\ file might look
   8.180 +	  <filename role="special">~/.hgrc</filename> file might look
   8.181  	  like this:
   8.182  	</para>
   8.183 -	<programlisting># regular hgrc file refers to external usermap
   8.184 -	  file [bugzilla] usermap =
   8.185 -	  /home/hg/repos/userdata/bugzilla-usermap.conf</programlisting>
   8.186 +	<programlisting># regular hgrc file refers to external usermap file
   8.187 +[bugzilla]
   8.188 +usermap = /home/hg/repos/userdata/bugzilla-usermap.conf</programlisting>
   8.189  	<para>While the <filename>usermap</filename> file that it
   8.190  	  refers to might look like this:
   8.191  	</para>
   8.192 -	<programlisting># bugzilla-usermap.conf - inside a hg
   8.193 -	  repository [usermap] stephanie@example.com =
   8.194 -	  steph</programlisting>
   8.195 +	<programlisting># bugzilla-usermap.conf - inside a hg repository
   8.196 +[usermap] stephanie@example.com = steph</programlisting>
   8.197  
   8.198        </sect3>
   8.199        <sect3>
   8.200 @@ -1036,7 +1037,7 @@
   8.201  
   8.202  	<para>You can configure the text that this hook adds as a
   8.203  	  comment; you specify it in the form of a Mercurial template.
   8.204 -	  Several <filename role="special"> /.hgrc</filename>\ entries
   8.205 +	  Several <filename role="special">~/.hgrc</filename> entries
   8.206  	  (still in the <literal role="rc-bugzilla">bugzilla</literal>
   8.207  	  section) control this behaviour.
   8.208  	</para>
   8.209 @@ -1068,27 +1069,20 @@
   8.210  	<para>In addition, you can add a <envar
   8.211  	    role="rc-item-web">baseurl</envar> item to the <literal
   8.212  	    role="rc-web">web</literal> section of your <filename
   8.213 -	    role="special"> /.hgrc</filename>.  The <literal
   8.214 +	    role="special">~/.hgrc</filename>.  The <literal
   8.215  	    role="hg-ext">bugzilla</literal> hook will make this
   8.216  	  available when expanding a template, as the base string to
   8.217  	  use when constructing a URL that will let users browse from
   8.218  	  a Bugzilla comment to view a changeset.  Example:
   8.219  	</para>
   8.220 -	<programlisting>[web] baseurl =
   8.221 -	  http://hg.domain.com/</programlisting>
   8.222 +	<programlisting>[web]
   8.223 +baseurl = http://hg.domain.com/</programlisting>
   8.224  
   8.225  	<para>Here is an example set of <literal
   8.226  	    role="hg-ext">bugzilla</literal> hook config information.
   8.227  	</para>
   8.228 -	<programlisting>[bugzilla] host = bugzilla.example.com
   8.229 -	  password = mypassword version = 2.16 # server-side repos
   8.230 -	  live in /home/hg/repos, so strip 4 leading # separators
   8.231 -	  strip = 4 hgweb = http://hg.example.com/ usermap =
   8.232 -	  /home/hg/repos/notify/bugzilla.conf template = Changeset
   8.233 -	  {node|short}, made by {author} in the {webroot} repo, refers
   8.234 -	  to this bug.\\nFor complete details, see
   8.235 -	  {hgweb}{webroot}?cmd=changeset;node={node|short}\\nChangeset
   8.236 -	  description:\\n\\t{desc|tabindent}</programlisting>
   8.237 +
   8.238 +	&ch10-bugzilla-config.lst;
   8.239  
   8.240        </sect3>
   8.241        <sect3>
   8.242 @@ -1116,9 +1110,8 @@
   8.243  	  <command>sudo</command> command.  Here is an example entry
   8.244  	  for a <filename>sudoers</filename> file.
   8.245  	</para>
   8.246 -	<programlisting>hg_user = (httpd_user) NOPASSWD:
   8.247 -	  /var/www/html/bugzilla/processmail-wrapper
   8.248 -	  %s</programlisting>
   8.249 +	<programlisting>hg_user = (httpd_user)
   8.250 +NOPASSWD: /var/www/html/bugzilla/processmail-wrapper %s</programlisting>
   8.251  	<para>This allows the <literal>hg_user</literal> user to run a
   8.252  	  <filename>processmail-wrapper</filename> program under the
   8.253  	  identity of <literal>httpd_user</literal>.
   8.254 @@ -1131,8 +1124,8 @@
   8.255  	  <filename>sudoers</filename> file.  The contents of the
   8.256  	  wrapper script are simple:
   8.257  	</para>
   8.258 -	<programlisting>#!/bin/sh cd `dirname $0` &amp;&amp;
   8.259 -	  ./processmail "$1" nobody@example.com</programlisting>
   8.260 +	<programlisting>#!/bin/sh
   8.261 +cd `dirname $0` &amp;&amp; ./processmail "$1" nobody@example.com</programlisting>
   8.262  	<para>It doesn't seem to matter what email address you pass to
   8.263  	  <filename>processmail</filename>.
   8.264  	</para>
   8.265 @@ -1143,8 +1136,7 @@
   8.266  	  push changes to the server.  The error message will look
   8.267  	  like this:
   8.268  	</para>
   8.269 -	<programlisting>cannot find bugzilla user id for
   8.270 -	  john.q.public@example.com</programlisting>
   8.271 +	<programlisting>cannot find bugzilla user id for john.q.public@example.com</programlisting>
   8.272  	<para>What this means is that the committer's address,
   8.273  	  <literal>john.q.public@example.com</literal>, is not a valid
   8.274  	  Bugzilla user name, nor does it have an entry in your
   8.275 @@ -1189,14 +1181,15 @@
   8.276  	  changesets (all those that arrived in a single pull or
   8.277  	  push).
   8.278  	</para>
   8.279 -	<programlisting>[hooks] # send one email per group of changes
   8.280 -	  changegroup.notify = python:hgext.notify.hook # send one
   8.281 -	  email per change incoming.notify =
   8.282 -	  python:hgext.notify.hook</programlisting>
   8.283 +	<programlisting>[hooks]
   8.284 +# send one email per group of changes
   8.285 +changegroup.notify = python:hgext.notify.hook
   8.286 +# send one email per change
   8.287 +incoming.notify = python:hgext.notify.hook</programlisting>
   8.288  
   8.289  	<para>Configuration information for this hook lives in the
   8.290  	  <literal role="rc-notify">notify</literal> section of a
   8.291 -	  <filename role="special"> /.hgrc</filename>\ file.
   8.292 +	  <filename role="special">~/.hgrc</filename> file.
   8.293  	</para>
   8.294  	<itemizedlist>
   8.295  	  <listitem><para><envar role="rc-item-notify">test</envar>:
   8.296 @@ -1214,7 +1207,7 @@
   8.297  	  <listitem><para><envar role="rc-item-notify">config</envar>:
   8.298  	      The path to a configuration file that contains
   8.299  	      subscription information.  This is kept separate from
   8.300 -	      the main <filename role="special"> /.hgrc</filename>\ so
   8.301 +	      the main <filename role="special">~/.hgrc</filename> so
   8.302  	      that you can maintain it in a repository of its own.
   8.303  	      People can then clone that repository, update their
   8.304  	      subscriptions, and push the changes back to your server.
   8.305 @@ -1273,35 +1266,14 @@
   8.306  	<para>Here is an example set of <literal
   8.307  	    role="hg-ext">notify</literal> configuration information.
   8.308  	</para>
   8.309 -	<programlisting>
   8.310 -	  [notify] # really send email test = false # subscriber data
   8.311 -	  lives in the notify repo config =
   8.312 -	  /home/hg/repos/notify/notify.conf # repos live in
   8.313 -	  /home/hg/repos on server, so strip 4 "/" chars strip = 4
   8.314 -	  template = X-Hg-Repo: {webroot} Subject: {webroot}:
   8.315 -	  {desc|firstline|strip} From: {author} changeset {node|short}
   8.316 -	  in {root} details:
   8.317 -	  {baseurl}{webroot}?cmd=changeset;node={node|short}
   8.318 -	  description: {desc|tabindent|strip} [web] baseurl =
   8.319 -	  http://hg.example.com/
   8.320 -	</programlisting>
   8.321 +
   8.322 +	&ch10-notify-config.lst;
   8.323  
   8.324  	<para>This will produce a message that looks like the
   8.325  	  following:
   8.326  	</para>
   8.327 -	<programlisting>
   8.328 -	  X-Hg-Repo: tests/slave Subject: tests/slave: Handle error
   8.329 -	  case when slave has no buffers Date: Wed,  2 Aug 2006
   8.330 -	  15:25:46 -0700 (PDT) changeset 3cba9bfe74b5 in
   8.331 -	  /home/hg/repos/tests/slave details:
   8.332 -	  http://hg.example.com/tests/slave?cmd=changeset;node=3cba9bfe74b5 
   8.333 -	  description: Handle error case when slave has no buffers
   8.334 -	  diffs (54 lines): diff -r 9d95df7cf2ad -r 3cba9bfe74b5
   8.335 -	  include/tests.h --- a/include/tests.h      Wed Aug 02
   8.336 -	  15:19:52 2006 -0700 +++ b/include/tests.h      Wed Aug 02
   8.337 -	  15:25:26 2006 -0700 @@ -212,6 +212,15 @@ static __inline__
   8.338 -	  void test_headers(void *h) [...snip...]
   8.339 -	</programlisting>
   8.340 +
   8.341 +	&ch10-notify-config-mail.lst;
   8.342  
   8.343        </sect3>
   8.344        <sect3>
   8.345 @@ -1327,9 +1299,7 @@
   8.346        <para>An in-process hook is called with arguments of the
   8.347  	following form:
   8.348        </para>
   8.349 -      <programlisting>
   8.350 -	def myhook(ui, repo, **kwargs): pass
   8.351 -      </programlisting>
   8.352 +      <programlisting>def myhook(ui, repo, **kwargs): pass</programlisting>
   8.353        <para>The <literal>ui</literal> parameter is a <literal
   8.354  	  role="py-mod-mercurial.ui">ui</literal> object. The
   8.355  	<literal>repo</literal> parameter is a <literal
   8.356 @@ -1373,7 +1343,7 @@
   8.357        <para>Note that changeset IDs are passed into Python hooks as
   8.358  	hexadecimal strings, not the binary hashes that Mercurial's
   8.359  	APIs normally use.  To convert a hash from hex to binary, use
   8.360 -	the \pymodfunc{mercurial.node}{bin} function.
   8.361 +	the <literal>bin</literal> function.
   8.362        </para>
   8.363  
   8.364      </sect2>
   8.365 @@ -1526,9 +1496,8 @@
   8.366  	<listitem><para><literal>node</literal>: A changeset ID.  The
   8.367  	    changeset ID of the first changeset in the group that was
   8.368  	    added.  All changesets between this and
   8.369 -	    \index{tags!<literal>tip</literal>}<literal>tip</literal>,
   8.370 -	    inclusive, were added by a single <command
   8.371 -	      role="hg-cmd">hg pull</command>, <command
   8.372 +	    <literal role="tag">tip</literal>, inclusive, were added by a single
   8.373 +	    <command role="hg-cmd">hg pull</command>, <command
   8.374  	      role="hg-cmd">hg push</command> or <command
   8.375  	      role="hg-cmd">hg unbundle</command>.
   8.376  	  </para>
   8.377 @@ -1880,7 +1849,7 @@
   8.378  	<listitem><para><literal>node</literal>: A changeset ID.  The
   8.379  	    changeset ID of the first changeset in the group that was
   8.380  	    added.  All changesets between this and
   8.381 -	    \index{tags!<literal>tip</literal>}<literal>tip</literal>,
   8.382 +	    <literal role="tag">tip</literal>,
   8.383  	    inclusive, were added by a single <command
   8.384  	      role="hg-cmd">hg pull</command>, <command
   8.385  	      role="hg-cmd">hg push</command> or <command
     9.1 --- a/en/ch11-template.xml	Wed Mar 18 19:50:36 2009 +0800
     9.2 +++ b/en/ch11-template.xml	Wed Mar 18 20:32:37 2009 +0800
     9.3 @@ -44,11 +44,12 @@
     9.4        <title>Setting a default style</title>
     9.5  
     9.6        <para>You can modify the output style that Mercurial will use
     9.7 -	for every command by editing your <filename role="special">
     9.8 -	  /.hgrc</filename>\ file, naming the style you would prefer
     9.9 -	to use.</para>
    9.10 -
    9.11 -      <programlisting>[ui] style = compact</programlisting>
    9.12 +	for every command by editing your <filename
    9.13 +	  role="special">~/.hgrc</filename> file, naming the style
    9.14 +	you would prefer to use.</para>
    9.15 +
    9.16 +      <programlisting>[ui]
    9.17 +style = compact</programlisting>
    9.18  
    9.19        <para>If you write a style of your own, you can use it by either
    9.20  	providing the path to your style file, or copying your style
    9.21 @@ -212,27 +213,27 @@
    9.22        single replacement, as described below.</para>
    9.23  
    9.24      <itemizedlist>
    9.25 -      <listitem><para><literal>\textbackslash\textbackslash</literal>:
    9.26 +      <listitem><para><literal>\</literal>:
    9.27  	  Backslash, <quote><literal>\</literal></quote>, ASCII
    9.28  	  134.</para>
    9.29        </listitem>
    9.30 -      <listitem><para><literal>\textbackslash n</literal>: Newline,
    9.31 +      <listitem><para><literal>\n</literal>: Newline,
    9.32  	  ASCII 12.</para>
    9.33        </listitem>
    9.34 -      <listitem><para><literal>\textbackslash r</literal>: Carriage
    9.35 +      <listitem><para><literal>\r</literal>: Carriage
    9.36  	  return, ASCII 15.</para>
    9.37        </listitem>
    9.38 -      <listitem><para><literal>\textbackslash t</literal>: Tab, ASCII
    9.39 +      <listitem><para><literal>\t</literal>: Tab, ASCII
    9.40  	  11.</para>
    9.41        </listitem>
    9.42 -      <listitem><para><literal>\textbackslash v</literal>: Vertical
    9.43 +      <listitem><para><literal>\v</literal>: Vertical
    9.44  	  tab, ASCII 13.</para>
    9.45        </listitem>
    9.46 -      <listitem><para><literal>\textbackslash {</literal>: Open curly
    9.47 +      <listitem><para><literal>{</literal>: Open curly
    9.48  	  brace, <quote><literal>{</literal></quote>, ASCII
    9.49  	  173.</para>
    9.50        </listitem>
    9.51 -      <listitem><para><literal>\textbackslash }</literal>: Close curly
    9.52 +      <listitem><para><literal>}</literal>: Close curly
    9.53  	  brace, <quote><literal>}</literal></quote>, ASCII
    9.54  	  175.</para>
    9.55        </listitem></itemizedlist>
    9.56 @@ -548,24 +549,19 @@
    9.57        <itemizedlist>
    9.58  	<listitem><para>The first component is simply Mercurial's way
    9.59  	    of saying <quote>I am giving up</quote>.</para>
    9.60 -	  <programlisting>___abort___: broken.style:1: parse
    9.61 -	    error</programlisting>
    9.62 +	  <programlisting>___abort___: broken.style:1: parse error</programlisting>
    9.63  	</listitem>
    9.64  	<listitem><para>Next comes the name of the style file that
    9.65  	    contains the error.</para>
    9.66 -	  <programlisting>
    9.67 -	    abort: ___broken.style___:1: parse error
    9.68 -	  </programlisting>
    9.69 +	  <programlisting>abort: ___broken.style___:1: parse error</programlisting>
    9.70  	</listitem>
    9.71  	<listitem><para>Following the file name is the line number
    9.72  	    where the error was encountered.</para>
    9.73 -	  <programlisting>abort: broken.style:___1___: parse
    9.74 -	    error</programlisting>
    9.75 +	  <programlisting>abort: broken.style:___1___: parse error</programlisting>
    9.76  	</listitem>
    9.77  	<listitem><para>Finally, a description of what went
    9.78  	    wrong.</para>
    9.79 -	  <programlisting>abort: broken.style:1: ___parse
    9.80 -	    error___</programlisting>
    9.81 +	  <programlisting>abort: broken.style:1: ___parse error___</programlisting>
    9.82  	</listitem>
    9.83  	<listitem><para>The description of the problem is not always
    9.84  	    clear (as in this case), but even when it is cryptic, it
    10.1 --- a/en/ch12-mq.xml	Wed Mar 18 19:50:36 2009 +0800
    10.2 +++ b/en/ch12-mq.xml	Wed Mar 18 20:32:37 2009 +0800
    10.3 @@ -256,7 +256,8 @@
    10.4  	role="home">~/.hgrc</filename> file, and add the lines
    10.5        below.</para>
    10.6  
    10.7 -    <programlisting>[extensions] hgext.mq =</programlisting>
    10.8 +    <programlisting>[extensions]
    10.9 +hgext.mq =</programlisting>
   10.10  
   10.11      <para>Once the extension is enabled, it will make a number of new
   10.12        commands available.  To verify that the extension is working,
   10.13 @@ -870,11 +871,9 @@
   10.14  	      role="hg-opt-update">-C</option></command> to override
   10.15  	  the patches you have pushed.</para>
   10.16        </listitem>
   10.17 -      <listitem><para>Merge all patches using
   10.18 -	  \hgcmdargs{qpush}{<option role="hg-ext-mq-cmd-qpush-opt">hg
   10.19 -	    -m</option> <option role="hg-ext-mq-cmd-qpush-opt">hg
   10.20 -	    -a</option>}.  The <option
   10.21 -	    role="hg-ext-mq-cmd-qpush-opt">hg -m</option> option to
   10.22 +      <listitem><para>Merge all patches using <command>hg qpush -m
   10.23 +	    -a</command>.  The <option
   10.24 +	    role="hg-ext-mq-cmd-qpush-opt">-m</option> option to
   10.25  	  <command role="hg-ext-mq">qpush</command> tells MQ to
   10.26  	  perform a three-way merge if the patch fails to
   10.27  	  apply.</para>
   10.28 @@ -931,10 +930,8 @@
   10.29        changeset ID will also accept the name of an applied patch.  MQ
   10.30        augments the tags normally in the repository with an eponymous
   10.31        one for each applied patch.  In addition, the special tags
   10.32 -      \index{tags!special tag
   10.33 -      names!<literal>qbase</literal>}<literal>qbase</literal> and
   10.34 -      \index{tags!special tag
   10.35 -      names!<literal>qtip</literal>}<literal>qtip</literal> identify
   10.36 +      <literal role="tag">qbase</literal> and
   10.37 +      <literal role="tag">qtip</literal> identify
   10.38        the <quote>bottom-most</quote> and topmost applied patches,
   10.39        respectively.</para>
   10.40  
   10.41 @@ -943,17 +940,14 @@
   10.42      <itemizedlist>
   10.43        <listitem><para>Want to patchbomb a mailing list with your
   10.44  	  latest series of changes?</para>
   10.45 -	<programlisting>hg email qbase:qtip
   10.46 -	</programlisting>
   10.47 +	<programlisting>hg email qbase:qtip</programlisting>
   10.48  	<para>  (Don't know what <quote>patchbombing</quote> is?  See
   10.49  	  section <xref linkend="sec.hgext.patchbomb"/>.)</para>
   10.50        </listitem>
   10.51        <listitem><para>Need to see all of the patches since
   10.52  	  <literal>foo.patch</literal> that have touched files in a
   10.53  	  subdirectory of your tree?</para>
   10.54 -	<programlisting>
   10.55 -	  hg log -r foo.patch:qtip <emphasis>subdir</emphasis>
   10.56 -	</programlisting>
   10.57 +	<programlisting>hg log -r foo.patch:qtip subdir</programlisting>
   10.58        </listitem>
   10.59      </itemizedlist>
   10.60  
   10.61 @@ -1081,8 +1075,7 @@
   10.62  	snippet in your <filename
   10.63  	  role="home">~/.bashrc</filename>.</para>
   10.64  
   10.65 -      <programlisting>alias mq=`hg -R $(hg
   10.66 -	root)/.hg/patches'</programlisting>
   10.67 +      <programlisting>alias mq=`hg -R $(hg root)/.hg/patches'</programlisting>
   10.68  
   10.69        <para>You can then issue commands of the form <command>mq
   10.70  	  pull</command> from the main repository.</para>
    11.1 --- a/en/ch13-mq-collab.xml	Wed Mar 18 19:50:36 2009 +0800
    11.2 +++ b/en/ch13-mq-collab.xml	Wed Mar 18 20:32:37 2009 +0800
    11.3 @@ -460,8 +460,9 @@
    11.4  	  role="hg-ext">extdiff</literal> extension in the usual way,
    11.5  	by adding a line to the <literal
    11.6  	  role="rc-extensions">extensions</literal> section of your
    11.7 -	<filename role="special"> /.hgrc</filename>.</para>
    11.8 -      <programlisting>[extensions] extdiff =</programlisting>
    11.9 +	<filename role="special">~/.hgrc</filename>.</para>
   11.10 +      <programlisting>[extensions]
   11.11 +extdiff =</programlisting>
   11.12        <para>The <command>interdiff</command> command expects to be
   11.13  	passed the names of two files, but the <literal
   11.14  	  role="hg-ext">extdiff</literal> extension passes the program
   11.15 @@ -477,22 +478,20 @@
   11.16        <para>With the <filename role="special">hg-interdiff</filename>
   11.17  	program in your shell's search path, you can run it as
   11.18  	follows, from inside an MQ patch directory:</para>
   11.19 -      <programlisting>hg extdiff -p hg-interdiff -r A:B
   11.20 -	my-change.patch</programlisting>
   11.21 +      <programlisting>hg extdiff -p hg-interdiff -r A:B my-change.patch</programlisting>
   11.22        <para>Since you'll probably want to use this long-winded command
   11.23  	a lot, you can get <literal role="hg-ext">hgext</literal> to
   11.24  	make it available as a normal Mercurial command, again by
   11.25 -	editing your <filename role="special">
   11.26 -	  /.hgrc</filename>.</para>
   11.27 -      <programlisting>[extdiff] cmd.interdiff =
   11.28 -	hg-interdiff</programlisting>
   11.29 +	editing your <filename
   11.30 +	  role="special">~/.hgrc</filename>.</para>
   11.31 +      <programlisting>[extdiff]
   11.32 +cmd.interdiff = hg-interdiff</programlisting>
   11.33        <para>This directs <literal role="hg-ext">hgext</literal> to
   11.34  	make an <literal>interdiff</literal> command available, so you
   11.35  	can now shorten the previous invocation of <command
   11.36  	  role="hg-ext-extdiff">extdiff</command> to something a
   11.37  	little more wieldy.</para>
   11.38 -      <programlisting>hg interdiff -r A:B
   11.39 -	my-change.patch</programlisting>
   11.40 +      <programlisting>hg interdiff -r A:B my-change.patch</programlisting>
   11.41  
   11.42        <note>
   11.43  	<para>  The <command>interdiff</command> command works well
    12.1 --- a/en/ch14-hgext.xml	Wed Mar 18 19:50:36 2009 +0800
    12.2 +++ b/en/ch14-hgext.xml	Wed Mar 18 20:32:37 2009 +0800
    12.3 @@ -166,11 +166,10 @@
    12.4      <orderedlist>
    12.5        <listitem><para>Clone the Python <literal>inotify</literal>
    12.6  	  binding repository.  Build and install it.</para>
    12.7 -	<programlisting>
    12.8 -	  hg clone http://hg.kublai.com/python/inotify cd inotify
    12.9 -	  python setup.py build --force sudo python setup.py install
   12.10 -	  --skip-build
   12.11 -	</programlisting>
   12.12 +	<programlisting>hg clone http://hg.kublai.com/python/inotify
   12.13 +cd inotify
   12.14 +python setup.py build --force
   12.15 +sudo python setup.py install --skip-build</programlisting>
   12.16        </listitem>
   12.17        <listitem><para>Clone the <filename
   12.18  	    class="directory">crew</filename> Mercurial repository.
   12.19 @@ -178,12 +177,9 @@
   12.20  	  repository so that Mercurial Queues will be able to apply
   12.21  	  patches to your cope of the <filename
   12.22  	    class="directory">crew</filename> repository.</para>
   12.23 -	<programlisting>
   12.24 -	  hg clone http://hg.intevation.org/mercurial/crew hg clone
   12.25 -	  crew inotify hg clone
   12.26 -	  http://hg.kublai.com/mercurial/patches/inotify
   12.27 -	  inotify/.hg/patches
   12.28 -	</programlisting>
   12.29 +	<programlisting>hg clone http://hg.intevation.org/mercurial/crew
   12.30 +hg clone crew inotify
   12.31 +hg clone http://hg.kublai.com/mercurial/patches/inotify inotify/.hg/patches</programlisting>
   12.32        </listitem>
   12.33        <listitem><para>Make sure that you have the Mercurial Queues
   12.34  	  extension, <literal role="hg-ext">mq</literal>, enabled.  If
   12.35 @@ -197,9 +193,8 @@
   12.36  	  using the <option role="hg-ext-mq-cmd-qpush-opt">hg
   12.37  	    -a</option> option to the <command
   12.38  	    role="hg-ext-mq">qpush</command> command.</para>
   12.39 -	<programlisting>
   12.40 -	  cd inotify hg qpush -a
   12.41 -	</programlisting>
   12.42 +	<programlisting>cd inotify
   12.43 +hg qpush -a</programlisting>
   12.44        </listitem>
   12.45        <listitem><para>  If you get an error message from <command
   12.46  	    role="hg-ext-mq">qpush</command>, you should not continue.
   12.47 @@ -207,16 +202,14 @@
   12.48        </listitem>
   12.49        <listitem><para>Build and install the patched version of
   12.50  	  Mercurial.</para>
   12.51 -	<programlisting>
   12.52 -	  python setup.py build --force sudo python setup.py install
   12.53 -	  --skip-build
   12.54 -	</programlisting>
   12.55 +	<programlisting>python setup.py build --force
   12.56 +sudo python setup.py install --skip-build</programlisting>
   12.57        </listitem>
   12.58      </orderedlist>
   12.59      <para>Once you've build a suitably patched version of Mercurial,
   12.60        all you need to do to enable the <literal
   12.61  	role="hg-ext">inotify</literal> extension is add an entry to
   12.62 -      your <filename role="special"> /.hgrc</filename>.</para>
   12.63 +      your <filename role="special">~/.hgrc</filename>.</para>
   12.64      <programlisting>[extensions] inotify =</programlisting>
   12.65      <para>When the <literal role="hg-ext">inotify</literal> extension
   12.66        is enabled, Mercurial will automatically and transparently start
   12.67 @@ -280,9 +273,10 @@
   12.68      <para>The <literal role="hg-ext">extdiff</literal> extension is
   12.69        bundled with Mercurial, so it's easy to set up.  In the <literal
   12.70  	role="rc-extensions">extensions</literal> section of your
   12.71 -      <filename role="special"> /.hgrc</filename>, simply add a
   12.72 +      <filename role="special">~/.hgrc</filename>, simply add a
   12.73        one-line entry to enable the extension.</para>
   12.74 -    <programlisting>[extensions] extdiff =</programlisting>
   12.75 +    <programlisting>[extensions]
   12.76 +extdiff =</programlisting>
   12.77      <para>This introduces a command named <command
   12.78  	role="hg-ext-extdiff">extdiff</command>, which by default uses
   12.79        your system's <command>diff</command> command to generate a
   12.80 @@ -372,15 +366,16 @@
   12.81  	<emphasis>new</emphasis> commands that will invoke your diff
   12.82  	viewer with exactly the right options.</para>
   12.83  
   12.84 -      <para>All you need to do is edit your <filename role="special">
   12.85 -	  /.hgrc</filename>, and add a section named <literal
   12.86 -	  role="rc-extdiff">extdiff</literal>.  Inside this section,
   12.87 -	you can define multiple commands.  Here's how to add a
   12.88 -	<literal>kdiff3</literal> command.  Once you've defined this,
   12.89 -	you can type <quote><literal>hg kdiff3</literal></quote> and
   12.90 -	the <literal role="hg-ext">extdiff</literal> extension will
   12.91 -	run <command>kdiff3</command> for you.</para>
   12.92 -      <programlisting>[extdiff] cmd.kdiff3 =</programlisting>
   12.93 +      <para>All you need to do is edit your <filename
   12.94 +	  role="special">~/.hgrc</filename>, and add a section named
   12.95 +	<literal role="rc-extdiff">extdiff</literal>.  Inside this
   12.96 +	section, you can define multiple commands.  Here's how to add
   12.97 +	a <literal>kdiff3</literal> command.  Once you've defined
   12.98 +	this, you can type <quote><literal>hg kdiff3</literal></quote>
   12.99 +	and the <literal role="hg-ext">extdiff</literal> extension
  12.100 +	will run <command>kdiff3</command> for you.</para>
  12.101 +      <programlisting>[extdiff]
  12.102 +cmd.kdiff3 =</programlisting>
  12.103        <para>If you leave the right hand side of the definition empty,
  12.104  	as above, the <literal role="hg-ext">extdiff</literal>
  12.105  	extension uses the name of the command you defined as the name
  12.106 @@ -388,7 +383,8 @@
  12.107  	be the same.  Here, we define a command named
  12.108  	<quote><literal>hg wibble</literal></quote>, which runs
  12.109  	<command>kdiff3</command>.</para>
  12.110 -      <programlisting>[extdiff] cmd.wibble = kdiff3</programlisting>
  12.111 +      <programlisting>[extdiff]
  12.112 + cmd.wibble = kdiff3</programlisting>
  12.113  
  12.114        <para>You can also specify the default options that you want to
  12.115  	invoke your diff viewing program with.  The prefix to use is
  12.116 @@ -397,8 +393,9 @@
  12.117  	defines a <quote><literal>hg vimdiff</literal></quote> command
  12.118  	that runs the <command>vim</command> editor's
  12.119  	<literal>DirDiff</literal> extension.</para>
  12.120 -      <programlisting>[extdiff] cmd.vimdiff = vim opts.vimdiff = -f
  12.121 -	'+next' '+execute "DirDiff" argv(0) argv(1)'</programlisting>
  12.122 +      <programlisting>[extdiff]
  12.123 + cmd.vimdiff = vim
  12.124 +opts.vimdiff = -f '+next' '+execute "DirDiff" argv(0) argv(1)'</programlisting>
  12.125  
  12.126      </sect2>
  12.127    </sect1>
  12.128 @@ -433,7 +430,8 @@
  12.129  	role="hg-ext">patchbomb</literal> extension takes just one or
  12.130        two lines in your <filename role="special">
  12.131  	/.hgrc</filename>.</para>
  12.132 -    <programlisting>[extensions] patchbomb =</programlisting>
  12.133 +    <programlisting>[extensions]
  12.134 +patchbomb =</programlisting>
  12.135      <para>Once you've enabled the extension, you will have a new
  12.136        command available, named <command
  12.137  	role="hg-ext-patchbomb">email</command>.</para>
    13.1 --- a/en/examples/auto-snippets.xml	Wed Mar 18 19:50:36 2009 +0800
    13.2 +++ b/en/examples/auto-snippets.xml	Wed Mar 18 20:32:37 2009 +0800
    13.3 @@ -1,3 +1,7 @@
    13.4 +<!ENTITY ch06-apache-config.lst SYSTEM "results/ch06-apache-config.lst.out">
    13.5 +<!ENTITY ch10-bugzilla-config.lst SYSTEM "results/ch10-bugzilla-config.lst.out">
    13.6 +<!ENTITY ch10-notify-config-mail.lst SYSTEM "results/ch10-notify-config-mail.lst.out">
    13.7 +<!ENTITY ch10-notify-config.lst SYSTEM "results/ch10-notify-config.lst.out">
    13.8  <!ENTITY interaction.backout.init SYSTEM "results/backout.init.out">
    13.9  <!ENTITY interaction.backout.manual.backout SYSTEM "results/backout.manual.backout.out">
   13.10  <!ENTITY interaction.backout.manual.cat SYSTEM "results/backout.manual.cat.out">
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/en/examples/ch06/apache-config.lst	Wed Mar 18 20:32:37 2009 +0800
    14.3 @@ -0,0 +1,11 @@
    14.4 +<Directory /home/*/public_html>
    14.5 +  AllowOverride FileInfo AuthConfig Limit
    14.6 +  Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    14.7 +  <Limit GET POST OPTIONS>
    14.8 +    Order allow,deny
    14.9 +    Allow from all
   14.10 +  </Limit>
   14.11 +  <LimitExcept GET POST OPTIONS>
   14.12 +    Order deny,allow Deny from all
   14.13 +  </LimitExcept>
   14.14 +</Directory>
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/en/examples/ch10/bugzilla-config.lst	Wed Mar 18 20:32:37 2009 +0800
    15.3 @@ -0,0 +1,14 @@
    15.4 +[bugzilla]
    15.5 +host = bugzilla.example.com
    15.6 +password = mypassword version = 2.16
    15.7 +# server-side repos live in /home/hg/repos, so strip 4 leading
    15.8 +# separators
    15.9 +strip = 4
   15.10 +hgweb = http://hg.example.com/
   15.11 +usermap = /home/hg/repos/notify/bugzilla.conf
   15.12 +template = Changeset {node|short}, made by {author} in the {webroot}
   15.13 +  repo, refers to this bug.\n
   15.14 +  For complete details, see
   15.15 +  {hgweb}{webroot}?cmd=changeset;node={node|short}\n
   15.16 +  Changeset description:\n
   15.17 +  \t{desc|tabindent}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/en/examples/ch10/notify-config-mail.lst	Wed Mar 18 20:32:37 2009 +0800
    16.3 @@ -0,0 +1,18 @@
    16.4 +X-Hg-Repo: tests/slave
    16.5 +Subject: tests/slave: Handle error case when slave has no buffers
    16.6 +Date: Wed,  2 Aug 2006 15:25:46 -0700 (PDT)
    16.7 +
    16.8 +changeset 3cba9bfe74b5 in /home/hg/repos/tests/slave
    16.9 +
   16.10 +details:
   16.11 +http://hg.example.com/tests/slave?cmd=changeset;node=3cba9bfe74b5 
   16.12 +
   16.13 +description: Handle error case when slave has no buffers
   16.14 +
   16.15 +diffs (54 lines):
   16.16 +diff -r 9d95df7cf2ad -r 3cba9bfe74b5 include/tests.h
   16.17 +--- a/include/tests.h      Wed Aug 02 15:19:52 2006 -0700
   16.18 ++++ b/include/tests.h      Wed Aug 02 15:25:26 2006 -0700
   16.19 +@@ -212,6 +212,15 @@ static __inline__
   16.20 +void test_headers(void *h)
   16.21 +[...snip...]
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/en/examples/ch10/notify-config.lst	Wed Mar 18 20:32:37 2009 +0800
    17.3 @@ -0,0 +1,19 @@
    17.4 +[notify]
    17.5 +# really send email
    17.6 +test = false
    17.7 +# subscriber data lives in the notify repo
    17.8 +config = /home/hg/repos/notify/notify.conf
    17.9 +# repos live in /home/hg/repos on server, so strip 4 "/" chars
   17.10 +strip = 4
   17.11 +template = X-Hg-Repo: {webroot}\n
   17.12 +  Subject: {webroot}: {desc|firstline|strip}\n
   17.13 +  From: {author}
   17.14 +  \n\n
   17.15 +  changeset {node|short} in {root}
   17.16 +  \n\ndetails:
   17.17 +  {baseurl}{webroot}?cmd=changeset;node={node|short}
   17.18 +  description: {desc|tabindent|strip}
   17.19 +
   17.20 +[web]
   17.21 +baseurl =
   17.22 +http://hg.example.com/
    18.1 --- a/en/examples/run-example	Wed Mar 18 19:50:36 2009 +0800
    18.2 +++ b/en/examples/run-example	Wed Mar 18 20:32:37 2009 +0800
    18.3 @@ -7,6 +7,7 @@
    18.4  import cStringIO
    18.5  import errno
    18.6  import getopt
    18.7 +import glob
    18.8  import os
    18.9  import pty
   18.10  import re
   18.11 @@ -54,10 +55,89 @@
   18.12      return None
   18.13          
   18.14  def result_name(name):
   18.15 -    dirname, basename = os.path.split(name)
   18.16 -    return os.path.join(dirname, 'results', basename)
   18.17 +    return os.path.normpath(os.path.join('results', name.replace(os.sep, '-')))
   18.18 +
   18.19 +def wopen(name):
   18.20 +    path = os.path.dirname(name)
   18.21 +    if path:
   18.22 +        try:
   18.23 +            os.makedirs(path)
   18.24 +        except OSError, err:
   18.25 +            if err.errno != errno.EEXIST:
   18.26 +                raise
   18.27 +    return open(name, 'w')
   18.28  
   18.29  class example:
   18.30 +    entities = dict.fromkeys(l.rstrip() for l in open('auto-snippets.xml'))
   18.31 +
   18.32 +    def __init__(self, name, verbose, keep_change):
   18.33 +        self.name = os.path.normpath(name)
   18.34 +        self.verbose = verbose
   18.35 +        self.keep_change = keep_change
   18.36 +        
   18.37 +    def status(self, s):
   18.38 +        sys.stdout.write(s)
   18.39 +        if not s.endswith('\n'):
   18.40 +            sys.stdout.flush()
   18.41 +
   18.42 +    def rename_output(self, base, ignore=[]):
   18.43 +        mangle_re = re.compile('(?:' + '|'.join(ignore) + ')')
   18.44 +        def mangle(s):
   18.45 +            return mangle_re.sub('', s)
   18.46 +        def matchfp(fp1, fp2):
   18.47 +            while True:
   18.48 +                s1 = mangle(fp1.readline())
   18.49 +                s2 = mangle(fp2.readline())
   18.50 +                if cmp(s1, s2):
   18.51 +                    break
   18.52 +                if not s1:
   18.53 +                    return True
   18.54 +            return False
   18.55 +
   18.56 +        oldname = result_name(base + '.out')
   18.57 +        tmpname = result_name(base + '.tmp')
   18.58 +        errname = result_name(base + '.err')
   18.59 +        errfp = open(errname, 'w+')
   18.60 +        for line in open(tmpname):
   18.61 +            errfp.write(mangle_re.sub('', line))
   18.62 +        os.rename(tmpname, result_name(base + '.lxo'))
   18.63 +        errfp.seek(0)
   18.64 +        try:
   18.65 +            oldfp = open(oldname)
   18.66 +        except IOError, err:
   18.67 +            if err.errno != errno.ENOENT:
   18.68 +                raise
   18.69 +            os.rename(errname, oldname)
   18.70 +            return False
   18.71 +        if matchfp(oldfp, errfp):
   18.72 +            os.unlink(errname)
   18.73 +            return False
   18.74 +        else:
   18.75 +            print >> sys.stderr, '\nOutput of %s has changed!' % base
   18.76 +            if self.keep_change:
   18.77 +                os.rename(errname, oldname)
   18.78 +                return False
   18.79 +            else:
   18.80 +                os.system('diff -u %s %s 1>&2' % (oldname, errname))
   18.81 +            return True
   18.82 +
   18.83 +class static_example(example):
   18.84 +    def run(self):
   18.85 +        self.status('running %s\n' % self.name)
   18.86 +        s = open(self.name).read().rstrip()
   18.87 +        s = s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
   18.88 +        ofp = wopen(result_name(self.name + '.tmp'))
   18.89 +        ofp.write('<programlisting>')
   18.90 +        ofp.write(s)
   18.91 +        ofp.write('</programlisting>\n')
   18.92 +        ofp.close()
   18.93 +        self.rename_output(self.name)
   18.94 +        norm = self.name.replace(os.sep, '-')
   18.95 +        example.entities[
   18.96 +            '<!ENTITY %s SYSTEM "results/%s.out">' % (norm, norm)] = 1
   18.97 +
   18.98 +
   18.99 +class shell_example(example):
  18.100      shell = '/usr/bin/env bash'
  18.101      ps1 = '__run_example_ps1__ '
  18.102      ps2 = '__run_example_ps2__ '
  18.103 @@ -65,12 +145,8 @@
  18.104      
  18.105      timeout = 10
  18.106  
  18.107 -    entities = dict.fromkeys(l.rstrip() for l in open('auto-snippets.xml'))
  18.108 -
  18.109      def __init__(self, name, verbose, keep_change):
  18.110 -        self.name = name
  18.111 -        self.verbose = verbose
  18.112 -        self.keep_change = keep_change
  18.113 +        example.__init__(self, name, verbose, keep_change)
  18.114          self.poll = select.poll()
  18.115  
  18.116      def parse(self):
  18.117 @@ -83,11 +159,6 @@
  18.118                  yield cfp.getvalue()
  18.119                  cfp.seek(0)
  18.120                  cfp.truncate()
  18.121 -        
  18.122 -    def status(self, s):
  18.123 -        sys.stdout.write(s)
  18.124 -        if not s.endswith('\n'):
  18.125 -            sys.stdout.flush()
  18.126  
  18.127      def send(self, s):
  18.128          if self.verbose:
  18.129 @@ -153,12 +224,12 @@
  18.130          maybe_unlink(self.name + '.run')
  18.131  
  18.132          rcfile = os.path.join(tmpdir, '.hgrc')
  18.133 -        rcfp = open(rcfile, 'w')
  18.134 +        rcfp = wopen(rcfile)
  18.135          print >> rcfp, '[ui]'
  18.136          print >> rcfp, "username = Bryan O'Sullivan <bos@serpentine.com>"
  18.137          
  18.138          rcfile = os.path.join(tmpdir, '.bashrc')
  18.139 -        rcfp = open(rcfile, 'w')
  18.140 +        rcfp = wopen(rcfile)
  18.141          print >> rcfp, 'PS1="%s"' % self.ps1
  18.142          print >> rcfp, 'PS2="%s"' % self.ps2
  18.143          print >> rcfp, 'unset HISTFILE'
  18.144 @@ -248,8 +319,7 @@
  18.145                                      'SYSTEM "results/%s.out">'
  18.146                                      % (norm, norm)] = 1
  18.147                                  read_hint = ofp_basename + ' '
  18.148 -                                ofp = open(result_name(ofp_basename + '.tmp'),
  18.149 -                                           'w')
  18.150 +                                ofp = wopen(result_name(ofp_basename + '.tmp'))
  18.151                                  ofp.write('<screen>')
  18.152                              else:
  18.153                                  ofp = None
  18.154 @@ -297,52 +367,11 @@
  18.155                      elif os.WIFSIGNALED(rc):
  18.156                          print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc)
  18.157                  else:
  18.158 -                    open(result_name(self.name + '.run'), 'w')
  18.159 +                    wopen(result_name(self.name + '.run'))
  18.160                  return err
  18.161          finally:
  18.162              shutil.rmtree(tmpdir)
  18.163  
  18.164 -    def rename_output(self, base, ignore):
  18.165 -        mangle_re = re.compile('(?:' + '|'.join(ignore) + ')')
  18.166 -        def mangle(s):
  18.167 -            return mangle_re.sub('', s)
  18.168 -        def matchfp(fp1, fp2):
  18.169 -            while True:
  18.170 -                s1 = mangle(fp1.readline())
  18.171 -                s2 = mangle(fp2.readline())
  18.172 -                if cmp(s1, s2):
  18.173 -                    break
  18.174 -                if not s1:
  18.175 -                    return True
  18.176 -            return False
  18.177 -
  18.178 -        oldname = result_name(base + '.out')
  18.179 -        tmpname = result_name(base + '.tmp')
  18.180 -        errname = result_name(base + '.err')
  18.181 -        errfp = open(errname, 'w+')
  18.182 -        for line in open(tmpname):
  18.183 -            errfp.write(mangle_re.sub('', line))
  18.184 -        os.rename(tmpname, result_name(base + '.lxo'))
  18.185 -        errfp.seek(0)
  18.186 -        try:
  18.187 -            oldfp = open(oldname)
  18.188 -        except IOError, err:
  18.189 -            if err.errno != errno.ENOENT:
  18.190 -                raise
  18.191 -            os.rename(errname, oldname)
  18.192 -            return False
  18.193 -        if matchfp(oldfp, errfp):
  18.194 -            os.unlink(errname)
  18.195 -            return False
  18.196 -        else:
  18.197 -            print >> sys.stderr, '\nOutput of %s has changed!' % base
  18.198 -            if self.keep_change:
  18.199 -                os.rename(errname, oldname)
  18.200 -                return False
  18.201 -            else:
  18.202 -                os.system('diff -u %s %s 1>&2' % (oldname, errname))
  18.203 -            return True
  18.204 -
  18.205  def print_help(exit, msg=None):
  18.206      if msg:
  18.207          print >> sys.stderr, 'Error:', msg
  18.208 @@ -383,18 +412,20 @@
  18.209                  print >> sys.stderr, '%s: %s' % (a, err.strerror)
  18.210                  errs += 1
  18.211                  continue
  18.212 -            if stat.S_ISREG(st.st_mode) and st.st_mode & 0111:
  18.213 -                if example(a, verbose, keep_change).run():
  18.214 -                    errs += 1
  18.215 +            if stat.S_ISREG(st.st_mode):
  18.216 +                if st.st_mode & 0111:
  18.217 +                    if shell_example(a, verbose, keep_change).run():
  18.218 +                        errs += 1
  18.219 +                elif a.endswith('.lst'):
  18.220 +                    static_example(a, verbose, keep_change).run()
  18.221              else:
  18.222                  print >> sys.stderr, '%s: not a file, or not executable' % a
  18.223                  errs += 1
  18.224      elif run_all:
  18.225 -        names = os.listdir(path)
  18.226 +        names = glob.glob("*") + glob.glob("app*/*") + glob.glob("ch*/*")
  18.227          names.sort()
  18.228          for name in names:
  18.229 -            if name == 'run-example' or name.startswith('.'): continue
  18.230 -            if name.endswith('~'): continue
  18.231 +            if name == 'run-example' or name.endswith('~'): continue
  18.232              pathname = os.path.join(path, name)
  18.233              try:
  18.234                  st = os.lstat(pathname)
  18.235 @@ -403,14 +434,17 @@
  18.236                  if err.errno != errno.ENOENT:
  18.237                      raise
  18.238                  continue
  18.239 -            if stat.S_ISREG(st.st_mode) and st.st_mode & 0111:
  18.240 -                if example(pathname, verbose, keep_change).run():
  18.241 -                    errs += 1
  18.242 -        print >> open(os.path.join(path, '.run'), 'w'), time.asctime()
  18.243 +            if stat.S_ISREG(st.st_mode):
  18.244 +                if st.st_mode & 0111:
  18.245 +                    if shell_example(pathname, verbose, keep_change).run():
  18.246 +                        errs += 1
  18.247 +                elif pathname.endswith('.lst'):
  18.248 +                    static_example(pathname, verbose, keep_change).run()
  18.249 +        print >> wopen(os.path.join(path, '.run')), time.asctime()
  18.250      else:
  18.251          print_help(1, msg='no test names given, and --all not provided')
  18.252  
  18.253 -    fp = open('auto-snippets.xml', 'w')
  18.254 +    fp = wopen('auto-snippets.xml')
  18.255      for key in sorted(example.entities.iterkeys()):
  18.256          print >> fp, key
  18.257      fp.close()