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