hgbook

diff en/concepts.tex @ 112:2fcead053b7a

More. Concept. Fun.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Nov 13 13:21:29 2006 -0800 (2006-11-13)
parents 34b8b7a15ea1
children a0f57b3e677e
line diff
     1.1 --- a/en/concepts.tex	Fri Nov 10 15:32:33 2006 -0800
     1.2 +++ b/en/concepts.tex	Mon Nov 13 13:21:29 2006 -0800
     1.3 @@ -12,6 +12,10 @@
     1.4  the software is doing when I perform a revision control task, I'm less
     1.5  likely to be surprised by its behaviour.
     1.6  
     1.7 +In this chapter, we'll initially cover the core concepts behind
     1.8 +Mercurial's design, then continue to discuss some of the interesting
     1.9 +details of its implementation.
    1.10 +
    1.11  \section{Mercurial's historical record}
    1.12  
    1.13  \subsection{Tracking the history of a single file}
    1.14 @@ -174,19 +178,23 @@
    1.15  the next key frame is received.  Also, the accumulation of encoding
    1.16  errors restarts anew with each key frame.
    1.17  
    1.18 -\subsection{Strong integrity}
    1.19 +\subsection{Identification and strong integrity}
    1.20  
    1.21  Along with delta or snapshot information, a revlog entry contains a
    1.22  cryptographic hash of the data that it represents.  This makes it
    1.23  difficult to forge the contents of a revision, and easy to detect
    1.24 -accidental corruption.  The hash that Mercurial uses is SHA-1, which
    1.25 -is 160 bits long.  Although all revision data is hashed, the changeset
    1.26 +accidental corruption.  
    1.27 +
    1.28 +Hashes provide more than a mere check against corruption; they are
    1.29 +used as the identifiers for revisions.  The changeset identification
    1.30  hashes that you see as an end user are from revisions of the
    1.31 -changelog.  Manifest and file hashes are only used behind the scenes.
    1.32 -
    1.33 -Mercurial checks these hashes when retrieving file revisions and when
    1.34 -pulling changes from a repository.  If it encounters an integrity
    1.35 -problem, it will complain and stop whatever it's doing.
    1.36 +changelog.  Although filelogs and the manifest also use hashes,
    1.37 +Mercurial only uses these behind the scenes.
    1.38 +
    1.39 +Mercurial verifies that hashes are correct when it retrieves file
    1.40 +revisions and when it pulls changes from another repository.  If it
    1.41 +encounters an integrity problem, it will complain and stop whatever
    1.42 +it's doing.
    1.43  
    1.44  In addition to the effect it has on retrieval efficiency, Mercurial's
    1.45  use of periodic snapshots makes it more robust against partial data
    1.46 @@ -220,6 +228,35 @@
    1.47  amount of data that Mercurial needs to read, which yields large
    1.48  performance improvements compared to other revision control systems.
    1.49  
    1.50 +\section{Revision history, branching,
    1.51 +  and merging}
    1.52 +
    1.53 +Every entry in a Mercurial revlog knows the identity of its immediate
    1.54 +ancestor revision, usually referred to as its \emph{parent}.  In fact,
    1.55 +a revision contains room for not one parent, but two.  Mercurial uses
    1.56 +a special hash, called the ``null ID'', to represent the idea ``there
    1.57 +is no parent here''.  This hash is simply a string of zeroes.
    1.58 +
    1.59 +In figure~\ref{fig:concepts:revlog}, you can see an example of the
    1.60 +conceptual structure of a revlog.  Filelogs, manifests, and changelogs
    1.61 +all have this same structure; they differ only in the kind of data
    1.62 +stored in each delta or snapshot.
    1.63 +
    1.64 +The first revision in a revlog (at the bottom of the image) has the
    1.65 +null ID in both of its parent slots.  For a ``normal'' revision, its
    1.66 +first parent slot contains the ID of its parent revision, and its
    1.67 +second contains the null ID, indicating that the revision has only one
    1.68 +real parent.  Any two revisions that have the same parent ID are
    1.69 +branches.  A revision that represents a merge between branches has two
    1.70 +normal revision IDs in its parent slots.
    1.71 +
    1.72 +\begin{figure}[ht]
    1.73 +  \centering
    1.74 +  \grafix{revlog}
    1.75 +  \caption{}
    1.76 +  \label{fig:concepts:revlog}
    1.77 +\end{figure}
    1.78 +
    1.79  \section{Other interesting design features}
    1.80  
    1.81  In the sections above, I've tried to highlight some of the most