comparison text/quick_start.txt @ 192:3b95da26a544

quick start: Included and partly reworked the mail from Martin Geisler for understanding Mercurial.
author Arne Babenhauserheide <bab@draketo.de>
date Thu, 04 Jun 2009 23:46:59 +0200
parents e288850bd825
children 124758f16b96
comparison
equal deleted inserted replaced
191:e288850bd825 192:3b95da26a544
28 28
29 I you want more than this quick overview, please have a look at our longer [guide](). 29 I you want more than this quick overview, please have a look at our longer [guide]().
30 30
31 == Part 2: Understanding Mercurial == 31 == Part 2: Understanding Mercurial ==
32 32
33 ... compile the great mails from M. Geisler ... 33 Let's look at some of the basic concepts of Mercurial to get a better understanding of its internals:
34
35 * Like in Subversion, history consists of a number of commits. They're
36 called changesets in Mercurial.
37
38 * Subversion requires a strict linear ordering of the commits and
39 gives nice linear revision numbers to them. So revision N has only
40 one child revision, rN+1.
41
42 This is simple, but it requires a central server to make sure that
43 everybody agrees on the revision numbers.
44
45 * Mercurial generalizes this by letting each changeset have multiple
46 children. If I work alone and make commits I'll make
47
48 C1 --> C2 --> C3
49
50 by making three commits. The commit C3 with no children is a "head".
51 It is also the newest changeset in the repository -- called "tip".
52
53 If I shared C1 with you and you started your work from that, your
54 commits will build a repository like this:
55
56 C1 --> C2' --> C3'
57
58 Here C3' is a head in your repository and I don't know anything
59 about C2' and C3' yet.
60
61 * If I pull from you, or you push to me, the two repositories are
62 compared. By default, all missing changesets are transferred. This
63 is all there is to push/pull: compare two graphs of changesets and
64 transfer the missing ones.
65
66 After a pull from you my repository will look like this:
67
68 /-> C2 --> C3
69 C1 -<
70 \-> C2' --> C3'
71
72 Here C1 has two child changesets, and the repository has two heads
73 since the development has diverged.
74
75 The changeset C3' will be the new tip since it is the newest
76 changeset in the repository. Note that tip is always a head, but a
77 head need not be the tip.
78
79 * Having two heads suggest that someone should merge them -- otherwise
80 the changes from one will never be combined with the changed made in
81 the other head.
82
83 When merging with 'hg merge' the task is to figure out the canonical
84 way to combine the changesets. If the changes do not overlap this is
85 usually trivial, otherwise you have to do a three-way merge. The
86 merge must be committed and this creates a changeset which explains
87 to the world how you think the two heads should be combined:
88
89 /-> C2 --> C3 -\
90 C1 -< >-> M
91 \-> C2' --> C3' -/
92
93 Note that the merge changeset M has two parents.
94
95 If you do not merge C3 and C3' and try to push you get the 'new
96 remote head' message and push aborts. It aborts since it is a little
97 "impolite" to leave the job of merging to someone else -- he who
98 created the two heads by pulling in some code should also normally
99 do the merging.
100
101
102 In all this it helped my understanding a lot to think in terms of the changeset graph. Just remember
103 that:
104
105 * "hg commit" adds a new node. The parent changesets of the new node
106 is given by "hg parents"
107
108 * "hg push" and "hg pull" transfer nodes in the graph between two
109 repositories.
110
111 * "hg update" updates the working copy to reflect a given node in
112 the history graph. This also changes the parent changeset of the
113 next commit, see "hg parents".
114
115
116 A final note: If you want to quickly look things up, you can use one of the [Mercurial cheatsheets](http://www.selenic.com/mercurial/wiki/index.cgi/QuickReferenceCardsAndCheatSheets).
117
118 *compiled from a great Mail by Martin Geisler*