Mercurial > hg-website
comparison text/from-svn-to-hg.txt @ 121:6ec2428ec891
moved concepts of hg for svn users to from-svn-to-hg.
author | Arne Babenhauserheide <bab@draketo.de> |
---|---|
date | Tue, 28 Apr 2009 12:50:06 +0200 |
parents | a7b8b2a1e46f |
children |
comparison
equal
deleted
inserted
replaced
119:17a30a75abaf | 121:6ec2428ec891 |
---|---|
1 Notes: | 1 Notes: |
2 * svn info -> hg paths | 2 * svn info -> hg paths |
3 * pull and push | 3 * pull and push |
4 * svn up -r REV -> hg up REV | 4 * svn up -r REV -> hg up REV |
5 | |
6 = Basic concepts of Mercurial for Subversion users = | |
7 | |
8 //If you're interested in the concepts behind Mercurial and already know Subversion, please join us and listen to a great explanation from Martin Geisler: // | |
9 | |
10 Let me try to make some of the basic concepts clear: | |
11 | |
12 * Like in Subversion, history consists of a number of commits. They're | |
13 called changesets in Mercurial. | |
14 | |
15 * Subversion requires a strict linear ordering of the commits and | |
16 gives nice linear revision numbers to them. So revision N has only | |
17 one child revision, rN+1. | |
18 | |
19 This is simple, but it requires a central server to make sure that | |
20 everybody agrees on the revision numbers. | |
21 | |
22 * Mercurial generalizes this by letting each changeset have multiple | |
23 children. If I work alone and make commits I'll make | |
24 | |
25 C1 --> C2 --> C3 | |
26 | |
27 by making three commits. The commit C3 with no children is a "head". | |
28 It is also the newest changeset in the repository -- called "tip". | |
29 | |
30 If I shared C1 with you and you started your work from that, your | |
31 commits will build a repository like this: | |
32 | |
33 C1 --> C2' --> C3' | |
34 | |
35 Here C3' is a head in your repository and I don't know anything | |
36 about C2' and C3' yet. | |
37 | |
38 * If I pull from you, or you push to me, the two repositories are | |
39 compared. By default, all missing changesets are transferred. This | |
40 is all there is to push/pull: compare two graphs of changesets and | |
41 transfer the missing ones. | |
42 | |
43 After a pull from you my repository will look like this: | |
44 | |
45 /-> C2 --> C3 | |
46 C1 -< | |
47 \-> C2' --> C3' | |
48 | |
49 Here C1 has two child changesets, and the repository has two heads | |
50 since the development has diverged. | |
51 | |
52 The changeset C3' will be the new tip since it is the newest | |
53 changeset in the repository. Note that tip is always a head, but a | |
54 head need not be the tip. | |
55 | |
56 * Having two heads suggest that someone should merge them -- otherwise | |
57 the changes from one will never be combined with the changes made in | |
58 the other head. | |
59 | |
60 When merging with 'hg merge' the task is to figure out the canonical | |
61 way to combine the changesets. If the changes do not overlap this is | |
62 usually trivial, otherwise you have to do a three-way merge. The | |
63 merge must be committed and this creates a changeset which explains | |
64 to the world how you think the two heads should be combined: | |
65 | |
66 /-> C2 --> C3 -\ | |
67 C1 -< >-> M | |
68 \-> C2' --> C3' -/ | |
69 | |
70 Note that the merge changeset M has two parents. | |
71 | |
72 If you do not merge C3 and C3' and try to push you get the 'new | |
73 remote head' message and push aborts. It aborts since it is a little | |
74 "impolite" to leave the job of merging to someone else -- he who | |
75 created the two heads by pulling in some code should also normally | |
76 do the merging. | |
77 | |
78 | |
79 > Sometimes it's hard to keep the several DVCS workings in my mind | |
80 | |
81 It helped me a lot to think in terms of the changeset graph. Remember | |
82 that: | |
83 | |
84 * "hg commit" adds a new node. The parent changesets of the new node | |
85 is given by "hg parents" | |
86 | |
87 * "hg push" and "hg pull" transfer nodes in the graph between two | |
88 repositories. | |
89 | |
90 * "hg update" updates the working copy to reflect a given node in | |
91 the history graph. This also changes the parent changeset of the | |
92 next commit, see "hg parents". | |
93 | |
94 > Is there not a simple Mercurial cheat sheet somewhere? | |
95 | |
96 There are some here: | |
97 | |
98 http://www.selenic.com/mercurial/wiki/index.cgi/QuickReferenceCardsAndCheatSheets | |
99 | |
100 - Martin Geisler | |
101 | |
102 PS: These descriptions were written on the [Mercurial mailinglist](http://selenic.com/mailman/listinfo/mercurial). |