comparison hgscm/templates/workflow_guide.html @ 160:bb60a4d6a1e3

learning in workflows: Added rollback to the feature clone workflow.
author Arne Babenhauserheide <bab@draketo.de>
date Tue, 12 May 2009 14:39:10 +0200
parents 83970c19b495
children 9d7df1cd39d3
comparison
equal deleted inserted replaced
159:83970c19b495 160:bb60a4d6a1e3
98 98
99 To see a certain revision, you can use the <hg>-r</hg> switch (--revision). To also see the diff of the displayed revisions, there's the <hg>-p</hg> switch (--patch) 99 To see a certain revision, you can use the <hg>-r</hg> switch (--revision). To also see the diff of the displayed revisions, there's the <hg>-p</hg> switch (--patch)
100 100
101 <pre>$ hg log -p -r 3</pre> 101 <pre>$ hg log -p -r 3</pre>
102 102
103 <h3>Lone developer with linear history</h3> 103 <h3>Lone developer with nonlinear history</h3>
104 104
105 <h4>Use case</h4> 105 <h4>Use case</h4>
106 106
107 <p>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.</p> 107 <p>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.</p>
108 108
205 205
206 <p>After finishing your feature you then <hg>pull</hg> it back into your main directory and <hg>merge</hg> the changes.</p> 206 <p>After finishing your feature you then <hg>pull</hg> it back into your main directory and <hg>merge</hg> the changes.</p>
207 207
208 <h4>Workflow</h4> 208 <h4>Workflow</h4>
209 209
210 <h5>Work in different clones</h5>
211
210 <p>First create the feature clone and do some changes</p> 212 <p>First create the feature clone and do some changes</p>
211 213
212 <pre>$ hg clone project feature1 214 <pre>$ hg clone project feature1
213 $ cd feature1 215 $ cd feature1
214 $ (do some changes and commits)</pre> 216 $ (do some changes and commits)</pre>
240 (enter commit message, for example "merged feature1")</pre> 242 (enter commit message, for example "merged feature1")</pre>
241 243
242 <p>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.</p> 244 <p>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.</p>
243 245
244 <p>Note: You also have to commit after a merge when there are no conflicts, because merging creates new history and you might want to attach a specific message to the merge (like "merge feature1").</p> 246 <p>Note: You also have to commit after a merge when there are no conflicts, because merging creates new history and you might want to attach a specific message to the merge (like "merge feature1").</p>
247
248 <h5>Rollback mistakes</h5>
249
250 Now you can work on different features in parallel, but from time to time a bad commit might sneak in. Naturally you could then just go back one revision and merge the stray error, keeping all mistakes out of the merged revision. However, there's an easier way, if you realize your error before you do another <hg>commit</hg> or <hg>pull</hg>: <hg>rollback</hg>.
251
252 Rolling back means undoing the last operation which added something to your history.
253
254 Imagine you just realized that you did a bad commit - for example you didn't see a spelling error in a label. To fix it you would use
255
256 <pre>hg rollback</pre>
257
258 And then redo the commit
259
260 <pre>hg commit -m "message"</pre>
261
262 If you can use the command history of your shell and you added the previous message via <hg>commit -m "message"</hg>, that following commit just means two clicks on the arrow-key "up" and one click on "enter".
263
264 Though it changes your history, rolling back doesn't change your files. It only undoes the last addition to your history.
265
266 But beware, that a rollback itself can't be undone. If you <hg>rollback</hg> and then forget to commit, you can't just say "give me my old commit back". You have to create a new commit.
267
268 Note: Rollback is possible, because Mercurial uses transactions when recording changes, and you can use the transaction record to undo the last transaction. This means that you can also use <hg>rollback</hg> to undo your last <hg>pull</hg>, if you didn't yet commit aything new.
245 269
246 <h3>Sharing changes</h3> 270 <h3>Sharing changes</h3>
247 271
248 <h4>Use Case</h4> 272 <h4>Use Case</h4>
249 273