hgbook

diff en/ch03-concepts.xml @ 654:1c13ed2130a7

Merge with http://hg.serpentine.com/mercurial/book
author Dongsheng Song <dongsheng.song@gmail.com>
date Mon Mar 30 16:23:33 2009 +0800 (2009-03-30)
parents 7e7c47481e4f 0b45854f0b7b
children e9ef075327c1
line diff
     1.1 --- a/en/ch03-concepts.xml	Fri Mar 20 16:43:35 2009 +0800
     1.2 +++ b/en/ch03-concepts.xml	Mon Mar 30 16:23:33 2009 +0800
     1.3 @@ -1,23 +1,23 @@
     1.4  <!-- vim: set filetype=docbkxml shiftwidth=2 autoindent expandtab tw=77 : -->
     1.5  
     1.6 -<chapter id="chap.concepts">
     1.7 +<chapter id="chap:concepts">
     1.8    <?dbhtml filename="behind-the-scenes.html"?>
     1.9    <title>Behind the scenes</title>
    1.10  
    1.11 -  <para>Unlike many revision control systems, the concepts upon which
    1.12 +  <para id="x_2e8">Unlike many revision control systems, the concepts upon which
    1.13      Mercurial is built are simple enough that it's easy to understand
    1.14      how the software really works.  Knowing this certainly isn't
    1.15      necessary, but I find it useful to have a <quote>mental
    1.16        model</quote> of what's going on.</para>
    1.17  
    1.18 -  <para>This understanding gives me confidence that Mercurial has been
    1.19 +  <para id="x_2e9">This understanding gives me confidence that Mercurial has been
    1.20      carefully designed to be both <emphasis>safe</emphasis> and
    1.21      <emphasis>efficient</emphasis>.  And just as importantly, if it's
    1.22      easy for me to retain a good idea of what the software is doing
    1.23      when I perform a revision control task, I'm less likely to be
    1.24      surprised by its behaviour.</para>
    1.25  
    1.26 -  <para>In this chapter, we'll initially cover the core concepts
    1.27 +  <para id="x_2ea">In this chapter, we'll initially cover the core concepts
    1.28      behind Mercurial's design, then continue to discuss some of the
    1.29      interesting details of its implementation.</para>
    1.30  
    1.31 @@ -27,7 +27,7 @@
    1.32      <sect2>
    1.33        <title>Tracking the history of a single file</title>
    1.34  
    1.35 -      <para>When Mercurial tracks modifications to a file, it stores
    1.36 +      <para id="x_2eb">When Mercurial tracks modifications to a file, it stores
    1.37  	the history of that file in a metadata object called a
    1.38  	<emphasis>filelog</emphasis>.  Each entry in the filelog
    1.39  	contains enough information to reconstruct one revision of the
    1.40 @@ -38,7 +38,7 @@
    1.41  	an index to help Mercurial to find a revision
    1.42  	efficiently.</para>
    1.43  
    1.44 -      <para>A file that is large, or has a lot of history, has its
    1.45 +      <para id="x_2ec">A file that is large, or has a lot of history, has its
    1.46  	filelog stored in separate data
    1.47  	(<quote><literal>.d</literal></quote> suffix) and index
    1.48  	(<quote><literal>.i</literal></quote> suffix) files.  For
    1.49 @@ -46,25 +46,23 @@
    1.50  	are combined in a single <quote><literal>.i</literal></quote>
    1.51  	file.  The correspondence between a file in the working
    1.52  	directory and the filelog that tracks its history in the
    1.53 -	repository is illustrated in figure <xref
    1.54 -	  endterm="fig.concepts.filelog.caption"
    1.55 -	  linkend="fig.concepts.filelog"/>.</para>
    1.56 -
    1.57 -      <informalfigure id="fig.concepts.filelog">
    1.58 -        <mediaobject>
    1.59 -          <imageobject><imagedata fileref="images/filelog.png"/></imageobject>
    1.60 -          <textobject><phrase>XXX add text</phrase></textobject>
    1.61 -          <caption><para id="fig.concepts.filelog.caption">Relationships between
    1.62 -            files in working directory and filelogs in repository</para>
    1.63 -          </caption>
    1.64 -        </mediaobject>
    1.65 -      </informalfigure>
    1.66 +	repository is illustrated in <xref
    1.67 +	  linkend="fig:concepts:filelog"/>.</para>
    1.68 +
    1.69 +      <figure id="fig:concepts:filelog">
    1.70 +	<title>Relationships between files in working directory and
    1.71 +	  filelogs in repository</title>
    1.72 +	<mediaobject>
    1.73 +	  <imageobject><imagedata fileref="figs/filelog.png"/></imageobject>
    1.74 +	  <textobject><phrase>XXX add text</phrase></textobject>
    1.75 +	</mediaobject>
    1.76 +      </figure>
    1.77  
    1.78      </sect2>
    1.79      <sect2>
    1.80        <title>Managing tracked files</title>
    1.81  
    1.82 -      <para>Mercurial uses a structure called a
    1.83 +      <para id="x_2ee">Mercurial uses a structure called a
    1.84  	<emphasis>manifest</emphasis> to collect together information
    1.85  	about the files that it tracks.  Each entry in the manifest
    1.86  	contains information about the files present in a single
    1.87 @@ -76,7 +74,7 @@
    1.88      <sect2>
    1.89        <title>Recording changeset information</title>
    1.90  
    1.91 -      <para>The <emphasis>changelog</emphasis> contains information
    1.92 +      <para id="x_2ef">The <emphasis>changelog</emphasis> contains information
    1.93  	about each changeset.  Each revision records who committed a
    1.94  	change, the changeset comment, other pieces of
    1.95  	changeset-related information, and the revision of the
    1.96 @@ -86,32 +84,30 @@
    1.97      <sect2>
    1.98        <title>Relationships between revisions</title>
    1.99  
   1.100 -      <para>Within a changelog, a manifest, or a filelog, each
   1.101 +      <para id="x_2f0">Within a changelog, a manifest, or a filelog, each
   1.102  	revision stores a pointer to its immediate parent (or to its
   1.103  	two parents, if it's a merge revision).  As I mentioned above,
   1.104  	there are also relationships between revisions
   1.105  	<emphasis>across</emphasis> these structures, and they are
   1.106  	hierarchical in nature.</para>
   1.107  
   1.108 -      <para>For every changeset in a repository, there is exactly one
   1.109 +      <para id="x_2f1">For every changeset in a repository, there is exactly one
   1.110  	revision stored in the changelog.  Each revision of the
   1.111  	changelog contains a pointer to a single revision of the
   1.112  	manifest.  A revision of the manifest stores a pointer to a
   1.113  	single revision of each filelog tracked when that changeset
   1.114 -	was created.  These relationships are illustrated in figure
   1.115 -	<xref endterm="fig.concepts.metadata.caption"
   1.116 -	  linkend="fig.concepts.metadata"/>.</para>
   1.117 -
   1.118 -      <informalfigure id="fig.concepts.metadata">
   1.119 -        <mediaobject>
   1.120 -          <imageobject><imagedata fileref="images/metadata.png"/></imageobject>
   1.121 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.122 -          <caption><para id="fig.concepts.metadata.caption">Metadata
   1.123 -            relationships</para></caption>
   1.124 -        </mediaobject>
   1.125 -      </informalfigure>
   1.126 -
   1.127 -      <para>As the illustration shows, there is
   1.128 +	was created.  These relationships are illustrated in
   1.129 +	<xref linkend="fig:concepts:metadata"/>.</para>
   1.130 +
   1.131 +      <figure id="fig:concepts:metadata">
   1.132 +	<title>Metadata relationships</title>
   1.133 +	<mediaobject>
   1.134 +	  <imageobject><imagedata fileref="figs/metadata.png"/></imageobject>
   1.135 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.136 +	</mediaobject>
   1.137 +      </figure>
   1.138 +
   1.139 +      <para id="x_2f3">As the illustration shows, there is
   1.140  	<emphasis>not</emphasis> a <quote>one to one</quote>
   1.141  	relationship between revisions in the changelog, manifest, or
   1.142  	filelog. If the manifest hasn't changed between two
   1.143 @@ -126,14 +122,14 @@
   1.144    <sect1>
   1.145      <title>Safe, efficient storage</title>
   1.146  
   1.147 -    <para>The underpinnings of changelogs, manifests, and filelogs are
   1.148 +    <para id="x_2f4">The underpinnings of changelogs, manifests, and filelogs are
   1.149        provided by a single structure called the
   1.150        <emphasis>revlog</emphasis>.</para>
   1.151  
   1.152      <sect2>
   1.153        <title>Efficient storage</title>
   1.154  
   1.155 -      <para>The revlog provides efficient storage of revisions using a
   1.156 +      <para id="x_2f5">The revlog provides efficient storage of revisions using a
   1.157  	<emphasis>delta</emphasis> mechanism.  Instead of storing a
   1.158  	complete copy of a file for each revision, it stores the
   1.159  	changes needed to transform an older revision into the new
   1.160 @@ -141,7 +137,7 @@
   1.161  	typically a fraction of a percent of the size of a full copy
   1.162  	of a file.</para>
   1.163  
   1.164 -      <para>Some obsolete revision control systems can only work with
   1.165 +      <para id="x_2f6">Some obsolete revision control systems can only work with
   1.166  	deltas of text files.  They must either store binary files as
   1.167  	complete snapshots or encoded into a text representation, both
   1.168  	of which are wasteful approaches.  Mercurial can efficiently
   1.169 @@ -149,16 +145,16 @@
   1.170  	doesn't need to treat text as special.</para>
   1.171  
   1.172      </sect2>
   1.173 -    <sect2 id="sec.concepts.txn">
   1.174 +    <sect2 id="sec:concepts:txn">
   1.175        <title>Safe operation</title>
   1.176  
   1.177 -      <para>Mercurial only ever <emphasis>appends</emphasis> data to
   1.178 +      <para id="x_2f7">Mercurial only ever <emphasis>appends</emphasis> data to
   1.179  	the end of a revlog file. It never modifies a section of a
   1.180  	file after it has written it.  This is both more robust and
   1.181  	efficient than schemes that need to modify or rewrite
   1.182  	data.</para>
   1.183  
   1.184 -      <para>In addition, Mercurial treats every write as part of a
   1.185 +      <para id="x_2f8">In addition, Mercurial treats every write as part of a
   1.186  	<emphasis>transaction</emphasis> that can span a number of
   1.187  	files.  A transaction is <emphasis>atomic</emphasis>: either
   1.188  	the entire transaction succeeds and its effects are all
   1.189 @@ -168,7 +164,7 @@
   1.190  	writing it, the reader will never see a partially written
   1.191  	result that might confuse it.</para>
   1.192  
   1.193 -      <para>The fact that Mercurial only appends to files makes it
   1.194 +      <para id="x_2f9">The fact that Mercurial only appends to files makes it
   1.195  	easier to provide this transactional guarantee.  The easier it
   1.196  	is to do stuff like this, the more confident you should be
   1.197  	that it's done correctly.</para>
   1.198 @@ -177,7 +173,7 @@
   1.199      <sect2>
   1.200        <title>Fast retrieval</title>
   1.201  
   1.202 -      <para>Mercurial cleverly avoids a pitfall common to all earlier
   1.203 +      <para id="x_2fa">Mercurial cleverly avoids a pitfall common to all earlier
   1.204  	revision control systems: the problem of <emphasis>inefficient
   1.205  	  retrieval</emphasis>. Most revision control systems store
   1.206  	the contents of a revision as an incremental series of
   1.207 @@ -188,16 +184,15 @@
   1.208  	file accumulates, the more revisions you must read, hence the
   1.209  	longer it takes to reconstruct a particular revision.</para>
   1.210  
   1.211 -      <informalfigure id="fig.concepts.snapshot">
   1.212 -        <mediaobject>
   1.213 -          <imageobject><imagedata fileref="images/snapshot.png"/></imageobject>
   1.214 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.215 -          <caption><para id="fig.concepts.snapshot.caption">Snapshot of
   1.216 -            a revlog, with incremental deltas</para></caption>
   1.217 -        </mediaobject>
   1.218 -      </informalfigure>
   1.219 -
   1.220 -      <para>The innovation that Mercurial applies to this problem is
   1.221 +      <figure id="fig:concepts:snapshot">
   1.222 +	<title>Snapshot of a revlog, with incremental deltas</title>
   1.223 +	<mediaobject>
   1.224 +	  <imageobject><imagedata fileref="figs/snapshot.png"/></imageobject>
   1.225 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.226 +	</mediaobject>
   1.227 +      </figure>
   1.228 +
   1.229 +      <para id="x_2fc">The innovation that Mercurial applies to this problem is
   1.230  	simple but effective.  Once the cumulative amount of delta
   1.231  	information stored since the last snapshot exceeds a fixed
   1.232  	threshold, it stores a new snapshot (compressed, of course),
   1.233 @@ -206,8 +201,7 @@
   1.234  	quickly.  This approach works so well that it has since been
   1.235  	copied by several other revision control systems.</para>
   1.236  
   1.237 -      <para>Figure <xref endterm="fig.concepts.snapshot.caption"
   1.238 -          linkend="fig.concepts.snapshot"/> illustrates
   1.239 +      <para id="x_2fd"><xref linkend="fig:concepts:snapshot"/> illustrates
   1.240  	the idea.  In an entry in a revlog's index file, Mercurial
   1.241  	stores the range of entries from the data file that it must
   1.242  	read to reconstruct a particular revision.</para>
   1.243 @@ -215,7 +209,7 @@
   1.244        <sect3>
   1.245  	<title>Aside: the influence of video compression</title>
   1.246  
   1.247 -	<para>If you're familiar with video compression or have ever
   1.248 +	<para id="x_2fe">If you're familiar with video compression or have ever
   1.249  	  watched a TV feed through a digital cable or satellite
   1.250  	  service, you may know that most video compression schemes
   1.251  	  store each frame of video as a delta against its predecessor
   1.252 @@ -224,7 +218,7 @@
   1.253  	  visual errors accumulate over the course of a number of
   1.254  	  inter-frame deltas.</para>
   1.255  
   1.256 -	<para>Because it's possible for a video stream to <quote>drop
   1.257 +	<para id="x_2ff">Because it's possible for a video stream to <quote>drop
   1.258  	    out</quote> occasionally due to signal glitches, and to
   1.259  	  limit the accumulation of artefacts introduced by the lossy
   1.260  	  compression process, video encoders periodically insert a
   1.261 @@ -240,24 +234,24 @@
   1.262      <sect2>
   1.263        <title>Identification and strong integrity</title>
   1.264  
   1.265 -      <para>Along with delta or snapshot information, a revlog entry
   1.266 +      <para id="x_300">Along with delta or snapshot information, a revlog entry
   1.267  	contains a cryptographic hash of the data that it represents.
   1.268  	This makes it difficult to forge the contents of a revision,
   1.269  	and easy to detect accidental corruption.</para>
   1.270  
   1.271 -      <para>Hashes provide more than a mere check against corruption;
   1.272 +      <para id="x_301">Hashes provide more than a mere check against corruption;
   1.273  	they are used as the identifiers for revisions.  The changeset
   1.274  	identification hashes that you see as an end user are from
   1.275  	revisions of the changelog.  Although filelogs and the
   1.276  	manifest also use hashes, Mercurial only uses these behind the
   1.277  	scenes.</para>
   1.278  
   1.279 -      <para>Mercurial verifies that hashes are correct when it
   1.280 +      <para id="x_302">Mercurial verifies that hashes are correct when it
   1.281  	retrieves file revisions and when it pulls changes from
   1.282  	another repository.  If it encounters an integrity problem, it
   1.283  	will complain and stop whatever it's doing.</para>
   1.284  
   1.285 -      <para>In addition to the effect it has on retrieval efficiency,
   1.286 +      <para id="x_303">In addition to the effect it has on retrieval efficiency,
   1.287  	Mercurial's use of periodic snapshots makes it more robust
   1.288  	against partial data corruption.  If a revlog becomes partly
   1.289  	corrupted due to a hardware error or system bug, it's often
   1.290 @@ -271,7 +265,7 @@
   1.291    <sect1>
   1.292      <title>Revision history, branching, and merging</title>
   1.293  
   1.294 -    <para>Every entry in a Mercurial revlog knows the identity of its
   1.295 +    <para id="x_304">Every entry in a Mercurial revlog knows the identity of its
   1.296        immediate ancestor revision, usually referred to as its
   1.297        <emphasis>parent</emphasis>.  In fact, a revision contains room
   1.298        for not one parent, but two.  Mercurial uses a special hash,
   1.299 @@ -279,14 +273,13 @@
   1.300        <quote>there is no parent here</quote>.  This hash is simply a
   1.301        string of zeroes.</para>
   1.302  
   1.303 -    <para>In figure <xref endterm="fig.concepts.revlog.caption"
   1.304 -        linkend="fig.concepts.revlog"/>, you can see
   1.305 +    <para id="x_305">In <xref linkend="fig:concepts:revlog"/>, you can see
   1.306        an example of the conceptual structure of a revlog.  Filelogs,
   1.307        manifests, and changelogs all have this same structure; they
   1.308        differ only in the kind of data stored in each delta or
   1.309        snapshot.</para>
   1.310  
   1.311 -    <para>The first revision in a revlog (at the bottom of the image)
   1.312 +    <para id="x_306">The first revision in a revlog (at the bottom of the image)
   1.313        has the null ID in both of its parent slots.  For a
   1.314        <quote>normal</quote> revision, its first parent slot contains
   1.315        the ID of its parent revision, and its second contains the null
   1.316 @@ -295,23 +288,22 @@
   1.317        revision that represents a merge between branches has two normal
   1.318        revision IDs in its parent slots.</para>
   1.319  
   1.320 -    <informalfigure id="fig.concepts.revlog">
   1.321 +    <figure id="fig:concepts:revlog">
   1.322 +      <title>The conceptual structure of a revlog</title>
   1.323        <mediaobject>
   1.324 -        <imageobject><imagedata fileref="images/revlog.png"/></imageobject>
   1.325 -        <textobject><phrase>XXX add text</phrase></textobject>        
   1.326 -	<caption><para id="fig.concepts.revlog.caption">Revision in revlog</para>
   1.327 -	</caption>
   1.328 +	<imageobject><imagedata fileref="figs/revlog.png"/></imageobject>
   1.329 +	<textobject><phrase>XXX add text</phrase></textobject>
   1.330        </mediaobject>
   1.331 -    </informalfigure>
   1.332 +    </figure>
   1.333  
   1.334    </sect1>
   1.335    <sect1>
   1.336      <title>The working directory</title>
   1.337  
   1.338 -    <para>In the working directory, Mercurial stores a snapshot of the
   1.339 +    <para id="x_307">In the working directory, Mercurial stores a snapshot of the
   1.340        files from the repository as of a particular changeset.</para>
   1.341  
   1.342 -    <para>The working directory <quote>knows</quote> which changeset
   1.343 +    <para id="x_308">The working directory <quote>knows</quote> which changeset
   1.344        it contains.  When you update the working directory to contain a
   1.345        particular changeset, Mercurial looks up the appropriate
   1.346        revision of the manifest to find out which files it was tracking
   1.347 @@ -320,13 +312,13 @@
   1.348        those files, with the same contents it had when the changeset
   1.349        was committed.</para>
   1.350  
   1.351 -    <para>The <emphasis>dirstate</emphasis> contains Mercurial's
   1.352 +    <para id="x_309">The <emphasis>dirstate</emphasis> contains Mercurial's
   1.353        knowledge of the working directory.  This details which
   1.354        changeset the working directory is updated to, and all of the
   1.355        files that Mercurial is tracking in the working
   1.356        directory.</para>
   1.357  
   1.358 -    <para>Just as a revision of a revlog has room for two parents, so
   1.359 +    <para id="x_30a">Just as a revision of a revlog has room for two parents, so
   1.360        that it can represent either a normal revision (with one parent)
   1.361        or a merge of two earlier revisions, the dirstate has slots for
   1.362        two parents.  When you use the <command role="hg-cmd">hg
   1.363 @@ -342,38 +334,35 @@
   1.364      <sect2>
   1.365        <title>What happens when you commit</title>
   1.366  
   1.367 -      <para>The dirstate stores parent information for more than just
   1.368 +      <para id="x_30b">The dirstate stores parent information for more than just
   1.369  	book-keeping purposes.  Mercurial uses the parents of the
   1.370  	dirstate as <emphasis>the parents of a new
   1.371  	  changeset</emphasis> when you perform a commit.</para>
   1.372  
   1.373 -      <informalfigure id="fig.concepts.wdir">
   1.374 -        <mediaobject>
   1.375 -          <imageobject><imagedata fileref="images/wdir.png"/></imageobject>
   1.376 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.377 -          <caption><para id="fig.concepts.wdir.caption">The working
   1.378 -            directory can have two parents</para></caption>
   1.379 -        </mediaobject>
   1.380 -      </informalfigure>
   1.381 -
   1.382 -      <para>Figure <xref endterm="fig.concepts.wdir.caption"
   1.383 -          linkend="fig.concepts.wdir"/> shows the
   1.384 +      <figure id="fig:concepts:wdir">
   1.385 +	<title>The working directory can have two parents</title>
   1.386 +	<mediaobject>
   1.387 +	  <imageobject><imagedata fileref="figs/wdir.png"/></imageobject>
   1.388 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.389 +	</mediaobject>
   1.390 +      </figure>
   1.391 +
   1.392 +      <para id="x_30d"><xref linkend="fig:concepts:wdir"/> shows the
   1.393  	normal state of the working directory, where it has a single
   1.394  	changeset as parent.  That changeset is the
   1.395  	<emphasis>tip</emphasis>, the newest changeset in the
   1.396  	repository that has no children.</para>
   1.397  
   1.398 -      <informalfigure id="fig.concepts.wdir-after-commit">
   1.399 -        <mediaobject>
   1.400 -          <imageobject><imagedata fileref="images/wdir-after-commit.png"/>
   1.401 -          </imageobject>
   1.402 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.403 -          <caption><para id="fig.concepts.wdir-after-commit.caption">The working
   1.404 -            directory gains new parents after a commit</para></caption>
   1.405 -        </mediaobject>
   1.406 -      </informalfigure>
   1.407 -
   1.408 -      <para>It's useful to think of the working directory as
   1.409 +      <figure id="fig:concepts:wdir-after-commit">
   1.410 +	<title>The working directory gains new parents after a
   1.411 +	  commit</title>
   1.412 +	<mediaobject>
   1.413 +	  <imageobject><imagedata fileref="figs/wdir-after-commit.png"/></imageobject>
   1.414 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.415 +	</mediaobject>
   1.416 +      </figure>
   1.417 +
   1.418 +      <para id="x_30f">It's useful to think of the working directory as
   1.419  	<quote>the changeset I'm about to commit</quote>.  Any files
   1.420  	that you tell Mercurial that you've added, removed, renamed,
   1.421  	or copied will be reflected in that changeset, as will
   1.422 @@ -381,12 +370,11 @@
   1.423  	the new changeset will have the parents of the working
   1.424  	directory as its parents.</para>
   1.425  
   1.426 -      <para>After a commit, Mercurial will update the parents of the
   1.427 -	working directory, so that the first parent is the ID of the
   1.428 -	new changeset, and the second is the null ID.  This is shown
   1.429 -	in figure <xref endterm="fig.concepts.wdir-after-commit.caption"
   1.430 -	  linkend="fig.concepts.wdir-after-commit"/>.
   1.431 -	Mercurial
   1.432 +      <para id="x_310">After a commit, Mercurial will update the
   1.433 +	parents of the working directory, so that the first parent is
   1.434 +	the ID of the new changeset, and the second is the null ID.
   1.435 +	This is shown in <xref
   1.436 +	  linkend="fig:concepts:wdir-after-commit"/>. Mercurial
   1.437  	doesn't touch any of the files in the working directory when
   1.438  	you commit; it just modifies the dirstate to note its new
   1.439  	parents.</para>
   1.440 @@ -395,7 +383,7 @@
   1.441      <sect2>
   1.442        <title>Creating a new head</title>
   1.443  
   1.444 -      <para>It's perfectly normal to update the working directory to a
   1.445 +      <para id="x_311">It's perfectly normal to update the working directory to a
   1.446  	changeset other than the current tip.  For example, you might
   1.447  	want to know what your project looked like last Tuesday, or
   1.448  	you could be looking through changesets to see which one
   1.449 @@ -404,43 +392,39 @@
   1.450  	interested in, and then examine the files in the working
   1.451  	directory directly to see their contents as they were when you
   1.452  	committed that changeset.  The effect of this is shown in
   1.453 -	figure <xref endterm="fig.concepts.wdir-pre-branch.caption"
   1.454 -	  linkend="fig.concepts.wdir-pre-branch"/>.</para>
   1.455 -
   1.456 -      <informalfigure id="fig.concepts.wdir-pre-branch">
   1.457 -        <mediaobject>
   1.458 -          <imageobject><imagedata fileref="images/wdir-pre-branch.png"/>
   1.459 -          </imageobject>
   1.460 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.461 -          <caption><para id="fig.concepts.wdir-pre-branch.caption">The working
   1.462 -            directory, updated to an older changeset</para></caption>
   1.463 -        </mediaobject>
   1.464 -      </informalfigure>
   1.465 -
   1.466 -      <para>Having updated the working directory to an older
   1.467 -	changeset, what happens if you make some changes, and then
   1.468 -	commit?  Mercurial behaves in the same way as I outlined
   1.469 +	<xref linkend="fig:concepts:wdir-pre-branch"/>.</para>
   1.470 +
   1.471 +      <figure id="fig:concepts:wdir-pre-branch">
   1.472 +	<title>The working directory, updated to an older
   1.473 +	  changeset</title>
   1.474 +	<mediaobject>
   1.475 +	  <imageobject><imagedata fileref="figs/wdir-pre-branch.png"/></imageobject>
   1.476 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.477 +	</mediaobject>
   1.478 +      </figure>
   1.479 +
   1.480 +      <para id="x_313">Having updated the working directory to an
   1.481 +	older changeset, what happens if you make some changes, and
   1.482 +	then commit?  Mercurial behaves in the same way as I outlined
   1.483  	above.  The parents of the working directory become the
   1.484  	parents of the new changeset.  This new changeset has no
   1.485  	children, so it becomes the new tip.  And the repository now
   1.486  	contains two changesets that have no children; we call these
   1.487  	<emphasis>heads</emphasis>.  You can see the structure that
   1.488 -	this creates in figure <xref
   1.489 -	  endterm="fig.concepts.wdir-branch.caption"
   1.490 -	  linkend="fig.concepts.wdir-branch"/>.</para>
   1.491 -
   1.492 -      <informalfigure id="fig.concepts.wdir-branch">
   1.493 -        <mediaobject>
   1.494 -          <imageobject><imagedata fileref="images/wdir-branch.png"/>
   1.495 -          </imageobject>
   1.496 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.497 -          <caption><para id="fig.concepts.wdir-branch.caption">After a
   1.498 -            commit made while synced to an older changeset</para></caption>
   1.499 -        </mediaobject>
   1.500 -      </informalfigure>
   1.501 +	this creates in <xref
   1.502 +	  linkend="fig:concepts:wdir-branch"/>.</para>
   1.503 +
   1.504 +      <figure id="fig:concepts:wdir-branch">
   1.505 +	<title>After a commit made while synced to an older
   1.506 +	  changeset</title>
   1.507 +	<mediaobject>
   1.508 +	  <imageobject><imagedata fileref="figs/wdir-branch.png"/></imageobject>
   1.509 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.510 +	</mediaobject>
   1.511 +      </figure>
   1.512  
   1.513        <note>
   1.514 -	<para>  If you're new to Mercurial, you should keep in mind a
   1.515 +	<para id="x_315">  If you're new to Mercurial, you should keep in mind a
   1.516  	  common <quote>error</quote>, which is to use the <command
   1.517  	    role="hg-cmd">hg pull</command> command without any
   1.518  	  options.  By default, the <command role="hg-cmd">hg
   1.519 @@ -452,7 +436,7 @@
   1.520  	  a new head, because your working directory isn't synced to
   1.521  	  whatever the current tip is.</para>
   1.522  
   1.523 -	<para>  I put the word <quote>error</quote> in quotes because
   1.524 +	<para id="x_316">  I put the word <quote>error</quote> in quotes because
   1.525  	  all that you need to do to rectify this situation is
   1.526  	  <command role="hg-cmd">hg merge</command>, then <command
   1.527  	    role="hg-cmd">hg commit</command>.  In other words, this
   1.528 @@ -466,67 +450,66 @@
   1.529      <sect2>
   1.530        <title>Merging heads</title>
   1.531  
   1.532 -      <para>When you run the <command role="hg-cmd">hg merge</command>
   1.533 -	command, Mercurial leaves the first parent of the working
   1.534 -	directory unchanged, and sets the second parent to the
   1.535 -	changeset you're merging with, as shown in figure <xref
   1.536 -	  endterm="fig.concepts.wdir-merge.caption" 
   1.537 -	  linkend="fig.concepts.wdir-merge"/>.</para>
   1.538 -
   1.539 -      <informalfigure id="fig.concepts.wdir-merge">
   1.540 -        <mediaobject>
   1.541 -          <imageobject><imagedata fileref="images/wdir-merge.png"/>
   1.542 -          </imageobject>
   1.543 -          <textobject><phrase>XXX add text</phrase></textobject>
   1.544 -          <caption><para id="fig.concepts.wdir-merge.caption">Merging two
   1.545 -            heads</para></caption>
   1.546 -        </mediaobject>
   1.547 -      </informalfigure>
   1.548 -
   1.549 -      <para>Mercurial also has to modify the working directory, to
   1.550 +      <para id="x_317">When you run the <command role="hg-cmd">hg
   1.551 +	  merge</command> command, Mercurial leaves the first parent
   1.552 +	of the working directory unchanged, and sets the second parent
   1.553 +	to the changeset you're merging with, as shown in <xref
   1.554 +	  linkend="fig:concepts:wdir-merge"/>.</para>
   1.555 +
   1.556 +      <figure id="fig:concepts:wdir-merge">
   1.557 +	<title>Merging two heads</title>
   1.558 +	<mediaobject>
   1.559 +	  <imageobject>
   1.560 +	    <imagedata fileref="figs/wdir-merge.png"/>
   1.561 +	  </imageobject>
   1.562 +	  <textobject><phrase>XXX add text</phrase></textobject>
   1.563 +	</mediaobject>
   1.564 +      </figure>
   1.565 +
   1.566 +      <para id="x_319">Mercurial also has to modify the working directory, to
   1.567  	merge the files managed in the two changesets.  Simplified a
   1.568  	little, the merging process goes like this, for every file in
   1.569  	the manifests of both changesets.</para>
   1.570        <itemizedlist>
   1.571 -	<listitem><para>If neither changeset has modified a file, do
   1.572 +	<listitem><para id="x_31a">If neither changeset has modified a file, do
   1.573  	    nothing with that file.</para>
   1.574  	</listitem>
   1.575 -	<listitem><para>If one changeset has modified a file, and the
   1.576 +	<listitem><para id="x_31b">If one changeset has modified a file, and the
   1.577  	    other hasn't, create the modified copy of the file in the
   1.578  	    working directory.</para>
   1.579  	</listitem>
   1.580 -	<listitem><para>If one changeset has removed a file, and the
   1.581 +	<listitem><para id="x_31c">If one changeset has removed a file, and the
   1.582  	    other hasn't (or has also deleted it), delete the file
   1.583  	    from the working directory.</para>
   1.584  	</listitem>
   1.585 -	<listitem><para>If one changeset has removed a file, but the
   1.586 +	<listitem><para id="x_31d">If one changeset has removed a file, but the
   1.587  	    other has modified the file, ask the user what to do: keep
   1.588  	    the modified file, or remove it?</para>
   1.589  	</listitem>
   1.590 -	<listitem><para>If both changesets have modified a file,
   1.591 +	<listitem><para id="x_31e">If both changesets have modified a file,
   1.592  	    invoke an external merge program to choose the new
   1.593  	    contents for the merged file.  This may require input from
   1.594  	    the user.</para>
   1.595  	</listitem>
   1.596 -	<listitem><para>If one changeset has modified a file, and the
   1.597 +	<listitem><para id="x_31f">If one changeset has modified a file, and the
   1.598  	    other has renamed or copied the file, make sure that the
   1.599  	    changes follow the new name of the file.</para>
   1.600  	</listitem></itemizedlist>
   1.601 -      <para>There are more details&emdash;merging has plenty of corner
   1.602 +      <para id="x_320">There are more details&emdash;merging has plenty of corner
   1.603  	cases&emdash;but these are the most common choices that are
   1.604  	involved in a merge.  As you can see, most cases are
   1.605  	completely automatic, and indeed most merges finish
   1.606  	automatically, without requiring your input to resolve any
   1.607  	conflicts.</para>
   1.608  
   1.609 -      <para>When you're thinking about what happens when you commit
   1.610 +      <para id="x_321">When you're thinking about what happens when you commit
   1.611  	after a merge, once again the working directory is <quote>the
   1.612  	  changeset I'm about to commit</quote>.  After the <command
   1.613  	  role="hg-cmd">hg merge</command> command completes, the
   1.614  	working directory has two parents; these will become the
   1.615  	parents of the new changeset.</para>
   1.616  
   1.617 -      <para>Mercurial lets you perform multiple merges, but you must
   1.618 +      <para id="x_322">Mercurial lets you perform multiple merges, but you must
   1.619  	commit the results of each individual merge as you go.  This
   1.620  	is necessary because Mercurial only tracks two parents for
   1.621  	both revisions and the working directory.  While it would be
   1.622 @@ -539,7 +522,7 @@
   1.623    <sect1>
   1.624      <title>Other interesting design features</title>
   1.625  
   1.626 -    <para>In the sections above, I've tried to highlight some of the
   1.627 +    <para id="x_323">In the sections above, I've tried to highlight some of the
   1.628        most important aspects of Mercurial's design, to illustrate that
   1.629        it pays careful attention to reliability and performance.
   1.630        However, the attention to detail doesn't stop there.  There are
   1.631 @@ -552,13 +535,13 @@
   1.632      <sect2>
   1.633        <title>Clever compression</title>
   1.634  
   1.635 -      <para>When appropriate, Mercurial will store both snapshots and
   1.636 +      <para id="x_324">When appropriate, Mercurial will store both snapshots and
   1.637  	deltas in compressed form.  It does this by always
   1.638  	<emphasis>trying to</emphasis> compress a snapshot or delta,
   1.639  	but only storing the compressed version if it's smaller than
   1.640  	the uncompressed version.</para>
   1.641  
   1.642 -      <para>This means that Mercurial does <quote>the right
   1.643 +      <para id="x_325">This means that Mercurial does <quote>the right
   1.644  	  thing</quote> when storing a file whose native form is
   1.645  	compressed, such as a <literal>zip</literal> archive or a JPEG
   1.646  	image.  When these types of files are compressed a second
   1.647 @@ -566,7 +549,7 @@
   1.648  	once-compressed form, and so Mercurial will store the plain
   1.649  	<literal>zip</literal> or JPEG.</para>
   1.650  
   1.651 -      <para>Deltas between revisions of a compressed file are usually
   1.652 +      <para id="x_326">Deltas between revisions of a compressed file are usually
   1.653  	larger than snapshots of the file, and Mercurial again does
   1.654  	<quote>the right thing</quote> in these cases.  It finds that
   1.655  	such a delta exceeds the threshold at which it should store a
   1.656 @@ -577,7 +560,7 @@
   1.657        <sect3>
   1.658  	<title>Network recompression</title>
   1.659  
   1.660 -	<para>When storing revisions on disk, Mercurial uses the
   1.661 +	<para id="x_327">When storing revisions on disk, Mercurial uses the
   1.662  	  <quote>deflate</quote> compression algorithm (the same one
   1.663  	  used by the popular <literal>zip</literal> archive format),
   1.664  	  which balances good speed with a respectable compression
   1.665 @@ -585,7 +568,7 @@
   1.666  	  network connection, Mercurial uncompresses the compressed
   1.667  	  revision data.</para>
   1.668  
   1.669 -	<para>If the connection is over HTTP, Mercurial recompresses
   1.670 +	<para id="x_328">If the connection is over HTTP, Mercurial recompresses
   1.671  	  the entire stream of data using a compression algorithm that
   1.672  	  gives a better compression ratio (the Burrows-Wheeler
   1.673  	  algorithm from the widely used <literal>bzip2</literal>
   1.674 @@ -595,7 +578,7 @@
   1.675  	  transferred, yielding better network performance over almost
   1.676  	  all kinds of network.</para>
   1.677  
   1.678 -	<para>(If the connection is over <command>ssh</command>,
   1.679 +	<para id="x_329">(If the connection is over <command>ssh</command>,
   1.680  	  Mercurial <emphasis>doesn't</emphasis> recompress the
   1.681  	  stream, because <command>ssh</command> can already do this
   1.682  	  itself.)</para>
   1.683 @@ -605,20 +588,20 @@
   1.684      <sect2>
   1.685        <title>Read/write ordering and atomicity</title>
   1.686  
   1.687 -      <para>Appending to files isn't the whole story when it comes to
   1.688 -	guaranteeing that a reader won't see a partial write.  If you
   1.689 -	recall figure <xref endterm="fig.concepts.metadata.caption"
   1.690 -	linkend="fig.concepts.metadata"/>, revisions in the
   1.691 -	changelog point to revisions in the manifest, and revisions in
   1.692 -	the manifest point to revisions in filelogs.  This hierarchy
   1.693 -	is deliberate.</para>
   1.694 -
   1.695 -      <para>A writer starts a transaction by writing filelog and
   1.696 +      <para id="x_32a">Appending to files isn't the whole story when
   1.697 +	it comes to guaranteeing that a reader won't see a partial
   1.698 +	write.  If you recall <xref linkend="fig:concepts:metadata"/>,
   1.699 +	revisions in
   1.700 +	the changelog point to revisions in the manifest, and
   1.701 +	revisions in the manifest point to revisions in filelogs.
   1.702 +	This hierarchy is deliberate.</para>
   1.703 +
   1.704 +      <para id="x_32b">A writer starts a transaction by writing filelog and
   1.705  	manifest data, and doesn't write any changelog data until
   1.706  	those are finished.  A reader starts by reading changelog
   1.707  	data, then manifest data, followed by filelog data.</para>
   1.708  
   1.709 -      <para>Since the writer has always finished writing filelog and
   1.710 +      <para id="x_32c">Since the writer has always finished writing filelog and
   1.711  	manifest data before it writes to the changelog, a reader will
   1.712  	never read a pointer to a partially written manifest revision
   1.713  	from the changelog, and it will never read a pointer to a
   1.714 @@ -628,7 +611,7 @@
   1.715      <sect2>
   1.716        <title>Concurrent access</title>
   1.717  
   1.718 -      <para>The read/write ordering and atomicity guarantees mean that
   1.719 +      <para id="x_32d">The read/write ordering and atomicity guarantees mean that
   1.720  	Mercurial never needs to <emphasis>lock</emphasis> a
   1.721  	repository when it's reading data, even if the repository is
   1.722  	being written to while the read is occurring. This has a big
   1.723 @@ -637,7 +620,7 @@
   1.724  	safely all at once, no matter whether it's being written to or
   1.725  	not.</para>
   1.726  
   1.727 -      <para>The lockless nature of reading means that if you're
   1.728 +      <para id="x_32e">The lockless nature of reading means that if you're
   1.729  	sharing a repository on a multi-user system, you don't need to
   1.730  	grant other local users permission to
   1.731  	<emphasis>write</emphasis> to your repository in order for
   1.732 @@ -650,7 +633,7 @@
   1.733  	which of course makes for all kinds of nasty and annoying
   1.734  	security and administrative problems.)</para>
   1.735  
   1.736 -      <para>Mercurial uses locks to ensure that only one process can
   1.737 +      <para id="x_32f">Mercurial uses locks to ensure that only one process can
   1.738  	write to a repository at a time (the locking mechanism is safe
   1.739  	even over filesystems that are notoriously hostile to locking,
   1.740  	such as NFS).  If a repository is locked, a writer will wait
   1.741 @@ -664,7 +647,7 @@
   1.742        <sect3>
   1.743  	<title>Safe dirstate access</title>
   1.744  
   1.745 -	<para>As with revision data, Mercurial doesn't take a lock to
   1.746 +	<para id="x_330">As with revision data, Mercurial doesn't take a lock to
   1.747  	  read the dirstate file; it does acquire a lock to write it.
   1.748  	  To avoid the possibility of reading a partially written copy
   1.749  	  of the dirstate file, Mercurial writes to a file with a
   1.750 @@ -679,17 +662,17 @@
   1.751      <sect2>
   1.752        <title>Avoiding seeks</title>
   1.753  
   1.754 -      <para>Critical to Mercurial's performance is the avoidance of
   1.755 +      <para id="x_331">Critical to Mercurial's performance is the avoidance of
   1.756  	seeks of the disk head, since any seek is far more expensive
   1.757  	than even a comparatively large read operation.</para>
   1.758  
   1.759 -      <para>This is why, for example, the dirstate is stored in a
   1.760 +      <para id="x_332">This is why, for example, the dirstate is stored in a
   1.761  	single file.  If there were a dirstate file per directory that
   1.762  	Mercurial tracked, the disk would seek once per directory.
   1.763  	Instead, Mercurial reads the entire single dirstate file in
   1.764  	one step.</para>
   1.765  
   1.766 -      <para>Mercurial also uses a <quote>copy on write</quote> scheme
   1.767 +      <para id="x_333">Mercurial also uses a <quote>copy on write</quote> scheme
   1.768  	when cloning a repository on local storage.  Instead of
   1.769  	copying every revlog file from the old repository into the new
   1.770  	repository, it makes a <quote>hard link</quote>, which is a
   1.771 @@ -700,7 +683,7 @@
   1.772  	one repository is using the file, so Mercurial makes a new
   1.773  	copy of the file that is private to this repository.</para>
   1.774  
   1.775 -      <para>A few revision control developers have pointed out that
   1.776 +      <para id="x_334">A few revision control developers have pointed out that
   1.777  	this idea of making a complete private copy of a file is not
   1.778  	very efficient in its use of storage.  While this is true,
   1.779  	storage is cheap, and this method gives the highest
   1.780 @@ -714,21 +697,21 @@
   1.781      <sect2>
   1.782        <title>Other contents of the dirstate</title>
   1.783  
   1.784 -      <para>Because Mercurial doesn't force you to tell it when you're
   1.785 +      <para id="x_335">Because Mercurial doesn't force you to tell it when you're
   1.786  	modifying a file, it uses the dirstate to store some extra
   1.787  	information so it can determine efficiently whether you have
   1.788  	modified a file.  For each file in the working directory, it
   1.789  	stores the time that it last modified the file itself, and the
   1.790  	size of the file at that time.</para>
   1.791  
   1.792 -      <para>When you explicitly <command role="hg-cmd">hg
   1.793 +      <para id="x_336">When you explicitly <command role="hg-cmd">hg
   1.794  	  add</command>, <command role="hg-cmd">hg remove</command>,
   1.795  	<command role="hg-cmd">hg rename</command> or <command
   1.796  	  role="hg-cmd">hg copy</command> files, Mercurial updates the
   1.797  	dirstate so that it knows what to do with those files when you
   1.798  	commit.</para>
   1.799  
   1.800 -      <para>When Mercurial is checking the states of files in the
   1.801 +      <para id="x_337">When Mercurial is checking the states of files in the
   1.802  	working directory, it first checks a file's modification time.
   1.803  	If that has not changed, the file must not have been modified.
   1.804  	If the file's size has changed, the file must have been