Mercurial > evolve
comparison docs/sharing.rst @ 1259:0daf56a2032d stable
docs: update sharing guide based (mostly) on marmoute's review
- don't claim certain scenarios are more/less common, just
simple/advanced
- mention code review as a multiple-developer scenario (not described
in detail yet!)
- suggest "hg config --edit --local" instead of "cat >> .hg/hgrc"
- use -q less often (and show resulting output)
- edit some section headers to be consistent with user guide
(example numbers; "amend" instead of "amending")
(These are just the small changes; big changes are yet to come.)
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Tue, 14 Apr 2015 12:43:37 -0400 |
parents | 0b66826f081c |
children | e8016d1011b5 |
comparison
equal
deleted
inserted
replaced
1258:8873aedbd83d | 1259:0daf56a2032d |
---|---|
3 ------------------------------ | 3 ------------------------------ |
4 Evolve: Shared Mutable History | 4 Evolve: Shared Mutable History |
5 ------------------------------ | 5 ------------------------------ |
6 | 6 |
7 Once you have mastered the art of mutable history in a single | 7 Once you have mastered the art of mutable history in a single |
8 repository, you might want to move up to the next level: *shared* | 8 repository (see the `user guide`_), you might want to move up to the |
9 mutable history. ``evolve`` lets you push and pull draft changesets | 9 next level: *shared* mutable history. ``evolve`` lets you push and |
10 between repositories along with their obsolescence markers. This opens | 10 pull draft changesets between repositories along with their |
11 up a number of interesting possibilities. | 11 obsolescence markers. This opens up a number of interesting |
12 | 12 possibilities. |
13 The most common scenario is a single developer working across two | 13 |
14 .. _`user guide`: user-guide.html | |
15 | |
16 The simplest scenario is a single developer working across two | |
14 computers. Say you're working on code that must be tested on a remote | 17 computers. Say you're working on code that must be tested on a remote |
15 test server, probably in a rack somewhere, only accessible by SSH, and | 18 test server, probably in a rack somewhere, only accessible by SSH, and |
16 running an “enterprise-grade” (out-of-date) OS. But you probably | 19 running an “enterprise-grade” (out-of-date) OS. But you probably |
17 prefer to write code locally: everything is setup the way you like it, | 20 prefer to write code locally: everything is setup the way you like it, |
18 and you can use your preferred editor, IDE, merge/diff tools, etc. | 21 and you can use your preferred editor, IDE, merge/diff tools, etc. |
38 whenever the code is demonstrably better, even if all the tests aren't | 41 whenever the code is demonstrably better, even if all the tests aren't |
39 passing yet—just ``hg amend`` when they are. And you can transfer | 42 passing yet—just ``hg amend`` when they are. And you can transfer |
40 those half-baked changesets between repositories to try things out on | 43 those half-baked changesets between repositories to try things out on |
41 your test server before anything is carved in stone. | 44 your test server before anything is carved in stone. |
42 | 45 |
43 A less common scenario is multiple developers sharing mutable history. | 46 A less common scenario is multiple developers sharing mutable history, |
44 (This is in fact how Mercurial itself is developed.) We'll cover this | 47 typically for code review. We'll cover this scenario later. But first, |
45 scenario later. But first, single-user sharing. | 48 single-user sharing. |
46 | 49 |
47 Publishing and non-publishing repositories | 50 Publishing and non-publishing repositories |
48 ------------------------------------------ | 51 ------------------------------------------ |
49 | 52 |
50 The key to shared mutable history is to keep your changesets in | 53 The key to shared mutable history is to keep your changesets in |
58 Setting things up | 61 Setting things up |
59 ----------------- | 62 ----------------- |
60 | 63 |
61 We'll work an example with three local repositories, although in the | 64 We'll work an example with three local repositories, although in the |
62 real world they'd most likely be on three different computers. First, | 65 real world they'd most likely be on three different computers. First, |
63 the public repository is where tested, polished changesets live, and | 66 the ``public`` repository is where tested, polished changesets live, |
64 it is where you push/pull changesets to/from the rest of your team. :: | 67 and it is where you synchronize changesets with the rest of your team. |
68 :: | |
65 | 69 |
66 $ hg init public | 70 $ hg init public |
67 | 71 |
68 We'll need two clones where work gets done:: | 72 We'll need two clones where work gets done:: |
69 | 73 |
70 $ hg clone -q public test-repo | 74 $ hg clone public test-repo |
71 $ hg clone -q test-repo dev-repo | 75 updating to branch default |
76 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
77 $ hg clone test-repo dev-repo | |
78 updating to branch default | |
79 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
72 | 80 |
73 ``dev-repo`` is your local machine, with GUI merge tools and IDEs and | 81 ``dev-repo`` is your local machine, with GUI merge tools and IDEs and |
74 everything configured just the way you like it. ``test-repo`` is the | 82 everything configured just the way you like it. ``test-repo`` is the |
75 test server in a rack somewhere behind SSH. So for the most part, | 83 test server in a rack somewhere behind SSH. So for the most part, |
76 we'll develop in ``dev-repo``, push to ``test-repo``, test and polish | 84 we'll develop in ``dev-repo``, push to ``test-repo``, test and polish |
77 there, and push to ``public``. | 85 there, and push to ``public``. |
78 | 86 |
79 The key to making this whole thing work is to make ``test-repo`` | 87 The key to shared mutable history is to make the target repository, |
80 non-publishing:: | 88 ``test-repo`` in this case, non-publishing. And, of course, we have to enable ``evolve`` in both ``test-repo`` and ``dev-repo``. |
81 | 89 |
82 $ cat >> test-repo/.hg/hgrc <<EOF | 90 First, edit the configuration for ``test-repo``:: |
91 | |
92 $ hg -R test-repo config --edit --local | |
93 | |
94 and add :: | |
95 | |
83 [phases] | 96 [phases] |
84 publish = false | 97 publish = false |
85 EOF | 98 |
86 | |
87 We also have to configure ``evolve`` in both ``test-repo`` and | |
88 ``dev-repo``, so that we can amend and evolve in both of them. :: | |
89 | |
90 $ cat >> test-repo/.hg/hgrc <<EOF | |
91 [extensions] | 99 [extensions] |
92 evolve = /path/to/mutable-history/hgext/evolve.py | 100 evolve = /path/to/mutable-history/hgext/evolve.py |
93 EOF | 101 |
94 $ cat >> dev-repo/.hg/hgrc <<EOF | 102 Then edit the configuration for ``dev-repo``:: |
103 | |
104 $ hg -R dev-repo config --edit --local | |
105 | |
106 and add :: | |
107 | |
95 [extensions] | 108 [extensions] |
96 evolve = /path/to/mutable-history/hgext/evolve.py | 109 evolve = /path/to/mutable-history/hgext/evolve.py |
97 EOF | |
98 | 110 |
99 Keep in mind that in real life, these repositories would probably be | 111 Keep in mind that in real life, these repositories would probably be |
100 on separate computers, so you'd have to login to each one to configure | 112 on separate computers, so you'd have to login to each one to configure |
101 each repository. | 113 each repository. |
102 | 114 |
104 | 116 |
105 $ cd test-repo | 117 $ cd test-repo |
106 $ echo 'my new project' > file1 | 118 $ echo 'my new project' > file1 |
107 $ hg add file1 | 119 $ hg add file1 |
108 $ hg commit -m 'create new project' | 120 $ hg commit -m 'create new project' |
109 $ hg push -q | 121 $ hg push |
122 [...] | |
123 added 1 changesets with 1 changes to 1 files | |
110 | 124 |
111 and pull that into the development repository:: | 125 and pull that into the development repository:: |
112 | 126 |
113 $ cd ../dev-repo | 127 $ cd ../dev-repo |
114 $ hg pull -u | 128 $ hg pull -u |
115 | 129 [...] |
116 Amending a shared changeset | 130 added 1 changesets with 1 changes to 1 files |
117 --------------------------- | 131 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
132 | |
133 Example 1: Amend a shared changeset | |
134 ----------------------------------- | |
118 | 135 |
119 Everything you learned in the `user guide`_ applies to work done in | 136 Everything you learned in the `user guide`_ applies to work done in |
120 ``dev-repo``. You can commit, amend, uncommit, evolve, and so forth | 137 ``dev-repo``. You can commit, amend, uncommit, evolve, and so forth |
121 just as before. | 138 just as before. |
122 | 139 |
185 | 202 |
186 Because of this deliberately incomplete synchronization, revision | 203 Because of this deliberately incomplete synchronization, revision |
187 numbers in ``test-repo`` and ``dev-repo`` are no longer consistent. We | 204 numbers in ``test-repo`` and ``dev-repo`` are no longer consistent. We |
188 *must* use changeset IDs. | 205 *must* use changeset IDs. |
189 | 206 |
190 Amend again, locally | 207 Example 2: Amend again, locally |
191 -------------------- | 208 ------------------------------- |
192 | 209 |
193 This process can repeat. Perhaps you figure out a more elegant fix to | 210 This process can repeat. Perhaps you figure out a more elegant fix to |
194 the bug, and want to mutate history so nobody ever knows you had a | 211 the bug, and want to mutate history so nobody ever knows you had a |
195 less-than-perfect idea. We'll implement it locally in ``dev-repo`` and | 212 less-than-perfect idea. We'll implement it locally in ``dev-repo`` and |
196 push to ``test-repo``:: | 213 push to ``test-repo``:: |
207 [figure SG04: each repo has one temporary amend commit, but they're different in each one] | 224 [figure SG04: each repo has one temporary amend commit, but they're different in each one] |
208 | 225 |
209 Let's hop over to ``test-repo`` to test the more elegant fix:: | 226 Let's hop over to ``test-repo`` to test the more elegant fix:: |
210 | 227 |
211 $ cd ../test-repo | 228 $ cd ../test-repo |
212 $ hg update -q | 229 $ hg update |
230 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
213 | 231 |
214 This time, all the tests pass, so no further amendment is required. | 232 This time, all the tests pass, so no further amendment is required. |
215 This bug fix is finished, so we push it to the public repository:: | 233 This bug fix is finished, so we push it to the public repository:: |
216 | 234 |
217 $ hg push | 235 $ hg push |
262 | 280 |
263 To demonstrate, let's start with the ``public`` repository as we left | 281 To demonstrate, let's start with the ``public`` repository as we left |
264 it in the last example, with two immutable changesets (figure 5 | 282 it in the last example, with two immutable changesets (figure 5 |
265 above). Two developers, Alice and Bob, start working from this point:: | 283 above). Two developers, Alice and Bob, start working from this point:: |
266 | 284 |
267 $ hg clone -q public alice | 285 $ hg clone public alice |
268 $ hg clone -q public bob | 286 updating to branch default |
287 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
288 $ hg clone public bob | |
289 updating to branch default | |
290 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
269 | 291 |
270 We need to configure Alice's and Bob's working repositories similar to | 292 We need to configure Alice's and Bob's working repositories similar to |
271 ``test-repo``, i.e. make them non-publishing and enable ``evolve``:: | 293 ``test-repo``, i.e. make them non-publishing and enable ``evolve``:: |
272 | 294 |
273 $ cat >> alice/.hg/hgrc <<EOF | 295 $ cat >> alice/.hg/hgrc <<EOF |
296 know if this bug fix is good enough to push to the public repository, | 318 know if this bug fix is good enough to push to the public repository, |
297 but it's good enough for Alice to commit. :: | 319 but it's good enough for Alice to commit. :: |
298 | 320 |
299 $ cd alice | 321 $ cd alice |
300 $ echo 'fix' > file2 | 322 $ echo 'fix' > file2 |
301 $ hg commit -q -A -m 'fix bug 15' | 323 $ hg commit -A -m 'fix bug 15' |
324 adding file2 | |
302 | 325 |
303 Now Bob has a bad idea: he decides to pull whatever Alice is working | 326 Now Bob has a bad idea: he decides to pull whatever Alice is working |
304 on and tweak her bug fix to his taste:: | 327 on and tweak her bug fix to his taste:: |
305 | 328 |
306 $ cd ../bob | 329 $ cd ../bob |
307 $ hg pull -q -u ../alice | 330 $ hg pull -u ../alice |
331 [...] | |
332 added 1 changesets with 1 changes to 1 files | |
333 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
308 $ echo 'Fix.' > file2 | 334 $ echo 'Fix.' > file2 |
309 $ hg amend -q -A -m 'fix bug 15 (amended)' | 335 $ hg amend -A -m 'fix bug 15 (amended)' |
310 | 336 |
311 (Note the lack of communication between Alice and Bob. Failing to | 337 (Note the lack of communication between Alice and Bob. Failing to |
312 communicate with your colleagues is a good way to get into trouble. | 338 communicate with your colleagues is a good way to get into trouble. |
313 Nevertheless, ``evolve`` can usually sort things out, as we will see.) | 339 Nevertheless, ``evolve`` can usually sort things out, as we will see.) |
314 | 340 |
317 After some testing, Alice realizes her bug fix is just fine as it is: | 343 After some testing, Alice realizes her bug fix is just fine as it is: |
318 no need for further polishing and amending, this changeset is ready to | 344 no need for further polishing and amending, this changeset is ready to |
319 publish. :: | 345 publish. :: |
320 | 346 |
321 $ cd ../alice | 347 $ cd ../alice |
322 $ hg push -q | 348 $ hg push |
349 [...] | |
350 added 1 changesets with 1 changes to 1 files | |
323 | 351 |
324 This introduces a contradiction: in Bob's repository, changeset 2:e011 | 352 This introduces a contradiction: in Bob's repository, changeset 2:e011 |
325 (his copy of Alice's fix) is obsolete, since Bob amended it. But in | 353 (his copy of Alice's fix) is obsolete, since Bob amended it. But in |
326 Alice's repository (and ``public``), that changeset is public: it is | 354 Alice's repository (and ``public``), that changeset is public: it is |
327 immutable, carved in stone for all eternity. No changeset can be both | 355 immutable, carved in stone for all eternity. No changeset can be both |
380 | 408 |
381 This time, Alice meddles with her colleague's work (still a bad | 409 This time, Alice meddles with her colleague's work (still a bad |
382 idea):: | 410 idea):: |
383 | 411 |
384 $ cd ../alice | 412 $ cd ../alice |
385 $ hg pull -q -u ../bob | 413 $ hg pull -u ../bob |
414 [...] | |
415 added 1 changesets with 1 changes to 1 files | |
386 $ echo 'better (alice)' >> file1 | 416 $ echo 'better (alice)' >> file1 |
387 $ hg amend -u alice -m 'fix bug 24 (v2 by alice)' | 417 $ hg amend -u alice -m 'fix bug 24 (v2 by alice)' |
388 | 418 |
389 Here's where things change from the "bumped" scenario above: this | 419 Here's where things change from the "bumped" scenario above: this |
390 time, the original author (Bob) decides to amend his changeset too. :: | 420 time, the original author (Bob) decides to amend his changeset too. :: |