annotate Hg.tex @ 9:2155510c62f3

A version formatted with Latex. And spellchecked.
author Jim Hague <jim.hague@acm.org>
date Fri, 22 May 2009 10:23:40 +0100
parents
children 2e4d690ffabb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
1 \documentclass[a4paper]{article}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
2 \usepackage{pslatex}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
3 \usepackage{url}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
4
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
5 \newcommand{\standout}[1]{
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
6 {\begin{center} \large \textbf{#1} \end{center}}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
7 }
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
8
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
9 \setlength{\parskip}{2mm}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
10 \setlength{\parindent}{0mm}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
11
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
12 \begin{document}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
13 \title{Inside a distributed version control system}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
14 \author{Jim Hague\\
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
15 \texttt{jim.hague@acm.org}}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
16 \date{May 2009}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
17 \maketitle
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
18
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
19 \section{Preamble}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
20 Grinton Lodge is a Youth Hostel that sits on an exposed hillside just
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
21 above the small hamlet of Grinton in Swaledale, in the Yorkshire Dales
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
22 National Park. A former Victorian shooting lodge, it now welcomes
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
23 walkers and other travellers from around the world.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
24
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
25 Tonight, a Wednesday in mid-November, is not one of its busiest
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
26 nights. Kat, the duty staff member, tells me that there is a small
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
27 corporate team-building group in the annex. There's no sign of them at
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
28 present. Otherwise, that portion of the world that has beaten a path
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
29 to the door of this grand building today consists of just me. And Kat
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
30 goes home soon.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
31
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
32 The November CVu, removed from its wrappers and read yesterday, lies
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
33 in my bag. Taunting me. Go on, it says, if you've ever going to put
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
34 finger to keyboard in the name of CVu, well, tonight you are out of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
35 excuses.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
36
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
37 Bugger.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
38
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
39 \section{Let's look into Mercurial}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
40 If you're at all interested in version control systems~--- and any
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
41 software developer not using one daily is a strange beast indeed~---
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
42 you'll at least have become vaguely aware in the last few years of the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
43 growing maturity of the latest group of version control systems
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
44 offering funky new stuff. These are the distributed version control
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
45 systems (DVCS). There is more to them than just their headline
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
46 attributes, being able to check history and do checkins while
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
47 disconnected from a central server, but these are damm useful to start
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
48 with.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
49
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
50 When I first heard about DVCS, it wasn't immediately obvious to me (to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
51 put it mildly) how they would work. After years of using a centralised
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
52 version control system, I had rough mental model of what went on. But
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
53 how do you cope without the central server forcing ordering onto the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
54 changes?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
55
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
56 Since then I've started using Mercurial\footnote{
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
57 \url{http://www.selenic.com/mercurial}}.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
58 Mercurial is a DVCS. It's one of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
59 three DVCSs that have gained significant popularity in the last few
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
60 years, the other two being Git\footnote{\url{http://git-scm.com}} and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
61 Bazaar\footnote{\url{http://bazaar-vcs.org/}}.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
62 I switched a significant work project over
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
63 to Mercurial (from Subversion) in mid-2007, because a customer site
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
64 required on-site work but could not allow access back to the company
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
65 VPN. I chose Mercurial for a variety of reasons which I won't bore you
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
66 with here\footnote{
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
67 OK, if you must know:
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
68 \begin{itemize}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
69 \item Implementability. I needed the system to work on Windows, Linux and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
70 AIX. The latter was not one of the directly supported platforms for
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
71 any of the candidates. Git's implementation uses a horde of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
72 tools. Bazaar requires only Python, but required Python 2.4 while IBM
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
73 stubbornly still supplies only Python 2.3. Mercurial requires Python
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
74 2.3 or greater, and uses some C for speed.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
75 \item Simplicity. My users used Subversion daily, but did not generally
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
76 have much experience with other VCS. From the command line,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
77 Mercurial's core operations will be familiar to a Subversion
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
78 user. This is also true of Bazaar, but was less true of Git. Git has
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
79 improved in this matter since then, but a Mr Winder of this parish
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
80 tells me that it's still possible to seriously embarrass
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
81 yourself. There was also a lack of Windows support for Git at the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
82 time.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
83 \item Speed. Mercurial is fast. In the same ballpark as Git. Bazaar
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
84 wasn't, and although it has improved significantly, has, in my
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
85 estimation, added user complexity in the process, and at the time
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
86 of writing is still off the pace for some operations.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
87 \item Documentation. At the time, Bryan O'Sullivan's excellent Mercurial
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
88 book (\url{http://hgbook.red-bean.com}) was a clear winner for best
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
89 documentation.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
90 \end{itemize}}.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
91
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
92 What I want to do in this article is give you an insight into how a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
93 DVCS works. OK, so specifically I'm going to be talking about
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
94 Mercurial, but Git and Bazaar attack the problem in a similar way. But
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
95 first I'd better give you some idea of how you use Mercurial.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
96
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
97 \subsection{The 5 minute Mercurial overview}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
98 \subsubsection{The basics}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
99 I think it unlikely that someone possessing the taste and discernment
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
100 to be reading CVu would not be familiar with at least one version
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
101 control system. So, while I want to give you a flavour of what it's
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
102 like to use, I'm not going to hang about. If you'd like a proper
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
103 introduction, or you don't follow something, I thoroughly recommend
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
104 you consult the Mercurial book.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
105
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
106 To start using Mercurial to keep track of a project.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
107
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
108 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
109 $ hg init
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
110 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
111 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
112
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
113 This creates the repository root in the current directory.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
114
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
115 Like CVS\footnote{\url{http://www.nongnu.org/cvs/}}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
116 with its \texttt{CVS} directory and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
117 Subversion\footnote{\url{http://subversion.tigris.org/}}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
118 with its \texttt{.svn}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
119 directory, Mercurial keeps its private data in a directory. Mercifully there is
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
120 only one of these, in the top level of your project. And rather than
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
121 holding details of where the actual repository is to be found, the \texttt{.hg}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
122 directory holds the entire repository.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
123
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
124 Next you need to specify the files you want Mercurial to track.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
125
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
126 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
127 $ echo "There was a gibbon one morning" > pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
128 $ hg add pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
129 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
130 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
131
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
132 As you might expect, this marks the files as to be added. And as you
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
133 might also expect, you need to commit to record the added files in the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
134 repository. The commit comment can be supplied on the command line; if
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
135 you don't supply a comment, you'll be dropped into an editor to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
136 provide one.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
137
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
138 There is a suggested format for these messages~--- a one line summary
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
139 followed by any more required detail on following lines. By default
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
140 Mercurial will only display the first line of commit messages when
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
141 listing changes. In these examples I'll stick to terse messages, and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
142 I'll enter them from the command line.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
143
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
144 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
145 $ hg commit -m "My Pome" -u "Jim Hague <jim.hague@acm.org>"
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
146 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
147 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
148
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
149 Mercurial records the user making the change as part of the change
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
150 information. It is usual to give your name and email address as I've
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
151 done here. You can imagine, though, that constantly having to repeat
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
152 this is a bit tedious, so you can set a default user name in a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
153 configuration file. Mercurial keeps global, user and repository
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
154 configurations, and it can go in any of those.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
155
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
156 As with Subversion, after further edits you see how your working copy
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
157 differs from the repository.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
158
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
159 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
160 $ hg status
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
161 M pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
162 $ hg diff
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
163 diff -r 33596ef855c1 pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
164 --- a/pome.txt Wed Apr 23 22:36:33 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
165 +++ b/pome.txt Wed Apr 23 22:48:01 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
166 @@ -1,1 +1,2 @@ There was a gibbon one morning
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
167 There was a gibbon one morning
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
168 +said "I think I will fly to the moon".
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
169 $ hg commit -m "A great second line"
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
170 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
171 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
172
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
173 And look through a log of changes.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
174
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
175 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
176 $ hg log
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
177 changeset: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
178 tag: tip
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
179 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
180 date: Wed Apr 23 22:49:10 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
181 summary: A great second line
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
182
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
183 changeset: 0:33596ef855c1
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
184 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
185 date: Wed Apr 23 22:36:33 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
186 summary: My Pome
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
187
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
188 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
189 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
190
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
191 There are some items here that need an explanation.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
192
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
193 The changeset identifier is in fact two identifiers separated by a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
194 colon. The first is the sequence number of the changeset in the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
195 repository, and is directly comparable to the change number in a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
196 Subversion repository. The second is a globally unique identifier for
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
197 that change. As the change is copied from one repository to another
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
198 (this is a distributed system, remember, even if we haven't come to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
199 that bit yet), its sequence number in any particular repository will
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
200 change, but the global identifier will always remain the same.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
201
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
202 \texttt{tip} is a Mercurial term. It means simply the most recent change.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
203
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
204 Want to rename a file?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
205
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
206 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
207 $ hg mv pome.txt poem.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
208 $ hg status
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
209 A poem.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
210 R pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
211 $ hg commit -m "Rename my file"
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
212 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
213 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
214 (The command to rename a file is actually \texttt{hg rename},
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
215 but Mercurial saves Unix-trained fingers from
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
216 typing embarrassment.)
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
217
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
218 At this point you may be wondering about directories. \texttt{hg mkdir}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
219 perhaps? Well, no. Mercurial only tracks files. To be sure, the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
220 directory a file occupies is tracked, but effectively only as a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
221 component of the file name. This has the slightly unexpected result
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
222 that you can't record an empty directory in your repository.\footnote{
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
223 I tripped over this converting a work Subversion
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
224 repository. One possibility is to create a placeholder file in the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
225 directory. In the event I created the directory (which receives build
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
226 products) as part of the build instead.}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
227
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
228 Given this, and the status output above that suggests strongly that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
229 Mercurial treats a rename as a copy followed by a delete, you may be
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
230 worried that Mercurial won't cope at all well with rearranging your
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
231 repository. Relax. Mercurial does store the details of the rename as
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
232 part of the changeset, and copes very well with rearrangements\footnote{
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
233 The Mercurial designers justify not dealing with
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
234 directories as first class objects by pointing out that provided you
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
235 can correctly move files about in the tree, the other reasons for
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
236 tracking directories are uncommon and do not in their opinion justify
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
237 the considerable added complexity. So far I've found no reason to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
238 doubt that judgement.}.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
239
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
240 Want to rewind the working copy to a previous revision?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
241
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
242 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
243 $ hg update -r 1
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
244 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
245 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
246 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
247
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
248 \texttt{hg update} updates the working files. In this case I'm specifying
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
249 that I want to go back to local changeset 1. I could also have typed
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
250 \texttt{-r 3d65e7a57890}, or even \texttt{-r 3d};
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
251 when specifying the global change
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
252 identifier you only need to type enough digits to make it unique.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
253
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
254 This is all very well, but it's not exactly distributed, is it?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
255
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
256 \subsubsection{Going distributed}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
257 A version control system goes Distributed by allowing multiple copies
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
258 of the repository to exist, and work to be done in all those
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
259 repositories in parallel. So when you start work on an existing
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
260 project, the first thing to do is to get your own copy of the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
261 repository.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
262
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
263 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
264 elsewhere$ hg clone ssh://jim.home.net/Poem Jim-Poem
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
265 updating working directory
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
266 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
267 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
268
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
269 Mercurial lets you access other repositories via the file system, over http or
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
270 over ssh.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
271
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
272 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
273 elsewhere$ cd Jim-Poem
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
274 elsewhere$ hg log
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
275 changeset: 3:a065eb26e6b9
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
276 tag: tip
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
277 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
278 date: Thu Apr 24 18:52:31 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
279 summary: Rename my file
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
280
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
281 changeset: 2:ff97668b7422
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
282 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
283 date: Thu Apr 24 18:50:22 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
284 summary: Finished first verse
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
285
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
286 changeset: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
287 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
288 date: Wed Apr 23 22:49:10 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
289 summary: A great second line
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
290
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
291 changeset: 0:33596ef855c1
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
292 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
293 date: Wed Apr 23 22:36:33 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
294 summary: My Pome
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
295
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
296 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
297 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
298
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
299 \texttt{hg clone} is aptly named. It creates a new repository that contains
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
300 exactly the same changes as the source repository. You can make a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
301 clone just by copying your project directory, if you're confident
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
302 nothing else will access it during the copy. \texttt{hg clone} saves you this
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
303 worry, and sets the default push/pull location in the new repo to the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
304 cloned repo.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
305
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
306 From that point, you use \texttt{hg pull} to collect changes from other
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
307 places into your repo (though note it does not by default update your
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
308 working copy), and, as you might guess, \texttt{hg push} shoves your changes
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
309 into a foreign repository. By default these will act on the repository
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
310 you cloned from, but you can specify any other repository.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
311
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
312 More on those in a moment. First, though, I want to show you something
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
313 you can't do in Subversion. Start with the repository with 4 changes
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
314 we just cloned. I want to focus on the first couple of lines, so I'll
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
315 wind the working copy back to the point where only those lines exist.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
316
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
317 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
318 $ hg update -r 1
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
319 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
320 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
321 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
322
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
323 And make a change.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
324
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
325 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
326 $ hg diff
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
327 diff -r 3d65e7a57890 pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
328 --- a/pome.txt Wed Apr 23 22:49:10 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
329 +++ b/pome.txt Thu Apr 24 19:13:14 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
330 @@ -1,2 +1,2 @@ There was a gibbon one morning
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
331 -There was a gibbon one morning
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
332 -said "I think I will fly to the moon".
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
333 +There was a baboon who one afternoon
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
334 +said "I think I will fly to the sun".
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
335 $ hg commit -m "Better first two lines"
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
336 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
337 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
338
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
339 The alert among you will have sat up at that. Well done! Yes, there's
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
340 something very worrying. How can I commit a change at an old point?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
341 If you try this in Subversion, it will complain mightily about your
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
342 file being out of date. But Mercurial just went ahead and did
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
343 something. The Bazaar experts among you will know that in Bazaar, if
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
344 you use \texttt{bzr revert -r} to bring the working copy to a past revision,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
345 make a change and commit, then your latest version will be the past
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
346 revision plus your change. Perhaps that's what Mercurial did?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
347
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
348 No. What Mercurial did is central to Mercurial's view of the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
349 world. You took your working copy back to an old changeset, and then
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
350 committed a fresh change based at that changeset. Mercurial actually
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
351 did just what you asked it to do, no more and no less. Let's see the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
352 initial evidence.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
353
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
354 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
355 $ hg heads
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
356 changeset: 4:267d32f158b3
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
357 tag: tip
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
358 parent: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
359 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
360 date: Thu Apr 24 19:13:59 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
361 summary: Better first two lines
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
362
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
363 changeset: 3:a065eb26e6b9
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
364 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
365 date: Thu Apr 24 18:52:31 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
366 summary: Rename my file
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
367
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
368 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
369 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
370
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
371 Time for some more Mercurial terminology. You can think of a \texttt{head} in
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
372 Mercurial as the most recent change on a branch. In Mercurial, a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
373 branch is simply what happens when you commit a change that has as its
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
374 parent a change that already has a child. Mercurial has a standard
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
375 extension \texttt{hg glog} which uses some ASCII art to show the current
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
376 state:
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
377
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
378 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
379 $ hg glog
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
380 @ changeset: 4:267d32f158b3
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
381 | tag: tip
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
382 | parent: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
383 | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
384 | date: Thu Apr 24 19:13:59 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
385 | summary: Better first two lines
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
386 |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
387 | o changeset: 3:a065eb26e6b9
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
388 | | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
389 | | date: Thu Apr 24 18:52:31 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
390 | | summary: Rename my file
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
391 | |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
392 | o changeset: 2:ff97668b7422
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
393 |/ user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
394 | date: Thu Apr 24 18:50:22 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
395 | summary: Finished first verse
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
396 |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
397 o changeset: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
398 | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
399 | date: Wed Apr 23 22:49:10 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
400 | summary: A great second line
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
401 |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
402 o changeset: 0:33596ef855c1
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
403 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
404 date: Wed Apr 23 22:36:33 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
405 summary: My Pome
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
406
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
407 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
408 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
409
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
410 \texttt{hg view} shows a nicer graphical view\footnote{Though, being
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
411 Tcl/Tk based, not that much nicer.}.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
412
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
413 So the change is in there. It's the latest change, and is simply on a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
414 different branch to the other changes.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
415
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
416 Almost invariably, you will want to bring everything back together and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
417 merge the branches. A merge is a change that combines two heads back
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
418 into one. It prepares an updated working directory with the merged
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
419 contents of the two heads for you to review and, if satisfactory,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
420 commit.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
421
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
422 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
423 $ hg merge
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
424 merging pome.txt and poem.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
425 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
426 (branch merge, don't forget to commit)
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
427 $ cat poem.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
428 There was a baboon who one afternoon
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
429 said "I think I will fly to the sun".
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
430 So with two great palms strapped to his arms,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
431 he started his takeoff run.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
432 $ hg commit -m "Merge first line branch"
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
433 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
434 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
435
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
436 (I'm no poet. The poem is, of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
437 course, \textit{Silly Old Baboon} by the late, great, Spike
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
438 Milligan. From \textit{A Book of Milliganimals}, Puffin, 1971.)
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
439
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
440 Here's the ASCII art again showing what just happened.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
441 Oh, and notice in the above that Mercurial has done the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
442 right thing with regard to the rename.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
443
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
444 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
445 $ hg glog
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
446 @ changeset: 5:792ab970fc80
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
447 |\ tag: tip
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
448 | | parent: 4:267d32f158b3
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
449 | | parent: 3:a065eb26e6b9
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
450 | | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
451 | | date: Thu Apr 24 19:29:53 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
452 | | summary: Merge first line branch
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
453 | |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
454 | o changeset: 4:267d32f158b3
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
455 | | parent: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
456 | | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
457 | | date: Thu Apr 24 19:13:59 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
458 | | summary: Better first two lines
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
459 | |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
460 o | changeset: 3:a065eb26e6b9
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
461 | | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
462 | | date: Thu Apr 24 18:52:31 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
463 | | summary: Rename my file
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
464 | |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
465 o | changeset: 2:ff97668b7422
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
466 |/ user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
467 | date: Thu Apr 24 18:50:22 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
468 | summary: Finished first verse
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
469 |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
470 o changeset: 1:3d65e7a57890
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
471 | user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
472 | date: Wed Apr 23 22:49:10 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
473 | summary: A great second line
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
474 |
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
475 o changeset: 0:33596ef855c1
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
476 user: Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
477 date: Wed Apr 23 22:36:33 2008 +0100
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
478 summary: My Pome
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
479
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
480 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
481 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
482
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
483 So, our little branch change has now been merged back, and we have a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
484 single line of development again. Notice that unlike the other
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
485 changesets, changeset 5 has two parent changesets, indicating it is a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
486 merge changeset. You can only merge two branches in one operation; or
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
487 putting it another way, a changeset can have a maximum of two parents.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
488
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
489 This behaviour is absolutely central to Mercurial's philosophy. If a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
490 change is committed that takes as its starting point a change that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
491 already has a child, then a branch gets created. Working with
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
492 Mercurial, branches get created frequently, and equally frequently
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
493 merged back. As befits any frequent operation, both are easy to do.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
494
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
495 You're probably thinking at this point that this making a commit onto
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
496 an old version is a slightly strange thing to do, and you'd be right.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
497 But that's exactly what's going to happen the moment you go
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
498 distributed. Two people working independently with their own
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
499 repositories are going to make commits based, typically, on the latest
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
500 changes they happen to have incorporated into their tree. To be
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
501 Distributed, a DVCS has to deal with this. Mercurial faces it head-on.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
502 When you pull changes into your repo (or someone else pushes them), if
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
503 any of the changes overlap~--- are both based on the same base change~---
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
504 you get extra heads, and it's up to you to let these extra heads live
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
505 or merge, as you please.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
506
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
507 In practice this is more manageable then you might think. Consider a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
508 typical Mercurial usage, where the 'master' repo sits on a known
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
509 server, and everyone pulls changes from the master and pushes their
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
510 own efforts to the master. But default Mercurial won't let you push if
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
511 the receiving repo will gain an extra head as a result, so you
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
512 typically pull (and do any required merging) just before
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
513 pushing. Subversion users will recognised this pattern. Subversion
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
514 won't let you commit a change if your working copy is not at the very
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
515 latest revision, so the Subversion user will update, and merge if
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
516 necessary, just before committing.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
517
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
518 What, then, about a branch in the conventional sense of '1.0
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
519 maintenance branch'? Typically in Mercurial you'd handle this by
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
520 keeping a separate cloned repository for those changes. Cloning is
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
521 fast, and if local uses hard links where possible on filesystems that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
522 support them, so isn't necessarily extravagant on disc space. You can,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
523 if you prefer, handle them all in a single repo with 'named
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
524 branches', but cloning is definitely simpler.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
525
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
526 OK, so now you know the basics of using Mercurial. We can proceed to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
527 looking at how this magic is achieved. In particular, where does this
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
528 magic globally unique identifier for a change come from?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
529
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
530 \subsection{Inside the Mercurial repo}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
531 The way Mercurial handles its repo is really quite simple.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
532
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
533 That's simple, as in 'most things are simple once you know the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
534 answer'. I found the explanation helpful\footnote{For the curious,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
535 Bryan O'Sullivan's excellent Mercurial book
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
536 has a chapter on the subject, and the Mercurial website has a fair amount
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
537 of detail too.}, so this section attempts
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
538 the 10,000ft (FL100 if you prefer) view of Mercurial.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
539
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
540 First remember that any file or component can only have one or two
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
541 parents. You can't merge more than one other branch at once.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
542
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
543 We start with the basic building block, which Mercurial calls a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
544 revlog. A revlog is a thing that holds a file and all the changes in
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
545 the file history\footnote{For any non-trivial file, this will
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
546 actually be two files on the disc, a data file and an index.}. The
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
547 revlog stores the differences between successive versions
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
548 of the file, though it will periodically store a complete version of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
549 the file instead of a difference, so that the content of any
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
550 particular file version can always be reconstructed without excessive
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
551 effort.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
552
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
553 Under the secret-squirrel Mercurial \texttt{.hg} directory at the top of your
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
554 project is a store which holds a revlog for each file in your
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
555 project. So you have the complete history of the project locally. No
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
556 more round trips to the server.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
557
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
558 Both the differences between successive versions and the periodic
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
559 complete versions of a file are compressed before storing. This is
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
560 surprisingly effective at minimising the storage requirements this
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
561 entire history of your project. I have a small Java project handy,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
562 comprising a little over 300 source modules. There are 5 branches plus
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
563 the mainline, and some 1920 commits in all. A Subversion checkout of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
564 the current mainline takes 51Mb. Converting the project to Mercurial
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
565 yields a Mercurial repository that takes 60Mb, so a little
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
566 bigger. Remember, though, that the Mercurial repository includes not
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
567 just the working copy, but also the entire history of the project.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
568
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
569 Any point in the evolution of a revlog can be uniquely identified with
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
570 a nodeid. This is simply the SHA1 hash of the current file contents
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
571 concatenated with the nodeids of one or both parents of the current
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
572 revision. Note that this way, two file states are identical if and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
573 only if the file contents are the same *and* the file has the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
574 same history.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
575
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
576 Here's a dump of a revlog index:
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
577
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
578 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
579 $ hg debugindex .hg/store/data/pome.txt.i
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
580 rev offset length base linkrev nodeid p1 p2
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
581 0 0 32 0 0 6bbbd5d6cc53 000000000000 000000000000
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
582 1 32 51 0 1 83d266583303 6bbbd5d6cc53 000000000000
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
583 2 83 84 0 2 14a54ec34bb6 83d266583303 000000000000
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
584 3 167 76 3 4 dc4df776b38b 83d266583303 000000000000
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
585 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
586 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
587
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
588 Note here that a file state can have two parents. If both the parent
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
589 nodeids are non-null, the file state has two parents, and the state is
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
590 therefore the result of a merge.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
591
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
592 Let's dump out a revlog at a particular revision:
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
593
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
594 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
595 $ hg debugdata .hg/store/data/pome.txt.i 2
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
596 There was a gibbon one morning
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
597 said "I think I will fly to the moon".
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
598 So with two great palms strapped to his arms,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
599 he started his takeoff run.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
600 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
601 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
602
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
603 The next component is the manifest. This is simply a list of all the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
604 files in the project, together with their current nodeids. The
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
605 manifest is a file, held in a revlog. The nodeid of the manifest,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
606 therefore, identifies the project filesystem at a particular point.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
607
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
608 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
609 $ hg debugdata .hg/store/00manifest.i 5
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
610 poem.txt5168b1a5e2f44aa4e0f164e170820845183f50c8
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
611 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
612 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
613
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
614 Finally we have the changeset. This is the atomic collection of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
615 changes to a repository that leads to a new revision. The changeset
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
616 info includes the nodeid of the corresponding manifest, the timestamp
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
617 and committer ID, a list of changed files and a comment. The changeset
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
618 also includes the nodeid of the parent changeset, or the two parents
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
619 if the change is a merge. The changeset description is held in a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
620 revlog, the changelog.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
621
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
622 \begin{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
623 $ hg debugdata .hg/store/00changelog.i 5
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
624 1ccc11b6f7308cc8fa1573c2f3811a4710c91e3e
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
625 Jim Hague <jim.hague@acm.org>
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
626 1209061793 -3600
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
627 poem.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
628 pome.txt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
629
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
630 Merge first line branch
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
631 $
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
632 \end{verbatim}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
633
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
634 The nodeid of the changeset, therefore, gives us a globally unique
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
635 identifier for any particular change. Changesets have a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
636 Subversion-like incrementing change number, but it is peculiar to that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
637 repository. The nodeid, however, is global.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
638
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
639 One more detail remains to complete the picture. How do we get back
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
640 from a particular file change to find the responsible changeset? Each
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
641 revlog change has a linkrev entry that does just this.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
642
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
643 So, now we have a repository with a history of the changes applied to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
644 that repository. Each change has a unique identifier. If we find that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
645 change in another repository, it means that at the point in the other
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
646 repository we have exactly the same state; the file contents and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
647 history are identical.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
648
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
649 At this point we can see how pulling changes from another repository
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
650 works. Mercurial has to determine which changesets in the source
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
651 repository are missing in the target repository. To do this, for each
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
652 head in the source repo it has to find the most recent change in that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
653 head that it already present in the target repo, and get any remaining
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
654 changes after that point. These changes are then copied over and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
655 applied.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
656
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
657 The Mercurial revlog format has proved remarkably durable. Since the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
658 first release of Mercurial in April 2005, these have been a total of 5
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
659 changes to the file format. However, of those, all but one have been
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
660 changes to the handling of file names. The most recent change, in
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
661 October 2008, and its predecessor in December 2006, were both
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
662 introduced purely to cope with Windows specific issues. The one change
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
663 that touched the data structures described above was in April 2006. The
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
664 format introduced, RevLogNG, changed only the details of index data
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
665 held, not the overall design. The chief Mercurial developer, Matt
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
666 Mackall, notes that the code in present-day Mercurial devoted to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
667 reading the old format comprises 28 lines of Python. Compared with,
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
668 say, the early tribulations of Subversion and the switch from \texttt{bdfs} to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
669 \texttt{fsfs}, this is an impressive record.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
670
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
671 \section{Reflections on going distributed}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
672 It's nearly traditional at this stage in an introduction to DVCS to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
673 demonstrate several different workflow scenarios that you can build
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
674 with a DVCS. Which makes the important point that a DVCS can be
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
675 adapted to your workflow in a way that is at best unwieldy with a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
676 CVCS. I intend, though, to break with tradition here.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
677
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
678 By this stage, I hope you can see that distributing version control
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
679 works by introducing branches where development takes place in
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
680 parallel. Mercurial treats these branches as arising naturally from
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
681 the commits made and transferred between repositories. Both Git and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
682 Bazaar take a slightly different viewpoint, and explicitly generate a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
683 fresh branch for work in a particular repositories. But in both cases
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
684 the underlying principle of identifying changes by a globally unique
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
685 identifier and resolving parallel development by merges between
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
686 overlapping changes is the same. And all three can be used in a truly
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
687 distributed manner, with full history and the ability to commit being
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
688 available locally.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
689
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
690 So instead of chatter on about workflows, I want instead to reflect on
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
691 the consequences all this has for that all-important question of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
692 whether a DVCS is a suitable vehicle for your data.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
693
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
694 The first is a minor and rather obvious point. If you want to store
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
695 files that are very large and which change often in your DVCS, then
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
696 all the compression in the world is unlikely to stop the storage
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
697 requirements for the full project history from becoming uncomfortably
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
698 large, particularly if the files are not very compressible to start
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
699 with.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
700
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
701 The second, and main, point is that there is an important question you
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
702 need to ask about your data. We've seen that a DVCS relies on
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
703 branching and merging to weave its magic. So take a close look at your
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
704 data, and ask:
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
705
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
706 \standout{Will It Merge?}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
707
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
708 The subset of plain old text which comprises program source
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
709 code requires some human oversight, but will merge automatically
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
710 well enough for the process to be well within the bounds of the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
711 possible.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
712
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
713 Unfortunately when we move further afield mergeability becomes a rarer
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
714 commodity. I nearly began the previous paragraph by stating that
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
715 plain old text will merge well enough. Then Doubt set in~--- what about
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
716 XML? Or BASE64 encoded content?
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
717
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
718 Of course, merge doesn't necessarily have to be textual merge. I am
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
719 told that Word can be used to diff and merge two Word \texttt{.doc} files, a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
720 data format notorious for its binary impenetrability. As long as some
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
721 suitable merge agent is available, and the DVCS can be configured to
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
722 use it for data of a particular type\footnote{Mercurial can have the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
723 merge and diff tools specified with reference to the file extension on
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
724 which they operate~--- I assume Bazaar and Git are similar.}, then there
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
725 is no bar to successful DVCS use.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
726
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
727 Before this reliance on mergeability causes you to dismiss DVCS out of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
728 hand, reflect. A CVCS can only handle non-mergeable data by acting as
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
729 a versioned file store; in other words, having as the only available
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
730 merge option the use of one or other of the merge candidates in its
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
731 entirety. Useful though a versioned file store can be, it cannot be
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
732 considered a full-featured version control system. By treating the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
733 offending unmergeable files as external to the DVCS, or with careful
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
734 workflow~--- disabling the distributed and mergeable potentials~--- a DVCS
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
735 can deal with these files, but only at a cost of its distributedness
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
736 or its version control system-ness. In this it differs little from a
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
737 CVCS.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
738
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
739 So, for all data you want to version control, let your battle cry be:
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
740
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
741 \standout{Will It Merge?}
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
742
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
743 At this point, I have an urge to don lab coat and safety goggles and
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
744 be videoed attempting to mechanically merge data in a variety of
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
745 different formats. Frankly, this is unlikely to be as exciting at
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
746 blending iPhones\footnote{\url{http://www.willitblend.com}},
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
747 but from a system development point of view it's rather more
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
748 important. And, I think gives us a large clue as to one of the
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
749 reasons for the continuing
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
750 popularity of Plain Old Text as a source code representation mechanism.
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
751
2155510c62f3 A version formatted with Latex. And spellchecked.
Jim Hague <jim.hague@acm.org>
parents:
diff changeset
752 \end{document}