view en/concepts.tex @ 108:e0b961975c5e

First bit of concepts chapter.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 09 Nov 2006 10:11:31 -0800
parents b8539d91c84d
children 1b67dc96f27a
line wrap: on
line source

\chapter{Behind the scenes}
\label{chap:concepts}

Unlike many revision control systems, the concepts upon which
Mercurial is built are simple enough that it's easy to understand how
the software really works.  Knowing this certainly isn't necessary,
but I find it useful to have a ``mental model'' of what's going on.

\section{Tracking the history of a single file}

When Mercurial tracks modifications to a file, it stores the history
of that file in a metadata object called a \emph{filelog}.  Each entry
in the filelog contains enough information to reconstruct one revision
of the file that is being tracked.  Filelogs are stored as files in
the \sdirname{.hg/data} directory.  A filelog contains two kinds of
information: revision data, and an index to help Mercurial to find a
revision efficiently.  

For small files without much history, the revision data and index are
combined in a single file (with a ``\texttt{.i}'' suffix).  A file
that is large, or has a lot of history, has its filelog stored as
separate data (``\texttt{.d}'' suffix) and index (``\texttt{.i}''
suffix) files.  The correspondence between a file in the working
directory and the filelog that tracks its history in the repository is
illustrated in figure~\ref{fig:concepts:filelog}.

\begin{figure}[ht]
  \centering
  \grafix{filelog}
  \caption{Relationships between files in working directory and
    filelogs in repository}
  \label{fig:concepts:filelog}
\end{figure}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "00book"
%%% End: