##// END OF EJS Templates
tests: explicitly request changed version in c/d conflict in test-commit-amend.t...
Siddharth Agarwal -
r27597:fe150586 default
parent child Browse files
Show More
@@ -1,1156 +1,1158 b''
1 1 $ cat << EOF >> $HGRCPATH
2 2 > [format]
3 3 > usegeneraldelta=yes
4 4 > EOF
5 5
6 6 $ hg init
7 7
8 8 Setup:
9 9
10 10 $ echo a >> a
11 11 $ hg ci -Am 'base'
12 12 adding a
13 13
14 14 Refuse to amend public csets:
15 15
16 16 $ hg phase -r . -p
17 17 $ hg ci --amend
18 18 abort: cannot amend public changesets
19 19 [255]
20 20 $ hg phase -r . -f -d
21 21
22 22 $ echo a >> a
23 23 $ hg ci -Am 'base1'
24 24
25 25 Nothing to amend:
26 26
27 27 $ hg ci --amend -m 'base1'
28 28 nothing changed
29 29 [1]
30 30
31 31 $ cat >> $HGRCPATH <<EOF
32 32 > [hooks]
33 33 > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
34 34 > EOF
35 35
36 36 Amending changeset with changes in working dir:
37 37 (and check that --message does not trigger an editor)
38 38
39 39 $ echo a >> a
40 40 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
41 41 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
42 42 43f1ba15f28a tip
43 43 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-f1bf3ab8-amend-backup.hg (glob)
44 44 $ echo 'pretxncommit.foo = ' >> $HGRCPATH
45 45 $ hg diff -c .
46 46 diff -r ad120869acf0 -r 43f1ba15f28a a
47 47 --- a/a Thu Jan 01 00:00:00 1970 +0000
48 48 +++ b/a Thu Jan 01 00:00:00 1970 +0000
49 49 @@ -1,1 +1,3 @@
50 50 a
51 51 +a
52 52 +a
53 53 $ hg log
54 54 changeset: 1:43f1ba15f28a
55 55 tag: tip
56 56 user: test
57 57 date: Thu Jan 01 00:00:00 1970 +0000
58 58 summary: amend base1
59 59
60 60 changeset: 0:ad120869acf0
61 61 user: test
62 62 date: Thu Jan 01 00:00:00 1970 +0000
63 63 summary: base
64 64
65 65
66 66 Check proper abort for empty message
67 67
68 68 $ cat > editor.sh << '__EOF__'
69 69 > #!/bin/sh
70 70 > echo "" > "$1"
71 71 > __EOF__
72 72 $ echo b > b
73 73 $ hg add b
74 74 $ hg summary
75 75 parent: 1:43f1ba15f28a tip
76 76 amend base1
77 77 branch: default
78 78 commit: 1 added, 1 unknown
79 79 update: (current)
80 80 phases: 2 draft
81 81 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
82 82 transaction abort!
83 83 rollback completed
84 84 abort: empty commit message
85 85 [255]
86 86 $ hg summary
87 87 parent: 1:43f1ba15f28a tip
88 88 amend base1
89 89 branch: default
90 90 commit: 1 added, 1 unknown
91 91 update: (current)
92 92 phases: 2 draft
93 93
94 94 Add new file:
95 95 $ hg ci --amend -m 'amend base1 new file'
96 96 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-7a3b3496-amend-backup.hg (glob)
97 97
98 98 Remove file that was added in amended commit:
99 99 (and test logfile option)
100 100 (and test that logfile option do not trigger an editor)
101 101
102 102 $ hg rm b
103 103 $ echo 'amend base1 remove new file' > ../logfile
104 104 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
105 105 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-0b55739a-amend-backup.hg (glob)
106 106
107 107 $ hg cat b
108 108 b: no such file in rev 74609c7f506e
109 109 [1]
110 110
111 111 No changes, just a different message:
112 112
113 113 $ hg ci -v --amend -m 'no changes, new message'
114 114 amending changeset 74609c7f506e
115 115 copying changeset 74609c7f506e to ad120869acf0
116 116 committing files:
117 117 a
118 118 committing manifest
119 119 committing changelog
120 120 stripping amended changeset 74609c7f506e
121 121 1 changesets found
122 122 uncompressed size of bundle content:
123 123 270 (changelog)
124 124 163 (manifests)
125 125 129 a
126 126 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-1bfde511-amend-backup.hg (glob)
127 127 1 changesets found
128 128 uncompressed size of bundle content:
129 129 266 (changelog)
130 130 163 (manifests)
131 131 129 a
132 132 adding branch
133 133 adding changesets
134 134 adding manifests
135 135 adding file changes
136 136 added 1 changesets with 1 changes to 1 files
137 137 committed changeset 1:1cd866679df8
138 138 $ hg diff -c .
139 139 diff -r ad120869acf0 -r 1cd866679df8 a
140 140 --- a/a Thu Jan 01 00:00:00 1970 +0000
141 141 +++ b/a Thu Jan 01 00:00:00 1970 +0000
142 142 @@ -1,1 +1,3 @@
143 143 a
144 144 +a
145 145 +a
146 146 $ hg log
147 147 changeset: 1:1cd866679df8
148 148 tag: tip
149 149 user: test
150 150 date: Thu Jan 01 00:00:00 1970 +0000
151 151 summary: no changes, new message
152 152
153 153 changeset: 0:ad120869acf0
154 154 user: test
155 155 date: Thu Jan 01 00:00:00 1970 +0000
156 156 summary: base
157 157
158 158
159 159 Disable default date on commit so when -d isn't given, the old date is preserved:
160 160
161 161 $ echo '[defaults]' >> $HGRCPATH
162 162 $ echo 'commit=' >> $HGRCPATH
163 163
164 164 Test -u/-d:
165 165
166 166 $ cat > .hg/checkeditform.sh <<EOF
167 167 > env | grep HGEDITFORM
168 168 > true
169 169 > EOF
170 170 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
171 171 HGEDITFORM=commit.amend.normal
172 172 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-5f5bcb85-amend-backup.hg (glob)
173 173 $ echo a >> a
174 174 $ hg ci --amend -u foo -d '1 0'
175 175 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-83b10a27-amend-backup.hg (glob)
176 176 $ hg log -r .
177 177 changeset: 1:5f357c7560ab
178 178 tag: tip
179 179 user: foo
180 180 date: Thu Jan 01 00:00:01 1970 +0000
181 181 summary: no changes, new message
182 182
183 183
184 184 Open editor with old commit message if a message isn't given otherwise:
185 185
186 186 $ cat > editor.sh << '__EOF__'
187 187 > #!/bin/sh
188 188 > cat $1
189 189 > echo "another precious commit message" > "$1"
190 190 > __EOF__
191 191
192 192 at first, test saving last-message.txt
193 193
194 194 $ cat > .hg/hgrc << '__EOF__'
195 195 > [hooks]
196 196 > pretxncommit.test-saving-last-message = false
197 197 > __EOF__
198 198
199 199 $ rm -f .hg/last-message.txt
200 200 $ hg commit --amend -v -m "message given from command line"
201 201 amending changeset 5f357c7560ab
202 202 copying changeset 5f357c7560ab to ad120869acf0
203 203 committing files:
204 204 a
205 205 committing manifest
206 206 committing changelog
207 207 running hook pretxncommit.test-saving-last-message: false
208 208 transaction abort!
209 209 rollback completed
210 210 abort: pretxncommit.test-saving-last-message hook exited with status 1
211 211 [255]
212 212 $ cat .hg/last-message.txt
213 213 message given from command line (no-eol)
214 214
215 215 $ rm -f .hg/last-message.txt
216 216 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
217 217 amending changeset 5f357c7560ab
218 218 copying changeset 5f357c7560ab to ad120869acf0
219 219 no changes, new message
220 220
221 221
222 222 HG: Enter commit message. Lines beginning with 'HG:' are removed.
223 223 HG: Leave message empty to abort commit.
224 224 HG: --
225 225 HG: user: foo
226 226 HG: branch 'default'
227 227 HG: changed a
228 228 committing files:
229 229 a
230 230 committing manifest
231 231 committing changelog
232 232 running hook pretxncommit.test-saving-last-message: false
233 233 transaction abort!
234 234 rollback completed
235 235 abort: pretxncommit.test-saving-last-message hook exited with status 1
236 236 [255]
237 237
238 238 $ cat .hg/last-message.txt
239 239 another precious commit message
240 240
241 241 $ cat > .hg/hgrc << '__EOF__'
242 242 > [hooks]
243 243 > pretxncommit.test-saving-last-message =
244 244 > __EOF__
245 245
246 246 then, test editing custom commit message
247 247
248 248 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
249 249 amending changeset 5f357c7560ab
250 250 copying changeset 5f357c7560ab to ad120869acf0
251 251 no changes, new message
252 252
253 253
254 254 HG: Enter commit message. Lines beginning with 'HG:' are removed.
255 255 HG: Leave message empty to abort commit.
256 256 HG: --
257 257 HG: user: foo
258 258 HG: branch 'default'
259 259 HG: changed a
260 260 committing files:
261 261 a
262 262 committing manifest
263 263 committing changelog
264 264 stripping amended changeset 5f357c7560ab
265 265 1 changesets found
266 266 uncompressed size of bundle content:
267 267 258 (changelog)
268 268 163 (manifests)
269 269 131 a
270 270 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-e7c84ade-amend-backup.hg (glob)
271 271 1 changesets found
272 272 uncompressed size of bundle content:
273 273 266 (changelog)
274 274 163 (manifests)
275 275 131 a
276 276 adding branch
277 277 adding changesets
278 278 adding manifests
279 279 adding file changes
280 280 added 1 changesets with 1 changes to 1 files
281 281 committed changeset 1:7ab3bf440b54
282 282
283 283 Same, but with changes in working dir (different code path):
284 284
285 285 $ echo a >> a
286 286 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
287 287 amending changeset 7ab3bf440b54
288 288 committing files:
289 289 a
290 290 committing manifest
291 291 committing changelog
292 292 copying changeset a0ea9b1a4c8c to ad120869acf0
293 293 another precious commit message
294 294
295 295
296 296 HG: Enter commit message. Lines beginning with 'HG:' are removed.
297 297 HG: Leave message empty to abort commit.
298 298 HG: --
299 299 HG: user: foo
300 300 HG: branch 'default'
301 301 HG: changed a
302 302 committing files:
303 303 a
304 304 committing manifest
305 305 committing changelog
306 306 stripping intermediate changeset a0ea9b1a4c8c
307 307 stripping amended changeset 7ab3bf440b54
308 308 2 changesets found
309 309 uncompressed size of bundle content:
310 310 490 (changelog)
311 311 322 (manifests)
312 312 249 a
313 313 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-8e3b5088-amend-backup.hg (glob)
314 314 1 changesets found
315 315 uncompressed size of bundle content:
316 316 266 (changelog)
317 317 163 (manifests)
318 318 133 a
319 319 adding branch
320 320 adding changesets
321 321 adding manifests
322 322 adding file changes
323 323 added 1 changesets with 1 changes to 1 files
324 324 committed changeset 1:ea22a388757c
325 325
326 326 $ rm editor.sh
327 327 $ hg log -r .
328 328 changeset: 1:ea22a388757c
329 329 tag: tip
330 330 user: foo
331 331 date: Thu Jan 01 00:00:01 1970 +0000
332 332 summary: another precious commit message
333 333
334 334
335 335 Moving bookmarks, preserve active bookmark:
336 336
337 337 $ hg book book1
338 338 $ hg book book2
339 339 $ hg ci --amend -m 'move bookmarks'
340 340 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-e51094db-amend-backup.hg (glob)
341 341 $ hg book
342 342 book1 1:6cec5aa930e2
343 343 * book2 1:6cec5aa930e2
344 344 $ echo a >> a
345 345 $ hg ci --amend -m 'move bookmarks'
346 346 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-e9b06de4-amend-backup.hg (glob)
347 347 $ hg book
348 348 book1 1:48bb6e53a15f
349 349 * book2 1:48bb6e53a15f
350 350
351 351 abort does not loose bookmarks
352 352
353 353 $ cat > editor.sh << '__EOF__'
354 354 > #!/bin/sh
355 355 > echo "" > "$1"
356 356 > __EOF__
357 357 $ echo a >> a
358 358 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
359 359 transaction abort!
360 360 rollback completed
361 361 abort: empty commit message
362 362 [255]
363 363 $ hg book
364 364 book1 1:48bb6e53a15f
365 365 * book2 1:48bb6e53a15f
366 366 $ hg revert -Caq
367 367 $ rm editor.sh
368 368
369 369 $ echo '[defaults]' >> $HGRCPATH
370 370 $ echo "commit=-d '0 0'" >> $HGRCPATH
371 371
372 372 Moving branches:
373 373
374 374 $ hg branch foo
375 375 marked working directory as branch foo
376 376 (branches are permanent and global, did you want a bookmark?)
377 377 $ echo a >> a
378 378 $ hg ci -m 'branch foo'
379 379 $ hg branch default -f
380 380 marked working directory as branch default
381 381 $ hg ci --amend -m 'back to default'
382 382 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-fd962fef-amend-backup.hg (glob)
383 383 $ hg branches
384 384 default 2:ce12b0b57d46
385 385
386 386 Close branch:
387 387
388 388 $ hg up -q 0
389 389 $ echo b >> b
390 390 $ hg branch foo
391 391 marked working directory as branch foo
392 392 (branches are permanent and global, did you want a bookmark?)
393 393 $ hg ci -Am 'fork'
394 394 adding b
395 395 $ echo b >> b
396 396 $ hg ci -mb
397 397 $ hg ci --amend --close-branch -m 'closing branch foo'
398 398 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-6701c392-amend-backup.hg (glob)
399 399
400 400 Same thing, different code path:
401 401
402 402 $ echo b >> b
403 403 $ hg ci -m 'reopen branch'
404 404 reopening closed branch head 4
405 405 $ echo b >> b
406 406 $ hg ci --amend --close-branch
407 407 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-49c0c55d-amend-backup.hg (glob)
408 408 $ hg branches
409 409 default 2:ce12b0b57d46
410 410
411 411 Refuse to amend during a merge:
412 412
413 413 $ hg up -q default
414 414 $ hg merge foo
415 415 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
416 416 (branch merge, don't forget to commit)
417 417 $ hg ci --amend
418 418 abort: cannot amend while merging
419 419 [255]
420 420 $ hg ci -m 'merge'
421 421
422 422 Follow copies/renames:
423 423
424 424 $ hg mv b c
425 425 $ hg ci -m 'b -> c'
426 426 $ hg mv c d
427 427 $ hg ci --amend -m 'b -> d'
428 428 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-adaaa8b1-amend-backup.hg (glob)
429 429 $ hg st --rev '.^' --copies d
430 430 A d
431 431 b
432 432 $ hg cp d e
433 433 $ hg ci -m 'e = d'
434 434 $ hg cp e f
435 435 $ hg ci --amend -m 'f = d'
436 436 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-d37aa788-amend-backup.hg (glob)
437 437 $ hg st --rev '.^' --copies f
438 438 A f
439 439 d
440 440
441 441 $ mv f f.orig
442 442 $ hg rm -A f
443 443 $ hg ci -m removef
444 444 $ hg cp a f
445 445 $ mv f.orig f
446 446 $ hg ci --amend -m replacef
447 447 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-90259f67-amend-backup.hg (glob)
448 448 $ hg st --change . --copies
449 449 $ hg log -r . --template "{file_copies}\n"
450 450
451 451
452 452 Move added file (issue3410):
453 453
454 454 $ echo g >> g
455 455 $ hg ci -Am g
456 456 adding g
457 457 $ hg mv g h
458 458 $ hg ci --amend
459 459 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-7059e0f1-amend-backup.hg (glob)
460 460 $ hg st --change . --copies h
461 461 A h
462 462 $ hg log -r . --template "{file_copies}\n"
463 463
464 464
465 465 Can't rollback an amend:
466 466
467 467 $ hg rollback
468 468 no rollback information available
469 469 [1]
470 470
471 471 Preserve extra dict (issue3430):
472 472
473 473 $ hg branch a
474 474 marked working directory as branch a
475 475 (branches are permanent and global, did you want a bookmark?)
476 476 $ echo a >> a
477 477 $ hg ci -ma
478 478 $ hg ci --amend -m "a'"
479 479 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-2be01fd1-amend-backup.hg (glob)
480 480 $ hg log -r . --template "{branch}\n"
481 481 a
482 482 $ hg ci --amend -m "a''"
483 483 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-ed28c4cd-amend-backup.hg (glob)
484 484 $ hg log -r . --template "{branch}\n"
485 485 a
486 486
487 487 Also preserve other entries in the dict that are in the old commit,
488 488 first graft something so there's an additional entry:
489 489
490 490 $ hg up 0 -q
491 491 $ echo z > z
492 492 $ hg ci -Am 'fork'
493 493 adding z
494 494 created new head
495 495 $ hg up 11
496 496 5 files updated, 0 files merged, 1 files removed, 0 files unresolved
497 497 $ hg graft 12
498 498 grafting 12:2647734878ef "fork" (tip)
499 499 $ hg ci --amend -m 'graft amend'
500 500 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-eedb103b-amend-backup.hg (glob)
501 501 $ hg log -r . --debug | grep extra
502 502 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e
503 503 extra: branch=a
504 504 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
505 505
506 506 Preserve phase
507 507
508 508 $ hg phase '.^::.'
509 509 11: draft
510 510 13: draft
511 511 $ hg phase --secret --force .
512 512 $ hg phase '.^::.'
513 513 11: draft
514 514 13: secret
515 515 $ hg commit --amend -m 'amend for phase' -q
516 516 $ hg phase '.^::.'
517 517 11: draft
518 518 13: secret
519 519
520 520 Test amend with obsolete
521 521 ---------------------------
522 522
523 523 Enable obsolete
524 524
525 525 $ cat >> $HGRCPATH << EOF
526 526 > [experimental]
527 527 > evolution=createmarkers,allowunstable
528 528 > EOF
529 529
530 530 Amend with no files changes
531 531
532 532 $ hg id -n
533 533 13
534 534 $ hg ci --amend -m 'babar'
535 535 $ hg id -n
536 536 14
537 537 $ hg log -Gl 3 --style=compact
538 538 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
539 539 | babar
540 540 |
541 541 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
542 542 | | fork
543 543 | |
544 544 o | 11 3334b7925910 1970-01-01 00:00 +0000 test
545 545 | | a''
546 546 | |
547 547 $ hg log -Gl 4 --hidden --style=compact
548 548 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
549 549 | babar
550 550 |
551 551 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
552 552 |/ amend for phase
553 553 |
554 554 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
555 555 | | fork
556 556 | |
557 557 o | 11 3334b7925910 1970-01-01 00:00 +0000 test
558 558 | | a''
559 559 | |
560 560
561 561 Amend with files changes
562 562
563 563 (note: the extra commit over 15 is a temporary junk I would be happy to get
564 564 ride of)
565 565
566 566 $ echo 'babar' >> a
567 567 $ hg commit --amend
568 568 $ hg log -Gl 6 --hidden --style=compact
569 569 @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test
570 570 | babar
571 571 |
572 572 | x 15 90fef497c56f 1970-01-01 00:00 +0000 test
573 573 | | temporary amend commit for b650e6ee8614
574 574 | |
575 575 | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test
576 576 |/ babar
577 577 |
578 578 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
579 579 |/ amend for phase
580 580 |
581 581 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
582 582 | | fork
583 583 | |
584 584 o | 11 3334b7925910 1970-01-01 00:00 +0000 test
585 585 | | a''
586 586 | |
587 587
588 588
589 589 Test that amend does not make it easy to create obsolescence cycle
590 590 ---------------------------------------------------------------------
591 591
592 592 $ hg id -r 14 --hidden
593 593 b650e6ee8614 (a)
594 594 $ hg revert -ar 14 --hidden
595 595 reverting a
596 596 $ hg commit --amend
597 597 $ hg id
598 598 b99e5df575f7 (a) tip
599 599
600 600 Test that rewriting leaving instability behind is allowed
601 601 ---------------------------------------------------------------------
602 602
603 603 $ hg up '.^'
604 604 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
605 605 $ echo 'b' >> a
606 606 $ hg log --style compact -r 'children(.)'
607 607 18[tip]:11 b99e5df575f7 1970-01-01 00:00 +0000 test
608 608 babar
609 609
610 610 $ hg commit --amend
611 611 $ hg log -r 'unstable()'
612 612 changeset: 18:b99e5df575f7
613 613 branch: a
614 614 parent: 11:3334b7925910
615 615 user: test
616 616 date: Thu Jan 01 00:00:00 1970 +0000
617 617 summary: babar
618 618
619 619
620 620 Amend a merge changeset (with renames and conflicts from the second parent):
621 621
622 622 $ hg up -q default
623 623 $ hg branch -q bar
624 624 $ hg cp a aa
625 625 $ hg mv z zz
626 626 $ echo cc > cc
627 627 $ hg add cc
628 628 $ hg ci -m aazzcc
629 629 $ hg up -q default
630 630 $ echo a >> a
631 631 $ echo dd > cc
632 632 $ hg add cc
633 633 $ hg ci -m aa
634 634 $ hg merge -q bar
635 635 warning: conflicts while merging cc! (edit, then use 'hg resolve --mark')
636 636 [1]
637 637 $ hg resolve -m cc
638 638 (no more unresolved files)
639 639 $ hg ci -m 'merge bar'
640 640 $ hg log --config diff.git=1 -pr .
641 641 changeset: 23:93cd4445f720
642 642 tag: tip
643 643 parent: 22:30d96aeaf27b
644 644 parent: 21:1aa437659d19
645 645 user: test
646 646 date: Thu Jan 01 00:00:00 1970 +0000
647 647 summary: merge bar
648 648
649 649 diff --git a/a b/aa
650 650 copy from a
651 651 copy to aa
652 652 diff --git a/cc b/cc
653 653 --- a/cc
654 654 +++ b/cc
655 655 @@ -1,1 +1,5 @@
656 656 +<<<<<<< local: 30d96aeaf27b - test: aa
657 657 dd
658 658 +=======
659 659 +cc
660 660 +>>>>>>> other: 1aa437659d19 bar - test: aazzcc
661 661 diff --git a/z b/zz
662 662 rename from z
663 663 rename to zz
664 664
665 665 $ hg debugrename aa
666 666 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
667 667 $ hg debugrename zz
668 668 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
669 669 $ hg debugrename cc
670 670 cc not renamed
671 671 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit
672 672 HGEDITFORM=commit.amend.merge
673 673 $ hg log --config diff.git=1 -pr .
674 674 changeset: 24:832b50f2c271
675 675 tag: tip
676 676 parent: 22:30d96aeaf27b
677 677 parent: 21:1aa437659d19
678 678 user: test
679 679 date: Thu Jan 01 00:00:00 1970 +0000
680 680 summary: merge bar (amend message)
681 681
682 682 diff --git a/a b/aa
683 683 copy from a
684 684 copy to aa
685 685 diff --git a/cc b/cc
686 686 --- a/cc
687 687 +++ b/cc
688 688 @@ -1,1 +1,5 @@
689 689 +<<<<<<< local: 30d96aeaf27b - test: aa
690 690 dd
691 691 +=======
692 692 +cc
693 693 +>>>>>>> other: 1aa437659d19 bar - test: aazzcc
694 694 diff --git a/z b/zz
695 695 rename from z
696 696 rename to zz
697 697
698 698 $ hg debugrename aa
699 699 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
700 700 $ hg debugrename zz
701 701 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
702 702 $ hg debugrename cc
703 703 cc not renamed
704 704 $ hg mv zz z
705 705 $ hg ci --amend -m 'merge bar (undo rename)'
706 706 $ hg log --config diff.git=1 -pr .
707 707 changeset: 26:bdafc5c72f74
708 708 tag: tip
709 709 parent: 22:30d96aeaf27b
710 710 parent: 21:1aa437659d19
711 711 user: test
712 712 date: Thu Jan 01 00:00:00 1970 +0000
713 713 summary: merge bar (undo rename)
714 714
715 715 diff --git a/a b/aa
716 716 copy from a
717 717 copy to aa
718 718 diff --git a/cc b/cc
719 719 --- a/cc
720 720 +++ b/cc
721 721 @@ -1,1 +1,5 @@
722 722 +<<<<<<< local: 30d96aeaf27b - test: aa
723 723 dd
724 724 +=======
725 725 +cc
726 726 +>>>>>>> other: 1aa437659d19 bar - test: aazzcc
727 727
728 728 $ hg debugrename z
729 729 z not renamed
730 730
731 731 Amend a merge changeset (with renames during the merge):
732 732
733 733 $ hg up -q bar
734 734 $ echo x > x
735 735 $ hg add x
736 736 $ hg ci -m x
737 737 $ hg up -q default
738 738 $ hg merge -q bar
739 739 $ hg mv aa aaa
740 740 $ echo aa >> aaa
741 741 $ hg ci -m 'merge bar again'
742 742 $ hg log --config diff.git=1 -pr .
743 743 changeset: 28:32f19415b634
744 744 tag: tip
745 745 parent: 26:bdafc5c72f74
746 746 parent: 27:4c94d5bc65f5
747 747 user: test
748 748 date: Thu Jan 01 00:00:00 1970 +0000
749 749 summary: merge bar again
750 750
751 751 diff --git a/aa b/aa
752 752 deleted file mode 100644
753 753 --- a/aa
754 754 +++ /dev/null
755 755 @@ -1,2 +0,0 @@
756 756 -a
757 757 -a
758 758 diff --git a/aaa b/aaa
759 759 new file mode 100644
760 760 --- /dev/null
761 761 +++ b/aaa
762 762 @@ -0,0 +1,3 @@
763 763 +a
764 764 +a
765 765 +aa
766 766 diff --git a/x b/x
767 767 new file mode 100644
768 768 --- /dev/null
769 769 +++ b/x
770 770 @@ -0,0 +1,1 @@
771 771 +x
772 772
773 773 $ hg debugrename aaa
774 774 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
775 775 $ hg mv aaa aa
776 776 $ hg ci --amend -m 'merge bar again (undo rename)'
777 777 $ hg log --config diff.git=1 -pr .
778 778 changeset: 30:1e2a06b3d312
779 779 tag: tip
780 780 parent: 26:bdafc5c72f74
781 781 parent: 27:4c94d5bc65f5
782 782 user: test
783 783 date: Thu Jan 01 00:00:00 1970 +0000
784 784 summary: merge bar again (undo rename)
785 785
786 786 diff --git a/aa b/aa
787 787 --- a/aa
788 788 +++ b/aa
789 789 @@ -1,2 +1,3 @@
790 790 a
791 791 a
792 792 +aa
793 793 diff --git a/x b/x
794 794 new file mode 100644
795 795 --- /dev/null
796 796 +++ b/x
797 797 @@ -0,0 +1,1 @@
798 798 +x
799 799
800 800 $ hg debugrename aa
801 801 aa not renamed
802 802 $ hg debugrename -r '.^' aa
803 803 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
804 804
805 805 Amend a merge changeset (with manifest-level conflicts):
806 806
807 807 $ hg up -q bar
808 808 $ hg rm aa
809 809 $ hg ci -m 'rm aa'
810 810 $ hg up -q default
811 811 $ echo aa >> aa
812 812 $ hg ci -m aa
813 $ hg merge -q bar
813 $ hg merge -q bar --config ui.interactive=True << EOF
814 > c
815 > EOF
814 816 local changed aa which remote deleted
815 817 use (c)hanged version, (d)elete, or leave (u)nresolved? c
816 818 $ hg ci -m 'merge bar (with conflicts)'
817 819 $ hg log --config diff.git=1 -pr .
818 820 changeset: 33:97a298b0c59f
819 821 tag: tip
820 822 parent: 32:3d78ce4226b8
821 823 parent: 31:67db8847a540
822 824 user: test
823 825 date: Thu Jan 01 00:00:00 1970 +0000
824 826 summary: merge bar (with conflicts)
825 827
826 828
827 829 $ hg rm aa
828 830 $ hg ci --amend -m 'merge bar (with conflicts, amended)'
829 831 $ hg log --config diff.git=1 -pr .
830 832 changeset: 35:6de0c1bde1c8
831 833 tag: tip
832 834 parent: 32:3d78ce4226b8
833 835 parent: 31:67db8847a540
834 836 user: test
835 837 date: Thu Jan 01 00:00:00 1970 +0000
836 838 summary: merge bar (with conflicts, amended)
837 839
838 840 diff --git a/aa b/aa
839 841 deleted file mode 100644
840 842 --- a/aa
841 843 +++ /dev/null
842 844 @@ -1,4 +0,0 @@
843 845 -a
844 846 -a
845 847 -aa
846 848 -aa
847 849
848 850 Issue 3445: amending with --close-branch a commit that created a new head should fail
849 851 This shouldn't be possible:
850 852
851 853 $ hg up -q default
852 854 $ hg branch closewithamend
853 855 marked working directory as branch closewithamend
854 856 $ echo foo > foo
855 857 $ hg add foo
856 858 $ hg ci -m..
857 859 $ hg ci --amend --close-branch -m 'closing'
858 860 abort: can only close branch heads
859 861 [255]
860 862
861 863 This silliness fails:
862 864
863 865 $ hg branch silliness
864 866 marked working directory as branch silliness
865 867 $ echo b >> b
866 868 $ hg ci --close-branch -m'open and close'
867 869 abort: can only close branch heads
868 870 [255]
869 871
870 872 Test that amend with --secret creates new secret changeset forcibly
871 873 ---------------------------------------------------------------------
872 874
873 875 $ hg phase '.^::.'
874 876 35: draft
875 877 36: draft
876 878 $ hg commit --amend --secret -m 'amend as secret' -q
877 879 $ hg phase '.^::.'
878 880 35: draft
879 881 38: secret
880 882
881 883 Test that amend with --edit invokes editor forcibly
882 884 ---------------------------------------------------
883 885
884 886 $ hg parents --template "{desc}\n"
885 887 amend as secret
886 888 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
887 889 $ hg parents --template "{desc}\n"
888 890 editor should be suppressed
889 891
890 892 $ hg status --rev '.^1::.'
891 893 A foo
892 894 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
893 895 editor should be invoked
894 896
895 897
896 898 HG: Enter commit message. Lines beginning with 'HG:' are removed.
897 899 HG: Leave message empty to abort commit.
898 900 HG: --
899 901 HG: user: test
900 902 HG: branch 'silliness'
901 903 HG: added foo
902 904 $ hg parents --template "{desc}\n"
903 905 editor should be invoked
904 906
905 907 Test that "diff()" in committemplate works correctly for amending
906 908 -----------------------------------------------------------------
907 909
908 910 $ cat >> .hg/hgrc <<EOF
909 911 > [committemplate]
910 912 > changeset.commit.amend = {desc}\n
911 913 > HG: M: {file_mods}
912 914 > HG: A: {file_adds}
913 915 > HG: R: {file_dels}
914 916 > {splitlines(diff()) % 'HG: {line}\n'}
915 917 > EOF
916 918
917 919 $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n"
918 920 M:
919 921 A: foo
920 922 R:
921 923 $ hg status -amr
922 924 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo"
923 925 expecting diff of foo
924 926
925 927 HG: M:
926 928 HG: A: foo
927 929 HG: R:
928 930 HG: diff -r 6de0c1bde1c8 foo
929 931 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
930 932 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
931 933 HG: @@ -0,0 +1,1 @@
932 934 HG: +foo
933 935
934 936 $ echo y > y
935 937 $ hg add y
936 938 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y"
937 939 expecting diff of foo and y
938 940
939 941 HG: M:
940 942 HG: A: foo y
941 943 HG: R:
942 944 HG: diff -r 6de0c1bde1c8 foo
943 945 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
944 946 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
945 947 HG: @@ -0,0 +1,1 @@
946 948 HG: +foo
947 949 HG: diff -r 6de0c1bde1c8 y
948 950 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
949 951 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
950 952 HG: @@ -0,0 +1,1 @@
951 953 HG: +y
952 954
953 955 $ hg rm a
954 956 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y"
955 957 expecting diff of a, foo and y
956 958
957 959 HG: M:
958 960 HG: A: foo y
959 961 HG: R: a
960 962 HG: diff -r 6de0c1bde1c8 a
961 963 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
962 964 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
963 965 HG: @@ -1,2 +0,0 @@
964 966 HG: -a
965 967 HG: -a
966 968 HG: diff -r 6de0c1bde1c8 foo
967 969 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
968 970 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
969 971 HG: @@ -0,0 +1,1 @@
970 972 HG: +foo
971 973 HG: diff -r 6de0c1bde1c8 y
972 974 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
973 975 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
974 976 HG: @@ -0,0 +1,1 @@
975 977 HG: +y
976 978
977 979 $ hg rm x
978 980 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y"
979 981 expecting diff of a, foo, x and y
980 982
981 983 HG: M:
982 984 HG: A: foo y
983 985 HG: R: a x
984 986 HG: diff -r 6de0c1bde1c8 a
985 987 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
986 988 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
987 989 HG: @@ -1,2 +0,0 @@
988 990 HG: -a
989 991 HG: -a
990 992 HG: diff -r 6de0c1bde1c8 foo
991 993 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
992 994 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
993 995 HG: @@ -0,0 +1,1 @@
994 996 HG: +foo
995 997 HG: diff -r 6de0c1bde1c8 x
996 998 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
997 999 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
998 1000 HG: @@ -1,1 +0,0 @@
999 1001 HG: -x
1000 1002 HG: diff -r 6de0c1bde1c8 y
1001 1003 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1002 1004 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1003 1005 HG: @@ -0,0 +1,1 @@
1004 1006 HG: +y
1005 1007
1006 1008 $ echo cccc >> cc
1007 1009 $ hg status -amr
1008 1010 M cc
1009 1011 $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc
1010 1012 cc should be excluded
1011 1013
1012 1014 HG: M:
1013 1015 HG: A: foo y
1014 1016 HG: R: a x
1015 1017 HG: diff -r 6de0c1bde1c8 a
1016 1018 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
1017 1019 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1018 1020 HG: @@ -1,2 +0,0 @@
1019 1021 HG: -a
1020 1022 HG: -a
1021 1023 HG: diff -r 6de0c1bde1c8 foo
1022 1024 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1023 1025 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1024 1026 HG: @@ -0,0 +1,1 @@
1025 1027 HG: +foo
1026 1028 HG: diff -r 6de0c1bde1c8 x
1027 1029 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1028 1030 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1029 1031 HG: @@ -1,1 +0,0 @@
1030 1032 HG: -x
1031 1033 HG: diff -r 6de0c1bde1c8 y
1032 1034 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1033 1035 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1034 1036 HG: @@ -0,0 +1,1 @@
1035 1037 HG: +y
1036 1038
1037 1039 Check for issue4405
1038 1040 -------------------
1039 1041
1040 1042 Setup the repo with a file that gets moved in a second commit.
1041 1043 $ hg init repo
1042 1044 $ cd repo
1043 1045 $ touch a0
1044 1046 $ hg add a0
1045 1047 $ hg commit -m a0
1046 1048 $ hg mv a0 a1
1047 1049 $ hg commit -m a1
1048 1050 $ hg up -q 0
1049 1051 $ hg log -G --template '{rev} {desc}'
1050 1052 o 1 a1
1051 1053 |
1052 1054 @ 0 a0
1053 1055
1054 1056
1055 1057 Now we branch the repro, but re-use the file contents, so we have a divergence
1056 1058 in the file revlog topology and the changelog topology.
1057 1059 $ hg revert --rev 1 --all
1058 1060 removing a0
1059 1061 adding a1
1060 1062 $ hg ci -qm 'a1-amend'
1061 1063 $ hg log -G --template '{rev} {desc}'
1062 1064 @ 2 a1-amend
1063 1065 |
1064 1066 | o 1 a1
1065 1067 |/
1066 1068 o 0 a0
1067 1069
1068 1070
1069 1071 The way mercurial does amends is to create a temporary commit (rev 3) and then
1070 1072 fold the new and old commits together into another commit (rev 4). During this
1071 1073 process, _findlimit is called to check how far back to look for the transitive
1072 1074 closure of file copy information, but due to the divergence of the filelog
1073 1075 and changelog graph topologies, before _findlimit was fixed, it returned a rev
1074 1076 which was not far enough back in this case.
1075 1077 $ hg mv a1 a2
1076 1078 $ hg status --copies --rev 0
1077 1079 A a2
1078 1080 a0
1079 1081 R a0
1080 1082 $ hg ci --amend -q
1081 1083 $ hg log -G --template '{rev} {desc}'
1082 1084 @ 4 a1-amend
1083 1085 |
1084 1086 | o 1 a1
1085 1087 |/
1086 1088 o 0 a0
1087 1089
1088 1090
1089 1091 Before the fix, the copy information was lost.
1090 1092 $ hg status --copies --rev 0
1091 1093 A a2
1092 1094 a0
1093 1095 R a0
1094 1096 $ cd ..
1095 1097
1096 1098 Check that amend properly preserve rename from directory rename (issue-4516)
1097 1099
1098 1100 If a parent of the merge renames a full directory, any files added to the old
1099 1101 directory in the other parent will be renamed to the new directory. For some
1100 1102 reason, the rename metadata was when amending such merge. This test ensure we
1101 1103 do not regress. We have a dedicated repo because it needs a setup with renamed
1102 1104 directory)
1103 1105
1104 1106 $ hg init issue4516
1105 1107 $ cd issue4516
1106 1108 $ mkdir olddirname
1107 1109 $ echo line1 > olddirname/commonfile.py
1108 1110 $ hg add olddirname/commonfile.py
1109 1111 $ hg ci -m first
1110 1112
1111 1113 $ hg branch newdirname
1112 1114 marked working directory as branch newdirname
1113 1115 (branches are permanent and global, did you want a bookmark?)
1114 1116 $ hg mv olddirname newdirname
1115 1117 moving olddirname/commonfile.py to newdirname/commonfile.py (glob)
1116 1118 $ hg ci -m rename
1117 1119
1118 1120 $ hg update default
1119 1121 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1120 1122 $ echo line1 > olddirname/newfile.py
1121 1123 $ hg add olddirname/newfile.py
1122 1124 $ hg ci -m log
1123 1125
1124 1126 $ hg up newdirname
1125 1127 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1126 1128 $ # create newdirname/newfile.py
1127 1129 $ hg merge default
1128 1130 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1129 1131 (branch merge, don't forget to commit)
1130 1132 $ hg ci -m add
1131 1133 $
1132 1134 $ hg debugrename newdirname/newfile.py
1133 1135 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def (glob)
1134 1136 $ hg status -C --change .
1135 1137 A newdirname/newfile.py
1136 1138 $ hg status -C --rev 1
1137 1139 A newdirname/newfile.py
1138 1140 $ hg status -C --rev 2
1139 1141 A newdirname/commonfile.py
1140 1142 olddirname/commonfile.py
1141 1143 A newdirname/newfile.py
1142 1144 olddirname/newfile.py
1143 1145 R olddirname/commonfile.py
1144 1146 R olddirname/newfile.py
1145 1147 $ hg debugindex newdirname/newfile.py
1146 1148 rev offset length delta linkrev nodeid p1 p2
1147 1149 0 0 88 -1 3 34a4d536c0c0 000000000000 000000000000
1148 1150
1149 1151 $ echo a >> newdirname/commonfile.py
1150 1152 $ hg ci --amend -m bug
1151 1153 $ hg debugrename newdirname/newfile.py
1152 1154 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def (glob)
1153 1155 $ hg debugindex newdirname/newfile.py
1154 1156 rev offset length delta linkrev nodeid p1 p2
1155 1157 0 0 88 -1 3 34a4d536c0c0 000000000000 000000000000
1156 1158
General Comments 0
You need to be logged in to leave comments. Login now