Mercurial > evolve
comparison tests/test-sharing.t @ 1261:56cc2eb5995a stable
docs: add code review scenario to sharing guide
The idea is to demonstrate a simpler multiple-developer situation that
does not involve getting into trouble.
The final scenario illustrates Alice and Bob getting into trouble with
bumped and divergent changesets by amending each other's history. The
required tests and text are all written, but will need to be heavily
revised because of the inserted scenario.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Tue, 14 Apr 2015 12:53:12 -0400 |
parents | 0daf56a2032d |
children | eb0a1d1d499b |
comparison
equal
deleted
inserted
replaced
1260:e8016d1011b5 | 1261:56cc2eb5995a |
---|---|
79 o 0:0dc9c9f6ab91 public create new project | 79 o 0:0dc9c9f6ab91 public create new project |
80 | 80 |
81 Pull into dev-repo: obsolescence markers are transferred, but not | 81 Pull into dev-repo: obsolescence markers are transferred, but not |
82 the new obsolete changeset. | 82 the new obsolete changeset. |
83 $ cd ../dev-repo | 83 $ cd ../dev-repo |
84 $ hg pull -q -u | 84 $ hg pull -u |
85 pulling from $TESTTMP/test-repo | |
86 searching for changes | |
87 adding changesets | |
88 adding manifests | |
89 adding file changes | |
90 added 1 changesets with 1 changes to 1 files (+1 heads) | |
91 pull obsolescence markers | |
92 2 obsolescence markers added | |
93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
85 | 94 |
86 Figure SG03 | 95 Figure SG03 |
87 $ hg shortlog --hidden -G | 96 $ hg shortlog --hidden -G |
88 @ 2:60ffde5765c5 draft fix bug 37 | 97 @ 2:60ffde5765c5 draft fix bug 37 |
89 | | 98 | |
142 | 151 |
143 Oops, still have draft changesets in dev-repo. | 152 Oops, still have draft changesets in dev-repo. |
144 $ cd ../dev-repo | 153 $ cd ../dev-repo |
145 $ hg shortlog -r 'draft()' | 154 $ hg shortlog -r 'draft()' |
146 4:de6151c48e1c draft fix bug 37 | 155 4:de6151c48e1c draft fix bug 37 |
147 $ hg pull -q -u | 156 $ hg pull -u |
157 pulling from $TESTTMP/test-repo | |
158 searching for changes | |
159 no changes found | |
160 pull obsolescence markers | |
161 0 obsolescence markers added | |
148 $ hg shortlog -r 'draft()' | 162 $ hg shortlog -r 'draft()' |
149 | 163 |
150 Sharing by Alice and Bob to demonstrate bumped and divergent changesets. | 164 Sharing with multiple developers: code review |
151 First, setup repos for them. | |
152 | 165 |
153 $ cd .. | 166 $ cd .. |
154 $ hg clone public alice | 167 $ hg clone public review |
155 updating to branch default | 168 updating to branch default |
156 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 169 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
157 $ hg clone public bob | 170 $ hg clone review alice |
158 updating to branch default | 171 updating to branch default |
159 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 172 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
160 $ cat >> alice/.hg/hgrc <<EOF | 173 $ hg clone review bob |
174 updating to branch default | |
175 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
176 $ cat >> review/.hg/hgrc <<EOF | |
161 > [phases] | 177 > [phases] |
162 > publish = false | 178 > publish = false |
163 > EOF | 179 > EOF |
164 $ cp alice/.hg/hgrc bob/.hg/hgrc | 180 |
165 | 181 Alice commits a draft bug fix, pushes to review repo. |
166 Alice commits a bug fix. | |
167 $ cd alice | 182 $ cd alice |
183 $ hg bookmark bug15 | |
168 $ echo 'fix' > file2 | 184 $ echo 'fix' > file2 |
169 $ hg commit -A -u alice -m 'fix bug 15' | 185 $ hg commit -A -u alice -m 'fix bug 15 (v1)' |
170 adding file2 | 186 adding file2 |
171 | 187 $ hg push -B bug15 |
172 Bob pulls and amends Alice's fix. | 188 pushing to $TESTTMP/review |
189 searching for changes | |
190 adding changesets | |
191 adding manifests | |
192 adding file changes | |
193 added 1 changesets with 1 changes to 1 files | |
194 pushing 4 obsolescence markers (* bytes) (glob) | |
195 0 obsolescence markers added | |
196 exporting bookmark bug15 | |
197 $ hg -R ../review bookmarks | |
198 bug15 2:f91e97234c2b | |
199 | |
200 Alice receives code review, amends her fix, and goes out to lunch to | |
201 await second review. | |
202 $ echo 'Fix.' > file2 | |
203 $ hg amend -m 'fix bug 15 (v2)' | |
204 $ hg push | |
205 pushing to $TESTTMP/review | |
206 searching for changes | |
207 adding changesets | |
208 adding manifests | |
209 adding file changes | |
210 added 1 changesets with 1 changes to 1 files (+1 heads) | |
211 pushing 6 obsolescence markers (* bytes) (glob) | |
212 2 obsolescence markers added | |
213 updating bookmark bug15 | |
214 $ hg -R ../review bookmarks | |
215 bug15 3:cbdfbd5a5db2 | |
216 | |
217 Figure SG06: review repository after Alice pushes her amended changeset. | |
218 $ hg --hidden -R ../review shortlog -G -r 1:: | |
219 o 3:cbdfbd5a5db2 draft fix bug 15 (v2) | |
220 | | |
221 | x 2:f91e97234c2b draft fix bug 15 (v1) | |
222 |/ | |
223 @ 1:de6151c48e1c public fix bug 37 | |
224 | | |
225 | |
226 Bob commits a draft changeset, pushes to review repo. | |
173 $ cd ../bob | 227 $ cd ../bob |
174 $ hg pull -u ../alice | 228 $ echo 'stuff' > file1 |
175 pulling from ../alice | 229 $ hg bookmark featureX |
176 searching for changes | 230 $ hg commit -u bob -m 'implement feature X (v1)' |
177 adding changesets | 231 $ hg push -B featureX |
178 adding manifests | 232 pushing to $TESTTMP/review |
179 adding file changes | 233 searching for changes |
180 added 1 changesets with 1 changes to 1 files | 234 remote has heads on branch 'default' that are not known locally: cbdfbd5a5db2 |
235 adding changesets | |
236 adding manifests | |
237 adding file changes | |
238 added 1 changesets with 1 changes to 1 files (+1 heads) | |
239 pushing 4 obsolescence markers (* bytes) (glob) | |
240 0 obsolescence markers added | |
241 exporting bookmark featureX | |
242 $ hg -R ../review bookmarks | |
243 bug15 3:cbdfbd5a5db2 | |
244 featureX 4:193657d1e852 | |
245 | |
246 Bob receives first review, amends and pushes. | |
247 $ echo 'do stuff' > file1 | |
248 $ hg amend -m 'implement feature X (v2)' | |
249 $ hg push | |
250 pushing to $TESTTMP/review | |
251 searching for changes | |
252 remote has heads on branch 'default' that are not known locally: cbdfbd5a5db2 | |
253 adding changesets | |
254 adding manifests | |
255 adding file changes | |
256 added 1 changesets with 1 changes to 1 files (+1 heads) | |
257 pushing 6 obsolescence markers (* bytes) (glob) | |
258 2 obsolescence markers added | |
259 updating bookmark featureX | |
260 | |
261 Bob receives second review, amends, and pushes to public: | |
262 this time, he's sure he got it right! | |
263 $ echo 'Do stuff.' > file1 | |
264 $ hg amend -m 'implement feature X (v3)' | |
265 $ hg push ../public | |
266 pushing to ../public | |
267 searching for changes | |
268 adding changesets | |
269 adding manifests | |
270 adding file changes | |
271 added 1 changesets with 1 changes to 1 files | |
272 pushing 8 obsolescence markers (* bytes) (glob) | |
273 4 obsolescence markers added | |
274 $ hg -R ../public bookmarks | |
275 no bookmarks set | |
276 $ hg push ../review | |
277 pushing to ../review | |
278 searching for changes | |
279 remote has heads on branch 'default' that are not known locally: cbdfbd5a5db2 | |
280 adding changesets | |
281 adding manifests | |
282 adding file changes | |
283 added 1 changesets with 1 changes to 1 files (+1 heads) | |
284 pushing 8 obsolescence markers (* bytes) (glob) | |
285 2 obsolescence markers added | |
286 updating bookmark featureX | |
287 $ hg -R ../review bookmarks | |
288 bug15 3:cbdfbd5a5db2 | |
289 featureX 6:540ba8f317e6 | |
290 | |
291 Figure SG07: review and public repos after Bob implements feature X. | |
292 $ hg --hidden -R ../review shortlog -G -r 1:: | |
293 o 6:540ba8f317e6 public implement feature X (v3) | |
294 | | |
295 | x 5:0eb74a7b6698 draft implement feature X (v2) | |
296 |/ | |
297 | x 4:193657d1e852 draft implement feature X (v1) | |
298 |/ | |
299 | o 3:cbdfbd5a5db2 draft fix bug 15 (v2) | |
300 |/ | |
301 | x 2:f91e97234c2b draft fix bug 15 (v1) | |
302 |/ | |
303 @ 1:de6151c48e1c public fix bug 37 | |
304 | | |
305 $ hg --hidden -R ../public shortlog -G -r 1:: | |
306 o 2:540ba8f317e6 public implement feature X (v3) | |
307 | | |
308 o 1:de6151c48e1c public fix bug 37 | |
309 | | |
310 | |
311 How do things look in the review repo? | |
312 $ cd ../review | |
313 $ hg --hidden shortlog -G -r 1:: | |
314 o 6:540ba8f317e6 public implement feature X (v3) | |
315 | | |
316 | x 5:0eb74a7b6698 draft implement feature X (v2) | |
317 |/ | |
318 | x 4:193657d1e852 draft implement feature X (v1) | |
319 |/ | |
320 | o 3:cbdfbd5a5db2 draft fix bug 15 (v2) | |
321 |/ | |
322 | x 2:f91e97234c2b draft fix bug 15 (v1) | |
323 |/ | |
324 @ 1:de6151c48e1c public fix bug 37 | |
325 | | |
326 | |
327 Meantime, Alice is back from lunch. While she was away, Bob approved | |
328 her change, so now she can publish it. | |
329 $ cd ../alice | |
330 $ hg --hidden shortlog -G -r 1:: | |
331 @ 4:cbdfbd5a5db2 draft fix bug 15 (v2) | |
332 | | |
333 | x 3:55dd95168a35 draft temporary amend commit for f91e97234c2b | |
334 | | | |
335 | x 2:f91e97234c2b draft fix bug 15 (v1) | |
336 |/ | |
337 o 1:de6151c48e1c public fix bug 37 | |
338 | | |
339 $ hg outgoing -q ../public | |
340 4:cbdfbd5a5db2 | |
341 $ hg push ../public | |
342 pushing to ../public | |
343 searching for changes | |
344 remote has heads on branch 'default' that are not known locally: 540ba8f317e6 | |
345 abort: push creates new remote head cbdfbd5a5db2 with bookmark 'bug15'! | |
346 (pull and merge or see "hg help push" for details about pushing new heads) | |
347 [255] | |
348 $ hg pull ../public | |
349 pulling from ../public | |
350 searching for changes | |
351 adding changesets | |
352 adding manifests | |
353 adding file changes | |
354 added 1 changesets with 1 changes to 1 files (+1 heads) | |
181 pull obsolescence markers | 355 pull obsolescence markers |
182 0 obsolescence markers added | 356 4 obsolescence markers added |
183 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 357 (run 'hg heads' to see heads, 'hg merge' to merge) |
184 $ echo 'Fix.' > file2 | 358 $ hg log -G -q -r 'head()' |
185 $ hg amend -A -u bob -m 'fix bug 15 (amended)' | 359 o 5:540ba8f317e6 |
186 | 360 | |
187 Figure SG06: Bob's repository after amending Alice's fix. | 361 | @ 4:cbdfbd5a5db2 |
188 (Nothing new here; we could have seen this in the user guide. | 362 |/ |
189 $ hg --hidden shortlog -G | 363 $ hg --hidden shortlog -G -r 1:: |
190 @ 4:fe884dfac355 draft fix bug 15 (amended) | 364 o 5:540ba8f317e6 public implement feature X (v3) |
191 | | 365 | |
192 | x 3:0376cac226f8 draft temporary amend commit for e011baf925da | 366 | @ 4:cbdfbd5a5db2 draft fix bug 15 (v2) |
367 |/ | |
368 | x 3:55dd95168a35 draft temporary amend commit for f91e97234c2b | |
193 | | | 369 | | |
194 | x 2:e011baf925da draft fix bug 15 | 370 | x 2:f91e97234c2b draft fix bug 15 (v1) |
195 |/ | 371 |/ |
196 o 1:de6151c48e1c public fix bug 37 | 372 o 1:de6151c48e1c public fix bug 37 |
197 | | 373 | |
198 o 0:0dc9c9f6ab91 public create new project | 374 |
199 | 375 Alice rebases her draft changeset on top of Bob's public changeset and |
200 | 376 publishes the result. |
201 But in the meantime, Alice decides the fix is just fine and publishes it. | 377 $ hg rebase -d 5 |
202 $ cd ../alice | 378 rebasing 4:cbdfbd5a5db2 "fix bug 15 (v2)" (bug15) |
203 $ hg push | 379 $ hg push ../public |
204 pushing to $TESTTMP/public | 380 pushing to ../public |
205 searching for changes | 381 searching for changes |
206 adding changesets | 382 adding changesets |
207 adding manifests | 383 adding manifests |
208 adding file changes | 384 adding file changes |
209 added 1 changesets with 1 changes to 1 files | 385 added 1 changesets with 1 changes to 1 files |
210 pushing 4 obsolescence markers (369 bytes) | 386 pushing 11 obsolescence markers (* bytes) (glob) |
211 0 obsolescence markers added | 387 3 obsolescence markers added |
212 | 388 $ hg push ../review |
213 Which means that Bob now has an formerly obsolete changeset that is | 389 pushing to ../review |
214 also public (2:6e83). As soon as he pulls its phase change, he's got | 390 searching for changes |
215 trouble: the successors of that formerly obsolete changeset are | 391 adding changesets |
216 bumped. | 392 adding manifests |
217 | 393 adding file changes |
218 $ cd ../bob | 394 added 1 changesets with 0 changes to 1 files |
219 $ hg --hidden shortlog -r 'obsolete()' | 395 pushing 11 obsolescence markers (* bytes) (glob) |
220 2:e011baf925da draft fix bug 15 | 396 1 obsolescence markers added |
221 3:0376cac226f8 draft temporary amend commit for e011baf925da | 397 updating bookmark bug15 |
222 $ hg pull -q -u | 398 |
223 1 new bumped changesets | 399 Figure SG08: review and public changesets after Alice pushes. |
224 $ hg --hidden shortlog -r 'obsolete()' | 400 $ hg --hidden -R ../review shortlog -G -r 1:: |
225 3:0376cac226f8 draft temporary amend commit for e011baf925da | 401 o 7:a06ec1bf97bd public fix bug 15 (v2) |
226 $ hg shortlog -r 'bumped()' | 402 | |
227 4:fe884dfac355 draft fix bug 15 (amended) | 403 o 6:540ba8f317e6 public implement feature X (v3) |
228 | 404 | |
229 Figure SG07: Bob's repo with one bumped changeset (rev 4:c02d) | 405 | x 5:0eb74a7b6698 draft implement feature X (v2) |
230 $ hg --hidden shortlog -G | 406 |/ |
231 @ 4:fe884dfac355 draft fix bug 15 (amended) | 407 | x 4:193657d1e852 draft implement feature X (v1) |
232 | | 408 |/ |
233 | x 3:0376cac226f8 draft temporary amend commit for e011baf925da | 409 | x 3:cbdfbd5a5db2 draft fix bug 15 (v2) |
234 | | | 410 |/ |
235 | o 2:e011baf925da public fix bug 15 | 411 | x 2:f91e97234c2b draft fix bug 15 (v1) |
236 |/ | 412 |/ |
413 @ 1:de6151c48e1c public fix bug 37 | |
414 | | |
415 $ hg --hidden -R ../public shortlog -G -r 1:: | |
416 o 3:a06ec1bf97bd public fix bug 15 (v2) | |
417 | | |
418 o 2:540ba8f317e6 public implement feature X (v3) | |
419 | | |
237 o 1:de6151c48e1c public fix bug 37 | 420 o 1:de6151c48e1c public fix bug 37 |
238 | | 421 | |
239 o 0:0dc9c9f6ab91 public create new project | |
240 | |
241 | |
242 Bob gets out of trouble by evolving the repository. | |
243 $ hg evolve --all | |
244 recreate:[4] fix bug 15 (amended) | |
245 atop:[2] fix bug 15 | |
246 computing new diff | |
247 committed as 227d860d9ad0 | |
248 working directory is now at 227d860d9ad0 | |
249 | |
250 Figure SG08 | |
251 $ hg --hidden shortlog -G | |
252 @ 5:227d860d9ad0 draft bumped update to e011baf925da: | |
253 | | |
254 | x 4:fe884dfac355 draft fix bug 15 (amended) | |
255 | | | |
256 +---x 3:0376cac226f8 draft temporary amend commit for e011baf925da | |
257 | | | |
258 o | 2:e011baf925da public fix bug 15 | |
259 |/ | |
260 o 1:de6151c48e1c public fix bug 37 | |
261 | | |
262 o 0:0dc9c9f6ab91 public create new project | |
263 | |
264 | |
265 Throw away Bob's messy repo and start over. | |
266 $ cd .. | |
267 $ rm -rf bob | |
268 $ cp -rp alice bob | |
269 | |
270 Bob commits a pretty good fix that both he and Alice will amend, | |
271 leading to divergence. | |
272 $ cd bob | |
273 $ echo 'pretty good fix' >> file1 | |
274 $ hg commit -u bob -m 'fix bug 24 (v1)' | |
275 | |
276 Alice pulls Bob's fix and improves it. | |
277 $ cd ../alice | |
278 $ hg pull -u ../bob | |
279 pulling from ../bob | |
280 searching for changes | |
281 adding changesets | |
282 adding manifests | |
283 adding file changes | |
284 added 1 changesets with 1 changes to 1 files | |
285 pull obsolescence markers | |
286 0 obsolescence markers added | |
287 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
288 $ echo 'better (alice)' >> file1 | |
289 $ hg amend -u alice -m 'fix bug 24 (v2 by alice)' | |
290 | |
291 Likewise, Bob amends his own fix. Now we have an obsolete changeset | |
292 with two successors, although the successors are in different repos. | |
293 $ cd ../bob | |
294 $ echo 'better (bob)' >> file1 | |
295 $ hg amend -u bob -m 'fix bug 24 (v2 by bob)' | |
296 | |
297 Bob pulls from Alice's repo and discovers the trouble: divergent changesets! | |
298 $ hg pull -q -u ../alice | |
299 not updating: not a linear update | |
300 (merge or update --check to force update) | |
301 2 new divergent changesets | |
302 $ hg shortlog -r 'divergent()' | |
303 5:fc16901f4d7a draft fix bug 24 (v2 by bob) | |
304 6:694fd0f6b503 draft fix bug 24 (v2 by alice) | |
305 | |
306 Figure SG09 | |
307 $ hg --hidden shortlog -G | |
308 o 6:694fd0f6b503 draft fix bug 24 (v2 by alice) | |
309 | | |
310 | @ 5:fc16901f4d7a draft fix bug 24 (v2 by bob) | |
311 |/ | |
312 | x 4:162612d3335b draft temporary amend commit for fe81d904ed08 | |
313 | | | |
314 | x 3:fe81d904ed08 draft fix bug 24 (v1) | |
315 |/ | |
316 o 2:e011baf925da public fix bug 15 | |
317 | | |
318 o 1:de6151c48e1c public fix bug 37 | |
319 | | |
320 o 0:0dc9c9f6ab91 public create new project | |
321 | |
322 Merge the trouble away. | |
323 $ hg merge --tool internal:local | |
324 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
325 (branch merge, don't forget to commit) | |
326 $ hg commit -m merge | |
327 $ hg shortlog -G | |
328 @ 7:b1d30ba26e44 draft merge | |
329 |\ | |
330 | o 6:694fd0f6b503 draft fix bug 24 (v2 by alice) | |
331 | | | |
332 o | 5:fc16901f4d7a draft fix bug 24 (v2 by bob) | |
333 |/ | |
334 o 2:e011baf925da public fix bug 15 | |
335 | | |
336 o 1:de6151c48e1c public fix bug 37 | |
337 | | |
338 o 0:0dc9c9f6ab91 public create new project | |
339 | |
340 $ hg log -q -r 'divergent()' | |
341 5:fc16901f4d7a | |
342 6:694fd0f6b503 | |
343 | |
344 # XXX hg evolve does not solve this trouble! bug in evolve? | |
345 #Evolve the trouble away. | |
346 # $ hg evolve --all --tool=internal:local | |
347 # merge:[5] fix bug 24 (v2 by bob) | |
348 # with: [6] fix bug 24 (v2 by alice) | |
349 # base: [3] fix bug 24 (v1) | |
350 # 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
351 # $ hg status | |
352 # $ hg shortlog -G | |
353 # o 6:694fd0f6b503 draft fix bug 24 (v2 by alice) | |
354 # | | |
355 # | @ 5:fc16901f4d7a draft fix bug 24 (v2 by bob) | |
356 # |/ | |
357 # o 2:e011baf925da public fix bug 15 | |
358 # | | |
359 # o 1:de6151c48e1c public fix bug 37 | |
360 # | | |
361 # o 0:0dc9c9f6ab91 public create new project | |
362 # | |
363 # $ hg --hidden shortlog -G |