Mercurial > hg-website
annotate text/learning_mercurial_in_workflows.txt @ 141:cf102ae37ad9
Added a note about using shared servers instead of bitbucket.org
author | Arne Babenhauserheide <bab@draketo.de> |
---|---|
date | Mon, 11 May 2009 16:22:19 +0200 |
parents | 67b0602c837b |
children |
rev | line source |
---|---|
102
fa153f85e455
workflows: Changed the title to 'Learning Mercurial in Workflows'.
Arne Babenhauserheide <bab@draketo.de>
parents:
101
diff
changeset
|
1 = Learning Mercurial in Workflows = |
97 | 2 |
3 With Mercurial you can use a multitude of different workflows. This page shows some of them, including their use cases. | |
4 | |
125
ea1289ecb35e
learning in workflows: intro fixed.
Arne Babenhauserheide <bab@draketo.de>
parents:
124
diff
changeset
|
5 It is intended to make it easy for Beginners of Version tracking to get going instantly and learn completely incrementally. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
6 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
7 = Basic workflows = |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
8 |
128
98ba6ac8ac93
learning in workflows: renamed sysadmin workflow to 'log keeping'
Arne Babenhauserheide <bab@draketo.de>
parents:
126
diff
changeset
|
9 == Log keeping == |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
10 |
101
7bcdd8b947fe
workflows: small fixes.
Arne Babenhauserheide <bab@draketo.de>
parents:
100
diff
changeset
|
11 === Use Case === |
7bcdd8b947fe
workflows: small fixes.
Arne Babenhauserheide <bab@draketo.de>
parents:
100
diff
changeset
|
12 |
128
98ba6ac8ac93
learning in workflows: renamed sysadmin workflow to 'log keeping'
Arne Babenhauserheide <bab@draketo.de>
parents:
126
diff
changeset
|
13 The first workflow is also the easiest one: You want to use Mercurial to be able to look back when you did which changes. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
14 |
128
98ba6ac8ac93
learning in workflows: renamed sysadmin workflow to 'log keeping'
Arne Babenhauserheide <bab@draketo.de>
parents:
126
diff
changeset
|
15 This workflow only requires an installed Mercurial and write access to some file storage (you almost definitely have that :) ). It shows the basic techniques for more complex workflows. |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
16 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
17 === Workflow === |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
18 |
129
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
19 ==== Prepare Mercurial ==== |
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
20 |
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
21 As first step, you should teach Mercurial your name. For that you open the file ~/.hgrc with a text-editor and add the ui section (user interaction) with your username: |
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
22 |
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
23 <code>[ui] |
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
24 username = Mr. Johnson <johnson@smith.com></code> |
177b4120c26b
learning in workflows: Added info how to set the username.
Arne Babenhauserheide <bab@draketo.de>
parents:
128
diff
changeset
|
25 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
26 ==== Initialize the project ==== |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
27 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
28 <code>$ hg init project</code> |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
29 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
30 ==== Add files and track them ==== |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
31 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
32 <code>$ cd project |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
33 $ (add files) |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
34 $ hg add </code> |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
35 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
36 Note: You can also go into an existing directory with files and init the repository there. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
37 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
38 $ cd project |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
39 $ hg init |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
40 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
41 Alternatively you can add only specific files instead of all files in the directory. Mercurial will then track only these files and won't know about the others. The following tells mercurial to track all files beginning with "file0" as well as file10, file11 and file12. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
42 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
43 $ hg add file0* file10 file11 file12 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
44 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
45 ==== Save changes ==== |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
46 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
47 $ (do some changes) |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
48 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
49 see which files changed, which have been added or removed, and which aren't tracked yet. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
50 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
51 $ hg status |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
52 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
53 see the exact changes. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
54 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
55 $ hg diff |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
56 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
57 commit the changes. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
58 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
59 $ hg commit |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
60 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
61 now an editor pops up and asks you for a commit message. Upon saving and closing the editor, your changes have been stored by Mercurial. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
62 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
63 Note: You can also supply the commit message directly via "hg commit -m 'MESSAGE'" |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
64 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
65 ==== Check your history ==== |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
66 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
67 $ hg log |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
68 |
130
77b10482cc47
learning in workflows: How to see a specific patch.
Arne Babenhauserheide <bab@draketo.de>
parents:
129
diff
changeset
|
69 This prints a list of changesets along with their date, the user who committed them (you) and their commit message. |
77b10482cc47
learning in workflows: How to see a specific patch.
Arne Babenhauserheide <bab@draketo.de>
parents:
129
diff
changeset
|
70 |
77b10482cc47
learning in workflows: How to see a specific patch.
Arne Babenhauserheide <bab@draketo.de>
parents:
129
diff
changeset
|
71 To see a certain diff, you can use the "-p" switch (--patch) |
77b10482cc47
learning in workflows: How to see a specific patch.
Arne Babenhauserheide <bab@draketo.de>
parents:
129
diff
changeset
|
72 |
77b10482cc47
learning in workflows: How to see a specific patch.
Arne Babenhauserheide <bab@draketo.de>
parents:
129
diff
changeset
|
73 $ hg log -p -r 3 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
74 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
75 == Lone developer with linear history == |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
76 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
77 === Use case === |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
78 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
79 The second workflow is still very easy: You're a lone developer and you want to use Mercurial to keep track of your own changes. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
80 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
81 It works just like the sysadmin workflow, with the difference that you go back to earlied changes at times. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
82 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
83 To start a new project, you initialize a repository, add your files and commit whenever you finished a part of your work. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
84 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
85 Also you check your history from time to time, so see how you progressed. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
86 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
87 === Workflow === |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
88 |
137
defbaee4011c
learning in workflows: two minor fixes.
Arne Babenhauserheide <bab@draketo.de>
parents:
136
diff
changeset
|
89 ==== Basics from log keeping ==== |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
90 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
91 Init your project, add files, see changes and commit them. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
92 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
93 <code>$ hg init project |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
94 $ cd project |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
95 $ (add files) |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
96 $ hg add # tell Mercurial to track all files |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
97 $ (do some changes) |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
98 $ hg diff # see changes |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
99 $ hg commit # save changes |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
100 $ hg log # see history |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
101 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
102 ==== Seeing an earlier revision ==== |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
103 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
104 Different from the sysadmin workflow, you'll want to go back in history at times and undo some changes, for example because it introduced a bug. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
105 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
106 To look at a previous version of your code, you can use update. Let's assume that you want to see revision 3. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
107 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
108 $ hg update 3 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
109 |
136
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
110 Now your code is back at revision 3, the fourth commit (Mercurial starts counting at 0). |
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
111 To check if you're really at that revision, you can use "identify -n". |
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
112 |
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
113 $ hg identify -n |
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
114 |
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
115 Note: "identify" without options gives you the short form of a unique revision ID. That ID is what Mercurial uses internally. If you tell someone about the version you updated to, you should use that ID, since the numbers can be different for other people. If you want to know the reasons behind that, please read up Mercurials [basic concepts](). |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
116 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
117 To update to the most recent revision, you can use "tip" as revision name. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
118 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
119 $ hg update tip |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
120 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
121 Note: If at any place any command complains, your best bet is to read what it tells you and follow that advice. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
122 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
123 Note: Instead of "hg update" you can also use the shorthand "hg up". Similarly you can abbreviate "hg commit" to "hg ci". |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
124 |
136
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
125 Note: To get a revision devoid of files, just "update" to "null" via "hg update null". That's the revision before any files were added. |
0364cfc00295
learning in workflows: Added identify and update to 'null'
Arne Babenhauserheide <bab@draketo.de>
parents:
135
diff
changeset
|
126 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
127 ==== Fixing errors in earlier revisions ==== |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
128 |
137
defbaee4011c
learning in workflows: two minor fixes.
Arne Babenhauserheide <bab@draketo.de>
parents:
136
diff
changeset
|
129 When you find a bug in some earlier revision you have two options: either you can fix it in the current code, or you can go back in history and fix the code exactly where you did it, which creates a cleaner history. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
130 |
138
741911a6f770
learning in workflows: A bit of polishing.
Arne Babenhauserheide <bab@draketo.de>
parents:
137
diff
changeset
|
131 To do it the cleaner way, you first update to the old revision, fix the bug and commit it. Afterwards you merge this revision and commit the merge. Don't worry, though: Merging in mercurial is fast and painless, as you'll see in an instant. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
132 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
133 Let's assume the bug was introduced in revision 3. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
134 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
135 $ hg update 3 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
136 $ (fix the bug) |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
137 $ hg commit |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
138 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
139 Now the fix is already stored in history. We just need to merge it with the current version of your code. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
140 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
141 $ hg merge |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
142 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
143 If there are conflicts use "hg resolve" - that's also what merge tells you to do in case of conflicts. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
144 |
133
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
145 First list the files with conflicts: |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
146 |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
147 $ hg resolve --list |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
148 |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
149 Then resolve them one by one. "resolve" attempts the merge again: |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
150 |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
151 $ hg resolve conflicting_file |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
152 (fix it by hand, if necessary) |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
153 |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
154 Mark the fixed file as resolved: |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
155 |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
156 $ hg resolve --mark conflicting_file |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
157 |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
158 Commit the merge, as soon as you resolved all conflicts. This step is also necessary if there were no conflicts! |
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
159 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
160 $ hg commit |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
161 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
162 At this point, your fix is merged with all your other work, and you can just go on coding. Additionally the history shows clearly where you fixed the bug, so you'll always be able to check where the bug was. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
163 |
133
5e1cff189630
learning in workflows: Fix: Moved the resolve explanation to the first mention of resolve.
Arne Babenhauserheide <bab@draketo.de>
parents:
132
diff
changeset
|
164 Note: Most merges will just work. You only need "resolve", when "merge" complains. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
165 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
166 So now you can initialize repositories, save changes, update to previous changes and develop in a nonlinear history by committing in earlier changesets and merging the changes into the current code. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
167 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
168 == Seperate features == |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
169 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
170 === Use Case === |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
171 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
172 At times you'll be working on several features in parallel. If you want to avoid mixing incomplete code versions, you can create clones of your local repository and work on each feature in its own code directory. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
173 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
174 After finishing your feature you then "pull" it back into your main directory and "merge" the changes. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
175 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
176 === Workflow === |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
177 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
178 First create the feature clone and do some changes |
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
179 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
180 $ hg clone project feature1 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
181 $ cd feature1 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
182 $ (do some changes and commits) |
131
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
183 |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
184 $ Now check what will come in when you pull from feature1, just like you can use "diff" before committing |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
185 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
186 $ cd ../project |
131
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
187 $ hg incoming ../feature1 |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
188 |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
189 Note: If you want to see the diffs, you can use "hg incoming --patch" just as you can do with "hg log --patch" for the changes in the repository. |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
190 |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
191 If you like the changes, you pull them into the project |
59b5985db58a
learning in workflows: added 'incoming'
Arne Babenhauserheide <bab@draketo.de>
parents:
130
diff
changeset
|
192 |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
193 $ hg pull ../feature1 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
194 |
134
4fc2fc6ddbed
learning in workflows: Added a note that we need a link for information about .hg
Arne Babenhauserheide <bab@draketo.de>
parents:
133
diff
changeset
|
195 Now you have the history of feature1 inside your project, but the changes aren't yet visible. Instead they are only stored inside a .hg directory of the project ([more information on the store]()). |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
196 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
197 Note: From now on we'll use the name "repository" for a directory which has a .hg directory with Mercurial history. |
101
7bcdd8b947fe
workflows: small fixes.
Arne Babenhauserheide <bab@draketo.de>
parents:
100
diff
changeset
|
198 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
199 If you didn't do any changes in the project, while you were working on feature1, you can just update to tip ("hg update tip"), but it is more likely that you'll have done some other changes in between changes. In that case, it's time for merging. |
99
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
200 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
201 Merge feature1 into the project code: |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
202 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
203 $ hg merge |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
204 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
205 If there are conflicts use "hg resolve" - that's also what merge tells you to do in case of conflicts. |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
206 |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
207 $ hg commit -m "merged feature1" |
71ff3b94b20d
Added workflows sysadmin, lone developer and seperate features.
Arne Babenhauserheide <bab@draketo.de>
parents:
97
diff
changeset
|
208 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
209 You can create an arbitrary number of clones and also carry them around on USB sticks. Also you can use them to synchronize your files at home and at work, or between your desktop and your laptop. |
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
210 |
104
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
211 == Sharing changes == |
100
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
212 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
213 === Use Case === |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
214 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
215 Now we go one step further: You are no longer alone, and you want to share your changes with others and include their changes. |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
216 |
104
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
217 The basic requirement for that is that you have to be able to see the changes of others. |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
218 |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
219 Mercurial allows you to do that very easily by including a simple webserver from which you can pull changes just as you can pull changes from local clones. |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
220 |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
221 There are a few other ways to share changes, though. Instead of using the builtin webserver, you can also send the changes by email or setup a shared repository, to where you "push" changes instead of pulling them. |
100
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
222 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
223 === Workflow === |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
224 |
104
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
225 ==== Using the builtin webserver ==== |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
226 |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
227 This is the easiest way to quickly share changes. |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
228 |
100
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
229 First the one who wants to share his changes creates the webserver |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
230 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
231 $ hg serve |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
232 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
233 Now all others can point their browsers to his IP address (for example 192.168.178.100) at port 8000. They will then see all his history there and can sdecide if they want to pull his changes. |
100
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
234 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
235 $ firefox http://192.168.178.100:8000 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
236 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
237 If they decide to include the changes, they just pull from the same URL |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
238 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
239 $ hg pull http://192.168.178.100:8000 |
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
240 |
106
cdcc94ca41e7
workflows: just polishing.
Arne Babenhauserheide <bab@draketo.de>
parents:
104
diff
changeset
|
241 At this point you all can work as if you had pulled from a local repository. All the data is now in your individual repositories and you can merge the changes and work with them without needing any connection to the served repository. |
100
6e29cdea7b3a
Workflows: Added basic sharing of changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
99
diff
changeset
|
242 |
104
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
243 ==== Sending changes by email ==== |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
244 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
245 Often you won't have direct access to the repository of someone else, be it because he's behind a restrictive firewall, or because you live in different timezones. You might also want to keep your changes confidential and prefer internal email (if you want additional protection, you can also encrypt the mails, for example with [GnuPG](http://gnupg.org)). |
108
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
246 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
247 In that case, you can easily export your changes as patches and send them by email. |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
248 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
249 Another reason to send them by email can be that your policy requires manual review of the changes when the other developers are used to reading diffs in emails. I'm sure you can think of more reasons. |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
250 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
251 Sending the changes via email is pretty straightforward with Mercurial. You just "export" your changes and attach (or copy paste) it in your email. Your collegues can then just "import" them. |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
252 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
253 First check which changes you want to export |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
254 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
255 $ cd project |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
256 $ hg log |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
257 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
258 We assume that you want to export changeset 3 and 4: |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
259 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
260 $ hg export 3 > change3.diff |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
261 $ hg export 4 > change4.diff |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
262 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
263 Now attach them to an email and your collegues can just run "import" on both diffs to get your full changes, including your user information. |
108
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
264 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
265 To be careful, they first clone their repository to have an integration directory: |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
266 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
267 $ hg clone project integration |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
268 $ cd integration |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
269 $ hg import change3.diff |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
270 $ hg import change4.diff |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
271 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
272 That's it. They can now test your changes in feature clones. If they accept them, they pull the changes into the main repository. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
273 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
274 $ cd ../project |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
275 $ hg pull ../integration |
108
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
276 |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
277 Note: The patchbomb extension automates the email-sending, but you don't need it for this workflow. |
ed683ad3947f
learning in workflows: Send changes by email.
Arne Babenhauserheide <bab@draketo.de>
parents:
107
diff
changeset
|
278 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
279 Note 2: You can also send around bundles, which are snippets of your actual history. Just create them via |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
280 $ hg bundle --base FIRST_REVISION_TO_BUNDLE changes.bundle |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
281 Others can then get your changes by simply pulling them, as if your bundle were an actual repository |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
282 $ hg pull path/to/changes.bundle |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
283 |
104
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
284 ==== Using a shared repository ==== |
03591004ed44
workflows: Added plan for sharing via email and via shared repo (bitbucket).
Arne Babenhauserheide <bab@draketo.de>
parents:
103
diff
changeset
|
285 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
286 Sending changes by mail might be the easiest way to reach people when you aren't yet part of the regular development team, but it creates additional workload: You have to send mails and then import the changes manually. Luckily there's an easier way which works quite well: The shared push repository. |
110
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
287 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
288 Till now we transferred all changes either via email or via pull, but there's yet another way: pushing. As the name suggests it's just the opposite of pulling: You push your changes into another repository. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
289 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
290 But to make use of it, we first need something we can push to. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
291 |
135
8d069bba8cce
learning in workflows: shared server now contains a bit more information for people with existing servers.
Arne Babenhauserheide <bab@draketo.de>
parents:
134
diff
changeset
|
292 By default "hg serve" doesn't allow pushing, since that would be a major security hole. You can allow pushing in the server, but that's no solution when you live in different timezones, so we'll go with another approach here: Using a shared repository, either on an existing shared server or on a service like [BitBucket](http://bitbucket.org). Doing so has a bit higher starting cost and takes a bit longer to explain, but it's well worth the effort spent. |
110
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
293 |
135
8d069bba8cce
learning in workflows: shared server now contains a bit more information for people with existing servers.
Arne Babenhauserheide <bab@draketo.de>
parents:
134
diff
changeset
|
294 If you want to use an existing shared server, you can use "serve" there and [allow pushing](). Also there are some other nice ways to allow [pushing to a Mercurial repository](), including simply [pushing via SSH](). |
8d069bba8cce
learning in workflows: shared server now contains a bit more information for people with existing servers.
Arne Babenhauserheide <bab@draketo.de>
parents:
134
diff
changeset
|
295 |
8d069bba8cce
learning in workflows: shared server now contains a bit more information for people with existing servers.
Arne Babenhauserheide <bab@draketo.de>
parents:
134
diff
changeset
|
296 Otherwise you first need to setup a BitBucket Account. Just signup at [BitBucket](http://bitbucket.org) and then hover your mouse over "Repositories". There click the item at the bottom of the opening dialog which say "Create new". |
110
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
297 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
298 Give it a name and a description, and if you want to keep it hidden from the public, select "private". |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
299 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
300 $ firefox http://bitbucket.org |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
301 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
302 Now your repository is created and you see instructions to "push" code to it. for that you'll use a command similar to the following (just with a different URL): |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
303 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
304 $ hg push https://bitbucket.org/ArneBab/1w6/ |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
305 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
306 (Replace the URL with the URL of your created repository. If your username is "Foo" and your repository is named "bar", the URL will be https://bitbucket.org/Foo/bar/) |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
307 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
308 Mercurial will ask for your BitBucket password, then push your code. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
309 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
310 Voilà , your code is online. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
311 |
135
8d069bba8cce
learning in workflows: shared server now contains a bit more information for people with existing servers.
Arne Babenhauserheide <bab@draketo.de>
parents:
134
diff
changeset
|
312 Note: You can also [use SSH for pushing to BitBucket](http://bitbucket.org/help/UsingSSH). |
8d069bba8cce
learning in workflows: shared server now contains a bit more information for people with existing servers.
Arne Babenhauserheide <bab@draketo.de>
parents:
134
diff
changeset
|
313 |
110
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
314 Now it's time to tell all your collegues to sign up at BitBucket, too. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
315 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
316 After that you can click the "Admin" tab of your created repository and add the names of your collegues on the right side under "Permission: Writers". Now they are allowed to push code to the repository. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
317 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
318 (If you chose to make the repository private, you'll need to add them to "Permission: Readers", too) |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
319 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
320 If one of you now wants to publish changes, he'll simply push them to the repository, and all others get them by pulling. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
321 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
322 Publish your changes: |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
323 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
324 $ hg push https://bitbucket.org/ArneBab/1w6/ |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
325 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
326 Pull others changes into your local repository: |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
327 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
328 $ hg pull https://bitbucket.org/ArneBab/1w6/ |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
329 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
330 People who join you in development can also just clone this repository, as if one of you were using "hg serve": |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
331 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
332 $ hg clone https://bitbucket.org/ArneBab/1w6/ 1w6 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
333 |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
334 That local repository will automatically be configured to pull/push from/to the online repository, so new contributors can just use "hg push" and "hg pull" without an URL. |
8c8c8aaaaad7
learning in workflows: added sharing changes.
Arne Babenhauserheide <bab@draketo.de>
parents:
108
diff
changeset
|
335 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
336 Note: To make this workflow more scaleable, each one of you can have his own BitBucket repository and you can simply pull from the others repositories. That way you can easily establish workflows in which certain people act as integrators and finally push checked code to a shared pull repository from which all others pull. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
337 |
141
cf102ae37ad9
Added a note about using shared servers instead of bitbucket.org
Arne Babenhauserheide <bab@draketo.de>
parents:
140
diff
changeset
|
338 Note: You can also use this workflow with a shared server instead of BitBucket, either via SSH or via a shared directory. An example for an SSH URL with Mercurial is be ssh://hg@bitbucket.org/ArneBab/1w6 (for a shared server you'd replace the "hg" in the given URL with your username). For a shared directory you just push as if the repository in the shared directory were on your local drive. |
cf102ae37ad9
Added a note about using shared servers instead of bitbucket.org
Arne Babenhauserheide <bab@draketo.de>
parents:
140
diff
changeset
|
339 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
340 == Summary == |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
341 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
342 Now let's take a step back and look where we are. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
343 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
344 With the commands you already know, a bit reading of "hg help <command>" and some evil script-fu you can already do almost everything you'll ever need to do when working with source code history. So from now on almost everything is convenience, and that's a good thing. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
345 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
346 First this is good, because it means, that you can now use most of the concepts which are used in more complex workflows. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
347 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
348 Second it aids you, because convenience lets you focus on your task instead of focussing on your tool. It helps you concentrate on the coding itself. Still you can always go back to the basics, if you want to. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
349 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
350 A short summary of what you can do which can also act as a short check, if you still remember the meaning of the commands: |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
351 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
352 create a project |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
353 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
354 $ hg init project |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
355 $ cd project |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
356 $ (add some files) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
357 $ hg add |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
358 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
359 (enter the commit message) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
360 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
361 do nonlinear development |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
362 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
363 $ (do some changes) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
364 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
365 (enter the commit message) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
366 $ hg update 0 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
367 $ (do some changes) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
368 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
369 (enter the commit message) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
370 $ hg merge |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
371 $ (optionally hg resolve) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
372 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
373 (enter the commit message) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
374 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
375 use feature clones |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
376 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
377 $ cd .. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
378 $ hg clone project feature1 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
379 $ cd feature1 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
380 $ (do some changes) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
381 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
382 (enter the commit message) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
383 $ cd ../project |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
384 $ hg pull ../feature1 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
385 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
386 share your repository via the integrated webserver |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
387 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
388 $ hg serve & |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
389 $ cd .. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
390 $ hg clone http://127.0.0.1:8000 project-clone |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
391 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
392 export changes to files |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
393 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
394 $ cd project-clone |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
395 $ (do some changes) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
396 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
397 (enter the commit message) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
398 $ hg export tip > ../changes.diff |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
399 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
400 import changes from files |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
401 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
402 $ cd ../project |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
403 $ hg import ../changes.diff |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
404 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
405 pull changes from a served repository (hg serve still runs on project) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
406 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
407 $ cd ../feature1 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
408 $ hg pull http://127.0.0.1:8000 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
409 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
410 Use shared repositories on BitBucket |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
411 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
412 $ (setup bitbucket repo) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
413 $ hg push https://bitbucket.org/USER/REPO |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
414 (enter name and password in the prompt) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
415 $ hg pull https://bitbucket.org/USER/REPO |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
416 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
417 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
418 Let's move on towards useful features and a bit more advanced workflows. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
419 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
420 == Backing out bad revisions == |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
421 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
422 === Use Case === |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
423 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
424 When you routinely pull code from others, it can happen that you overlook some bad change. As soon as others pull that change from you, you have little chance to get completely rid of it. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
425 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
426 To resolve that problem, Mercurial offers you the backout command. Backing out a change means, that you tell Mercurial to create a commit which reverses the bad change. That way you don't get rid of the bad code in history, but you can remove it from new revisions. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
427 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
428 Note: The basic commands don't directly rewrite history - if you want to do that, you need to activate some of the extensions which are shipped with mercurial. We'll come to that later on. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
429 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
430 === Workflow === |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
431 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
432 Let's assume the bad change was revision 3, and we already have one more revision in our repository. To remove the bad code, we just backout of it. This creates a new change which reverses the bad change. After backing out, we merge that new change into the current code. |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
433 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
434 $ hg backout 3 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
435 $ hg merge |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
436 (potentially resolve conflicts) |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
437 $ hg commit |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
438 (enter commit message. For example: "merged backout") |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
439 |
115
8a603a9cbc04
learning in workflows: Minor addition to backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
111
diff
changeset
|
440 That's it. You reversed the bad change. It's still recorded that it was once there (don't rewrite history, if it's not really necessary), but it doesn't affect future code anymore. |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
441 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
442 == Collaborative feature development == |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
443 |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
444 Now that we can share changes and reverse them if necessary, we go one step further: Using Mercurial to help in coordinating the coding. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
445 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
446 The first part is an easy way to develop features together, without requiring every developer to keep track of several feature clones. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
447 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
448 === Use Case === |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
449 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
450 When you want to split your development into several features, you need to keep track of who works on which feature and where to get which changes. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
451 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
452 Mercurial makes this easy for you by providing names branches. They are a part of the main repository, so they are available to everyone involved. At the same time, changes committed on a certain branch don't get mixed into the changes in the default branch, so features are kept separate, until they get merged into the default branch. |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
453 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
454 === Workflow === |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
455 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
456 When someone in your group wants to start coding on a feature without disturbing the others, he can create a named branch and commit there. When someone else wants to join in, he just updates to the branch and commits away. As soon as the feature is finished, someone merges the named branch into the default branch. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
457 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
458 Create a named branch (name: feature1) and work on it: |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
459 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
460 $ hg branch feature1 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
461 (do some changes) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
462 $ hg commit |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
463 (write commit message) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
464 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
465 Update into the branch and work in it: |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
466 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
467 $ hg update feature1 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
468 (do some changes) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
469 $ hg commit |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
470 (write commit message) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
471 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
472 Now you can commit, pull, push and merge as if they were working in a separate repository. If the history of the named branch is linear and you call "hg merge", Mercurial asks you to specify an explicit revision, since the branch in which you work doesn't have anything to merge. |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
473 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
474 When you finished the feature, you merge it back into the default branch. |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
475 |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
476 $ hg update default |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
477 $ hg merge feature1 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
478 $ hg commit |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
479 (write commit message) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
480 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
481 And that's it. Now you can easily keep features separate without unnecessary bookkeeping. |
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
482 |
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
483 Note: Named branches stay in history as permanent record after you finished your work. If you don't like having that record in your history, please have a look at some of the [advanced workflows](workflows#advanced) |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
484 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
485 == Marking revisions: tag and sign == |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
486 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
487 === Use Case === |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
488 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
489 Since you can now code separate features more easily, you might want to mark certain revisions as fit for consumption (or similar). For example you might want to mark releases, or just mark off revisions as reviewed. |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
490 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
491 For this Mercurial offers tags. Tags add a name to a revision and are part of the history. You can tag a change years after it was committed. The tag includes the information when it was added, and tags can be pulled, pushed and merged just like any other committed change. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
492 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
493 Note: A tag must not contain the char ":", since that char is used for specifying multiple reivions - see "hg help revisions". |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
494 |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
495 === Workflow === |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
496 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
497 Let's assume you want to give revision 3 the name "v0.1". |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
498 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
499 Add the tag: |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
500 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
501 $ hg tag -r 3 v0.1 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
502 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
503 See all tags: |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
504 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
505 $ hg tags |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
506 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
507 When you look at the log you'll now see a line in changeset 3 which marks the Tag. If someone wants to update to the tagged revision, he can just use the name of your tag: |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
508 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
509 $ hg update v0.1 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
510 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
511 Now he'll be at the tagged revision and can work from there. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
512 |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
513 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
514 == Removing history == |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
515 |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
516 === Use Case === |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
517 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
518 At times you will have changes in your repository, which you really don't want in it. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
519 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
520 There are many advanced options for removing these, and of them most use great extensions (Mercurial Queues is the most often used one), but in this basic guide, we'll solve the problem with just the commands we already learned. But we'll use an option to clone which we didn't yet use. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
521 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
522 This workflow becomes inconvenient when you need to changes, which are buried below many new changes. If you spot it early enough, you can get rid of them without too much effort, though. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
523 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
524 === Workflow === |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
525 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
526 Let's assume you want to get rid of revision 2 and we have 3 revisions in total. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
527 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
528 The first step is to use the "--rev" option to clone: Create a clone which only contains the changes up to the specified revision. This means that you want to keep revision 1, so we only clone up to that. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
529 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
530 $ hg clone -r 1 project stripped |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
531 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
532 Now you can export the change 3 from the original repository (project) and import it into the stripped one. |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
533 |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
534 $ cd project |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
535 $ hg export 3 > ../changes.diff |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
536 $ cd ../stripped |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
537 $ hg import ../changes.diff |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
538 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
539 If a part of the changes couldn't be applied, you'll see that part in *.rej files. If you have *.rej files, you'll have to include or discard changes by hand. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
540 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
541 $ cat *.rej |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
542 (apply changes by hand) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
543 $ hg commit |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
544 (write commit message) |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
545 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
546 That's it. "hg export" also includes the commit message, date, committer and similar metadata, so you are already done. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
547 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
548 Note: removing history will change the revision IDs of revisions after the removed one, and if you pull from someone else who still has the revision you removed, you will pull the removed parts again. That's why rewriting history should most times only be done for changes which you didn't yet publicise. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
549 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
550 == Summary == |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
551 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
552 So now you can work with Mercurial in private, and also share your changes in a multitude of ways. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
553 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
554 Additionally to that you can also remove bad changes, either by creating a change in the repository which reverses the original change, or by really rewriting history, so it looks like the change never occured. |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
555 |
132
a7fb926c69f6
learning in workflows: fixed soem typos and did some clarifications.
Arne Babenhauserheide <bab@draketo.de>
parents:
131
diff
changeset
|
556 And you can separate the work on features in a single repository by using named branches and add tags to revisions which are visible markers for others and can be used to update to the tagged revisions. |
124
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
557 |
0bee8982f334
learning in workflows mostly finished - I hope :) .
Arne Babenhauserheide <bab@draketo.de>
parents:
115
diff
changeset
|
558 With this we can conclude our practical guide. |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
559 |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
560 = More Complex Workflows = |
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
561 |
140
67b0602c837b
Added correct URL to the general workflows wikipage.
Arne Babenhauserheide <bab@draketo.de>
parents:
139
diff
changeset
|
562 If you now want to check some more complex workflows, please have a look at the general [workflows](http://selenic.com/mercurial/wiki/Workflows) wikipage. |
139
2fcd14a3b9f9
learning in workflows: Added a link to the (not yet written) basic concept overview for understanding.
Arne Babenhauserheide <bab@draketo.de>
parents:
138
diff
changeset
|
563 |
2fcd14a3b9f9
learning in workflows: Added a link to the (not yet written) basic concept overview for understanding.
Arne Babenhauserheide <bab@draketo.de>
parents:
138
diff
changeset
|
564 To deepen your understanding, you should also check the [basic concept overview](quick_start_concepts). |
111
8b51ceb2d36b
learning in workflows: Added backout.
Arne Babenhauserheide <bab@draketo.de>
parents:
110
diff
changeset
|
565 |
140
67b0602c837b
Added correct URL to the general workflows wikipage.
Arne Babenhauserheide <bab@draketo.de>
parents:
139
diff
changeset
|
566 Have fun with Mercurial! |