##// END OF EJS Templates
commit: add test showing that commit --amend --no-edit still shows editor...
Kyle Lippincott -
r42590:060ff339 default
parent child Browse files
Show More
@@ -1,1298 +1,1329 b''
1 1 $ hg init
2 2
3 3 Setup:
4 4
5 5 $ echo a >> a
6 6 $ hg ci -Am 'base'
7 7 adding a
8 8
9 9 Refuse to amend public csets:
10 10
11 11 $ hg phase -r . -p
12 12 $ hg ci --amend
13 13 abort: cannot amend public changesets
14 14 (see 'hg help phases' for details)
15 15 [255]
16 16 $ hg phase -r . -f -d
17 17
18 18 $ echo a >> a
19 19 $ hg ci -Am 'base1'
20 20
21 21 Nothing to amend:
22 22
23 23 $ hg ci --amend -m 'base1'
24 24 nothing changed
25 25 [1]
26 26
27 27 $ cat >> $HGRCPATH <<EOF
28 28 > [hooks]
29 29 > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
30 30 > EOF
31 31
32 32 Amending changeset with changes in working dir:
33 33 (and check that --message does not trigger an editor)
34 34
35 35 $ echo a >> a
36 36 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
37 37 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
38 38 43f1ba15f28a tip
39 39 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg
40 40 $ echo 'pretxncommit.foo = ' >> $HGRCPATH
41 41 $ hg diff -c .
42 42 diff -r ad120869acf0 -r 43f1ba15f28a a
43 43 --- a/a Thu Jan 01 00:00:00 1970 +0000
44 44 +++ b/a Thu Jan 01 00:00:00 1970 +0000
45 45 @@ -1,1 +1,3 @@
46 46 a
47 47 +a
48 48 +a
49 49 $ hg log
50 50 changeset: 1:43f1ba15f28a
51 51 tag: tip
52 52 user: test
53 53 date: Thu Jan 01 00:00:00 1970 +0000
54 54 summary: amend base1
55 55
56 56 changeset: 0:ad120869acf0
57 57 user: test
58 58 date: Thu Jan 01 00:00:00 1970 +0000
59 59 summary: base
60 60
61 61
62 62 Check proper abort for empty message
63 63
64 64 $ cat > editor.sh << '__EOF__'
65 65 > #!/bin/sh
66 66 > echo "" > "$1"
67 67 > __EOF__
68 68
69 69 Update the existing file to ensure that the dirstate is not in pending state
70 70 (where the status of some files in the working copy is not known yet). This in
71 71 turn ensures that when the transaction is aborted due to an empty message during
72 72 the amend, there should be no rollback.
73 73 $ echo a >> a
74 74
75 75 $ echo b > b
76 76 $ hg add b
77 77 $ hg summary
78 78 parent: 1:43f1ba15f28a tip
79 79 amend base1
80 80 branch: default
81 81 commit: 1 modified, 1 added, 1 unknown
82 82 update: (current)
83 83 phases: 2 draft
84 84 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
85 85 abort: empty commit message
86 86 [255]
87 87 $ hg summary
88 88 parent: 1:43f1ba15f28a tip
89 89 amend base1
90 90 branch: default
91 91 commit: 1 modified, 1 added, 1 unknown
92 92 update: (current)
93 93 phases: 2 draft
94 94
95 95 Add new file along with modified existing file:
96 96 $ hg ci --amend -m 'amend base1 new file'
97 97 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg
98 98
99 99 Remove file that was added in amended commit:
100 100 (and test logfile option)
101 101 (and test that logfile option do not trigger an editor)
102 102
103 103 $ hg rm b
104 104 $ echo 'amend base1 remove new file' > ../logfile
105 105 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
106 106 saved backup bundle to $TESTTMP/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg
107 107
108 108 $ hg cat b
109 109 b: no such file in rev 47343646fa3d
110 110 [1]
111 111
112 112 No changes, just a different message:
113 113
114 114 $ hg ci -v --amend -m 'no changes, new message'
115 115 amending changeset 47343646fa3d
116 116 copying changeset 47343646fa3d to ad120869acf0
117 117 committing files:
118 118 a
119 119 committing manifest
120 120 committing changelog
121 121 1 changesets found
122 122 uncompressed size of bundle content:
123 123 254 (changelog)
124 124 163 (manifests)
125 125 131 a
126 126 saved backup bundle to $TESTTMP/.hg/strip-backup/47343646fa3d-c2758885-amend.hg
127 127 1 changesets found
128 128 uncompressed size of bundle content:
129 129 250 (changelog)
130 130 163 (manifests)
131 131 131 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:401431e913a1
138 138 $ hg diff -c .
139 139 diff -r ad120869acf0 -r 401431e913a1 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,4 @@
143 143 a
144 144 +a
145 145 +a
146 146 +a
147 147 $ hg log
148 148 changeset: 1:401431e913a1
149 149 tag: tip
150 150 user: test
151 151 date: Thu Jan 01 00:00:00 1970 +0000
152 152 summary: no changes, new message
153 153
154 154 changeset: 0:ad120869acf0
155 155 user: test
156 156 date: Thu Jan 01 00:00:00 1970 +0000
157 157 summary: base
158 158
159 159
160 160 Disable default date on commit so when -d isn't given, the old date is preserved:
161 161
162 162 $ echo '[defaults]' >> $HGRCPATH
163 163 $ echo 'commit=' >> $HGRCPATH
164 164
165 165 Test -u/-d:
166 166
167 167 $ cat > .hg/checkeditform.sh <<EOF
168 168 > env | grep HGEDITFORM
169 169 > true
170 170 > EOF
171 171 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
172 172 HGEDITFORM=commit.amend.normal
173 173 saved backup bundle to $TESTTMP/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg
174 174 $ echo a >> a
175 175 $ hg ci --amend -u foo -d '1 0'
176 176 saved backup bundle to $TESTTMP/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg
177 177 $ hg log -r .
178 178 changeset: 1:a9a13940fc03
179 179 tag: tip
180 180 user: foo
181 181 date: Thu Jan 01 00:00:01 1970 +0000
182 182 summary: no changes, new message
183 183
184 184
185 185 Open editor with old commit message if a message isn't given otherwise:
186 186
187 187 $ cat > editor.sh << '__EOF__'
188 188 > #!/bin/sh
189 189 > cat $1
190 190 > echo "another precious commit message" > "$1"
191 191 > __EOF__
192 192
193 193 at first, test saving last-message.txt
194 194
195 195 $ cat > .hg/hgrc << '__EOF__'
196 196 > [hooks]
197 197 > pretxncommit.test-saving-last-message = false
198 198 > __EOF__
199 199
200 200 $ rm -f .hg/last-message.txt
201 201 $ hg commit --amend -v -m "message given from command line"
202 202 amending changeset a9a13940fc03
203 203 copying changeset a9a13940fc03 to ad120869acf0
204 204 committing files:
205 205 a
206 206 committing manifest
207 207 committing changelog
208 208 running hook pretxncommit.test-saving-last-message: false
209 209 transaction abort!
210 210 rollback completed
211 211 abort: pretxncommit.test-saving-last-message hook exited with status 1
212 212 [255]
213 213 $ cat .hg/last-message.txt
214 214 message given from command line (no-eol)
215 215
216 216 $ rm -f .hg/last-message.txt
217 217 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
218 218 amending changeset a9a13940fc03
219 219 copying changeset a9a13940fc03 to ad120869acf0
220 220 no changes, new message
221 221
222 222
223 223 HG: Enter commit message. Lines beginning with 'HG:' are removed.
224 224 HG: Leave message empty to abort commit.
225 225 HG: --
226 226 HG: user: foo
227 227 HG: branch 'default'
228 228 HG: changed a
229 229 committing files:
230 230 a
231 231 committing manifest
232 232 committing changelog
233 233 running hook pretxncommit.test-saving-last-message: false
234 234 transaction abort!
235 235 rollback completed
236 236 abort: pretxncommit.test-saving-last-message hook exited with status 1
237 237 [255]
238 238
239 239 $ cat .hg/last-message.txt
240 240 another precious commit message
241 241
242 242 $ cat > .hg/hgrc << '__EOF__'
243 243 > [hooks]
244 244 > pretxncommit.test-saving-last-message =
245 245 > __EOF__
246 246
247 247 then, test editing custom commit message
248 248
249 249 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
250 250 amending changeset a9a13940fc03
251 251 copying changeset a9a13940fc03 to ad120869acf0
252 252 no changes, new message
253 253
254 254
255 255 HG: Enter commit message. Lines beginning with 'HG:' are removed.
256 256 HG: Leave message empty to abort commit.
257 257 HG: --
258 258 HG: user: foo
259 259 HG: branch 'default'
260 260 HG: changed a
261 261 committing files:
262 262 a
263 263 committing manifest
264 264 committing changelog
265 265 1 changesets found
266 266 uncompressed size of bundle content:
267 267 249 (changelog)
268 268 163 (manifests)
269 269 133 a
270 270 saved backup bundle to $TESTTMP/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg
271 271 1 changesets found
272 272 uncompressed size of bundle content:
273 273 257 (changelog)
274 274 163 (manifests)
275 275 133 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:64a124ba1b44
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 64a124ba1b44
288 288 another precious commit message
289 289
290 290
291 291 HG: Enter commit message. Lines beginning with 'HG:' are removed.
292 292 HG: Leave message empty to abort commit.
293 293 HG: --
294 294 HG: user: foo
295 295 HG: branch 'default'
296 296 HG: changed a
297 297 committing files:
298 298 a
299 299 committing manifest
300 300 committing changelog
301 301 1 changesets found
302 302 uncompressed size of bundle content:
303 303 257 (changelog)
304 304 163 (manifests)
305 305 133 a
306 306 saved backup bundle to $TESTTMP/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg
307 307 1 changesets found
308 308 uncompressed size of bundle content:
309 309 257 (changelog)
310 310 163 (manifests)
311 311 135 a
312 312 adding branch
313 313 adding changesets
314 314 adding manifests
315 315 adding file changes
316 316 added 1 changesets with 1 changes to 1 files
317 317 committed changeset 1:7892795b8e38
318 318
319 319 $ rm editor.sh
320 320 $ hg log -r .
321 321 changeset: 1:7892795b8e38
322 322 tag: tip
323 323 user: foo
324 324 date: Thu Jan 01 00:00:01 1970 +0000
325 325 summary: another precious commit message
326 326
327 327
328 328 Moving bookmarks, preserve active bookmark:
329 329
330 330 $ hg book book1
331 331 $ hg book book2
332 332 $ hg ci --amend -m 'move bookmarks'
333 333 saved backup bundle to $TESTTMP/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg
334 334 $ hg book
335 335 book1 1:8311f17e2616
336 336 * book2 1:8311f17e2616
337 337 $ echo a >> a
338 338 $ hg ci --amend -m 'move bookmarks'
339 339 saved backup bundle to $TESTTMP/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg
340 340 $ hg book
341 341 book1 1:a3b65065808c
342 342 * book2 1:a3b65065808c
343 343
344 344 abort does not loose bookmarks
345 345
346 346 $ cat > editor.sh << '__EOF__'
347 347 > #!/bin/sh
348 348 > echo "" > "$1"
349 349 > __EOF__
350 350 $ echo a >> a
351 351 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
352 352 abort: empty commit message
353 353 [255]
354 354 $ hg book
355 355 book1 1:a3b65065808c
356 356 * book2 1:a3b65065808c
357 357 $ hg revert -Caq
358 358 $ rm editor.sh
359 359
360 360 $ echo '[defaults]' >> $HGRCPATH
361 361 $ echo "commit=-d '0 0'" >> $HGRCPATH
362 362
363 363 Moving branches:
364 364
365 365 $ hg branch foo
366 366 marked working directory as branch foo
367 367 (branches are permanent and global, did you want a bookmark?)
368 368 $ echo a >> a
369 369 $ hg ci -m 'branch foo'
370 370 $ hg branch default -f
371 371 marked working directory as branch default
372 372 $ hg ci --amend -m 'back to default'
373 373 saved backup bundle to $TESTTMP/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg
374 374 $ hg branches
375 375 default 2:9c07515f2650
376 376
377 377 Close branch:
378 378
379 379 $ hg up -q 0
380 380 $ echo b >> b
381 381 $ hg branch foo
382 382 marked working directory as branch foo
383 383 (branches are permanent and global, did you want a bookmark?)
384 384 $ hg ci -Am 'fork'
385 385 adding b
386 386 $ echo b >> b
387 387 $ hg ci -mb
388 388 $ hg ci --amend --close-branch -m 'closing branch foo'
389 389 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-54245dc7-amend.hg
390 390
391 391 Same thing, different code path:
392 392
393 393 $ echo b >> b
394 394 $ hg ci -m 'reopen branch'
395 395 reopening closed branch head 4
396 396 $ echo b >> b
397 397 $ hg ci --amend --close-branch
398 398 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-b900d9fa-amend.hg
399 399 $ hg branches
400 400 default 2:9c07515f2650
401 401
402 402 Refuse to amend during a merge:
403 403
404 404 $ hg up -q default
405 405 $ hg merge foo
406 406 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
407 407 (branch merge, don't forget to commit)
408 408 $ hg ci --amend
409 409 abort: cannot amend while merging
410 410 [255]
411 411 $ hg ci -m 'merge'
412 412
413 413 Refuse to amend if there is a merge conflict (issue5805):
414 414
415 415 $ hg up -q foo
416 416 $ echo c > a
417 417 $ hg up default -t :fail
418 418 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
419 419 use 'hg resolve' to retry unresolved file merges
420 420 [1]
421 421 $ hg resolve -l
422 422 U a
423 423
424 424 $ hg ci --amend
425 425 abort: unresolved merge conflicts (see 'hg help resolve')
426 426 [255]
427 427
428 428 $ hg up -qC .
429 429
430 430 Follow copies/renames:
431 431
432 432 $ hg mv b c
433 433 $ hg ci -m 'b -> c'
434 434 $ hg mv c d
435 435 $ hg ci --amend -m 'b -> d'
436 436 saved backup bundle to $TESTTMP/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg
437 437 $ hg st --rev '.^' --copies d
438 438 A d
439 439 b
440 440 $ hg cp d e
441 441 $ hg ci -m 'e = d'
442 442 $ hg cp e f
443 443 $ hg ci --amend -m 'f = d'
444 444 saved backup bundle to $TESTTMP/.hg/strip-backup/9198f73182d5-251d584a-amend.hg
445 445 $ hg st --rev '.^' --copies f
446 446 A f
447 447 d
448 448
449 449 $ mv f f.orig
450 450 $ hg rm -A f
451 451 $ hg ci -m removef
452 452 $ hg cp a f
453 453 $ mv f.orig f
454 454 $ hg ci --amend -m replacef
455 455 saved backup bundle to $TESTTMP/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg
456 456 $ hg st --change . --copies
457 457 $ hg log -r . --template "{file_copies}\n"
458 458
459 459
460 460 Move added file (issue3410):
461 461
462 462 $ echo g >> g
463 463 $ hg ci -Am g
464 464 adding g
465 465 $ hg mv g h
466 466 $ hg ci --amend
467 467 saved backup bundle to $TESTTMP/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg
468 468 $ hg st --change . --copies h
469 469 A h
470 470 $ hg log -r . --template "{file_copies}\n"
471 471
472 472
473 473 Can't rollback an amend:
474 474
475 475 $ hg rollback
476 476 no rollback information available
477 477 [1]
478 478
479 479 Preserve extra dict (issue3430):
480 480
481 481 $ hg branch a
482 482 marked working directory as branch a
483 483 (branches are permanent and global, did you want a bookmark?)
484 484 $ echo a >> a
485 485 $ hg ci -ma
486 486 $ hg ci --amend -m "a'"
487 487 saved backup bundle to $TESTTMP/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg
488 488 $ hg log -r . --template "{branch}\n"
489 489 a
490 490 $ hg ci --amend -m "a''"
491 491 saved backup bundle to $TESTTMP/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg
492 492 $ hg log -r . --template "{branch}\n"
493 493 a
494 494
495 495 Also preserve other entries in the dict that are in the old commit,
496 496 first graft something so there's an additional entry:
497 497
498 498 $ hg up 0 -q
499 499 $ echo z > z
500 500 $ hg ci -Am 'fork'
501 501 adding z
502 502 created new head
503 503 $ hg up 11
504 504 5 files updated, 0 files merged, 1 files removed, 0 files unresolved
505 505 $ hg graft 12
506 506 grafting 12:2647734878ef "fork" (tip)
507 507 $ hg ci --amend -m 'graft amend'
508 508 saved backup bundle to $TESTTMP/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg
509 509 $ hg log -r . --debug | grep extra
510 510 extra: amend_source=fe8c6f7957ca1665ed77496ed7a07657d469ac60
511 511 extra: branch=a
512 512 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
513 513
514 514 Preserve phase
515 515
516 516 $ hg phase '.^::.'
517 517 11: draft
518 518 13: draft
519 519 $ hg phase --secret --force .
520 520 $ hg phase '.^::.'
521 521 11: draft
522 522 13: secret
523 523 $ hg commit --amend -m 'amend for phase' -q
524 524 $ hg phase '.^::.'
525 525 11: draft
526 526 13: secret
527 527
528 528 Test amend with obsolete
529 529 ---------------------------
530 530
531 531 Enable obsolete
532 532
533 533 $ cat >> $HGRCPATH << EOF
534 534 > [experimental]
535 535 > evolution.createmarkers=True
536 536 > evolution.allowunstable=True
537 537 > EOF
538 538
539 539 Amend with no files changes
540 540
541 541 $ hg id -n
542 542 13
543 543 $ hg ci --amend -m 'babar'
544 544 $ hg id -n
545 545 14
546 546 $ hg log -Gl 3 --style=compact
547 547 @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test
548 548 | babar
549 549 |
550 550 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
551 551 | | fork
552 552 | ~
553 553 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test
554 554 | a''
555 555 ~
556 556 $ hg log -Gl 4 --hidden --style=compact
557 557 @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test
558 558 | babar
559 559 |
560 560 | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test
561 561 |/ amend for phase
562 562 |
563 563 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
564 564 | | fork
565 565 | ~
566 566 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test
567 567 | a''
568 568 ~
569 569
570 570 Amend with files changes
571 571
572 572 (note: the extra commit over 15 is a temporary junk I would be happy to get
573 573 ride of)
574 574
575 575 $ echo 'babar' >> a
576 576 $ hg commit --amend
577 577 $ hg log -Gl 6 --hidden --style=compact
578 578 @ 15[tip]:11 a5b42b49b0d5 1970-01-01 00:00 +0000 test
579 579 | babar
580 580 |
581 581 | x 14:11 682950e85999 1970-01-01 00:00 +0000 test
582 582 |/ babar
583 583 |
584 584 | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test
585 585 |/ amend for phase
586 586 |
587 587 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
588 588 | | fork
589 589 | ~
590 590 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test
591 591 | a''
592 592 |
593 593 o 10 5fa75032e226 1970-01-01 00:00 +0000 test
594 594 | g
595 595 ~
596 596
597 597
598 598 Test that amend does not make it easy to create obsolescence cycle
599 599 ---------------------------------------------------------------------
600 600
601 601 $ hg id -r 14 --hidden
602 602 682950e85999 (a)
603 603 $ hg revert -ar 14 --hidden
604 604 reverting a
605 605 $ hg commit --amend
606 606 $ hg id
607 607 37973c7e0b61 (a) tip
608 608
609 609 Test that rewriting leaving instability behind is allowed
610 610 ---------------------------------------------------------------------
611 611
612 612 $ hg up '.^'
613 613 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
614 614 $ echo 'b' >> a
615 615 $ hg log --style compact -r 'children(.)'
616 616 16[tip]:11 37973c7e0b61 1970-01-01 00:00 +0000 test
617 617 babar
618 618
619 619 $ hg commit --amend
620 620 1 new orphan changesets
621 621 $ hg log -r 'orphan()'
622 622 changeset: 16:37973c7e0b61
623 623 branch: a
624 624 parent: 11:0ddb275cfad1
625 625 user: test
626 626 date: Thu Jan 01 00:00:00 1970 +0000
627 627 instability: orphan
628 628 summary: babar
629 629
630 630
631 631 Amend a merge changeset (with renames and conflicts from the second parent):
632 632
633 633 $ hg up -q default
634 634 $ hg branch -q bar
635 635 $ hg cp a aa
636 636 $ hg mv z zz
637 637 $ echo cc > cc
638 638 $ hg add cc
639 639 $ hg ci -m aazzcc
640 640 $ hg up -q default
641 641 $ echo a >> a
642 642 $ echo dd > cc
643 643 $ hg add cc
644 644 $ hg ci -m aa
645 645 $ hg merge -q bar
646 646 warning: conflicts while merging cc! (edit, then use 'hg resolve --mark')
647 647 [1]
648 648 $ hg resolve -m cc
649 649 (no more unresolved files)
650 650 $ hg ci -m 'merge bar'
651 651 $ hg log --config diff.git=1 -pr .
652 652 changeset: 20:163cfd7219f7
653 653 tag: tip
654 654 parent: 19:30d96aeaf27b
655 655 parent: 18:1aa437659d19
656 656 user: test
657 657 date: Thu Jan 01 00:00:00 1970 +0000
658 658 summary: merge bar
659 659
660 660 diff --git a/a b/aa
661 661 copy from a
662 662 copy to aa
663 663 diff --git a/cc b/cc
664 664 --- a/cc
665 665 +++ b/cc
666 666 @@ -1,1 +1,5 @@
667 667 +<<<<<<< working copy: 30d96aeaf27b - test: aa
668 668 dd
669 669 +=======
670 670 +cc
671 671 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
672 672 diff --git a/z b/zz
673 673 rename from z
674 674 rename to zz
675 675
676 676 $ hg debugrename aa
677 677 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
678 678 $ hg debugrename zz
679 679 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
680 680 $ hg debugrename cc
681 681 cc not renamed
682 682 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit
683 683 HGEDITFORM=commit.amend.merge
684 684 $ hg log --config diff.git=1 -pr .
685 685 changeset: 21:bca52d4ed186
686 686 tag: tip
687 687 parent: 19:30d96aeaf27b
688 688 parent: 18:1aa437659d19
689 689 user: test
690 690 date: Thu Jan 01 00:00:00 1970 +0000
691 691 summary: merge bar (amend message)
692 692
693 693 diff --git a/a b/aa
694 694 copy from a
695 695 copy to aa
696 696 diff --git a/cc b/cc
697 697 --- a/cc
698 698 +++ b/cc
699 699 @@ -1,1 +1,5 @@
700 700 +<<<<<<< working copy: 30d96aeaf27b - test: aa
701 701 dd
702 702 +=======
703 703 +cc
704 704 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
705 705 diff --git a/z b/zz
706 706 rename from z
707 707 rename to zz
708 708
709 709 $ hg debugrename aa
710 710 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
711 711 $ hg debugrename zz
712 712 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
713 713 $ hg debugrename cc
714 714 cc not renamed
715 715 $ hg mv zz z
716 716 $ hg ci --amend -m 'merge bar (undo rename)'
717 717 $ hg log --config diff.git=1 -pr .
718 718 changeset: 22:12594a98ca3f
719 719 tag: tip
720 720 parent: 19:30d96aeaf27b
721 721 parent: 18:1aa437659d19
722 722 user: test
723 723 date: Thu Jan 01 00:00:00 1970 +0000
724 724 summary: merge bar (undo rename)
725 725
726 726 diff --git a/a b/aa
727 727 copy from a
728 728 copy to aa
729 729 diff --git a/cc b/cc
730 730 --- a/cc
731 731 +++ b/cc
732 732 @@ -1,1 +1,5 @@
733 733 +<<<<<<< working copy: 30d96aeaf27b - test: aa
734 734 dd
735 735 +=======
736 736 +cc
737 737 +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc
738 738
739 739 $ hg debugrename z
740 740 z not renamed
741 741
742 742 Amend a merge changeset (with renames during the merge):
743 743
744 744 $ hg up -q bar
745 745 $ echo x > x
746 746 $ hg add x
747 747 $ hg ci -m x
748 748 $ hg up -q default
749 749 $ hg merge -q bar
750 750 $ hg mv aa aaa
751 751 $ echo aa >> aaa
752 752 $ hg ci -m 'merge bar again'
753 753 $ hg log --config diff.git=1 -pr .
754 754 changeset: 24:dffde028b388
755 755 tag: tip
756 756 parent: 22:12594a98ca3f
757 757 parent: 23:4c94d5bc65f5
758 758 user: test
759 759 date: Thu Jan 01 00:00:00 1970 +0000
760 760 summary: merge bar again
761 761
762 762 diff --git a/aa b/aa
763 763 deleted file mode 100644
764 764 --- a/aa
765 765 +++ /dev/null
766 766 @@ -1,2 +0,0 @@
767 767 -a
768 768 -a
769 769 diff --git a/aaa b/aaa
770 770 new file mode 100644
771 771 --- /dev/null
772 772 +++ b/aaa
773 773 @@ -0,0 +1,3 @@
774 774 +a
775 775 +a
776 776 +aa
777 777 diff --git a/x b/x
778 778 new file mode 100644
779 779 --- /dev/null
780 780 +++ b/x
781 781 @@ -0,0 +1,1 @@
782 782 +x
783 783
784 784 $ hg debugrename aaa
785 785 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
786 786
787 787 Update to p1 with 'aaa' modified. 'aaa' was renamed from 'aa' in p2. 'aa' exists
788 788 in p1 too, but it was recorded as copied from p2.
789 789 $ echo modified >> aaa
790 790 $ hg co -m '.^' -t :merge3
791 791 file 'aaa' was deleted in other [destination] but was modified in local [working copy].
792 792 What do you want to do?
793 793 use (c)hanged version, (d)elete, or leave (u)nresolved? u
794 794 1 files updated, 0 files merged, 1 files removed, 1 files unresolved
795 795 use 'hg resolve' to retry unresolved file merges
796 796 [1]
797 797 $ hg co -C tip
798 798 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
799 799
800 800 $ hg mv aaa aa
801 801 $ hg ci --amend -m 'merge bar again (undo rename)'
802 802 $ hg log --config diff.git=1 -pr .
803 803 changeset: 25:18e3ba160489
804 804 tag: tip
805 805 parent: 22:12594a98ca3f
806 806 parent: 23:4c94d5bc65f5
807 807 user: test
808 808 date: Thu Jan 01 00:00:00 1970 +0000
809 809 summary: merge bar again (undo rename)
810 810
811 811 diff --git a/aa b/aa
812 812 --- a/aa
813 813 +++ b/aa
814 814 @@ -1,2 +1,3 @@
815 815 a
816 816 a
817 817 +aa
818 818 diff --git a/x b/x
819 819 new file mode 100644
820 820 --- /dev/null
821 821 +++ b/x
822 822 @@ -0,0 +1,1 @@
823 823 +x
824 824
825 825 $ hg debugrename aa
826 826 aa not renamed
827 827 $ hg debugrename -r '.^' aa
828 828 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
829 829
830 830 Amend a merge changeset (with manifest-level conflicts):
831 831
832 832 $ hg up -q bar
833 833 $ hg rm aa
834 834 $ hg ci -m 'rm aa'
835 835 $ hg up -q default
836 836 $ echo aa >> aa
837 837 $ hg ci -m aa
838 838 $ hg merge -q bar --config ui.interactive=True << EOF
839 839 > c
840 840 > EOF
841 841 file 'aa' was deleted in other [merge rev] but was modified in local [working copy].
842 842 What do you want to do?
843 843 use (c)hanged version, (d)elete, or leave (u)nresolved? c
844 844 $ hg ci -m 'merge bar (with conflicts)'
845 845 $ hg log --config diff.git=1 -pr .
846 846 changeset: 28:b4c3035e2544
847 847 tag: tip
848 848 parent: 27:4b216ca5ba97
849 849 parent: 26:67db8847a540
850 850 user: test
851 851 date: Thu Jan 01 00:00:00 1970 +0000
852 852 summary: merge bar (with conflicts)
853 853
854 854
855 855 $ hg rm aa
856 856 $ hg ci --amend -m 'merge bar (with conflicts, amended)'
857 857 $ hg log --config diff.git=1 -pr .
858 858 changeset: 29:1205ed810051
859 859 tag: tip
860 860 parent: 27:4b216ca5ba97
861 861 parent: 26:67db8847a540
862 862 user: test
863 863 date: Thu Jan 01 00:00:00 1970 +0000
864 864 summary: merge bar (with conflicts, amended)
865 865
866 866 diff --git a/aa b/aa
867 867 deleted file mode 100644
868 868 --- a/aa
869 869 +++ /dev/null
870 870 @@ -1,4 +0,0 @@
871 871 -a
872 872 -a
873 873 -aa
874 874 -aa
875 875
876 876 Issue 3445: amending with --close-branch a commit that created a new head should fail
877 877 This shouldn't be possible:
878 878
879 879 $ hg up -q default
880 880 $ hg branch closewithamend
881 881 marked working directory as branch closewithamend
882 882 $ echo foo > foo
883 883 $ hg add foo
884 884 $ hg ci -m..
885 885 $ hg ci --amend --close-branch -m 'closing'
886 886 abort: can only close branch heads
887 887 [255]
888 888
889 889 This silliness fails:
890 890
891 891 $ hg branch silliness
892 892 marked working directory as branch silliness
893 893 $ echo b >> b
894 894 $ hg ci --close-branch -m'open and close'
895 895 abort: can only close branch heads
896 896 [255]
897 897
898 898 Test that amend with --secret creates new secret changeset forcibly
899 899 ---------------------------------------------------------------------
900 900
901 901 $ hg phase '.^::.'
902 902 29: draft
903 903 30: draft
904 904 $ hg commit --amend --secret -m 'amend as secret' -q
905 905 $ hg phase '.^::.'
906 906 29: draft
907 907 31: secret
908 908
909 909 Test that amend with --edit invokes editor forcibly
910 910 ---------------------------------------------------
911 911
912 912 $ hg parents --template "{desc}\n"
913 913 amend as secret
914 914 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
915 915 $ hg parents --template "{desc}\n"
916 916 editor should be suppressed
917 917
918 918 $ hg status --rev '.^1::.'
919 919 A foo
920 920 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
921 921 editor should be invoked
922 922
923 923
924 924 HG: Enter commit message. Lines beginning with 'HG:' are removed.
925 925 HG: Leave message empty to abort commit.
926 926 HG: --
927 927 HG: user: test
928 928 HG: branch 'silliness'
929 929 HG: added foo
930 930 $ hg parents --template "{desc}\n"
931 931 editor should be invoked
932 932
933 Test that amend with --no-edit avoids the editor
934 ------------------------------------------------
935
936 $ hg commit --amend -m "before anything happens"
937 $ hg parents --template "{desc}\n"
938 before anything happens
939 $ HGEDITOR=cat hg commit --amend --no-edit -m "editor should be suppressed"
940 $ hg parents --template "{desc}\n"
941 editor should be suppressed
942
943 (We need a file change here since we won't have a message change)
944 $ cp foo foo.orig
945 $ echo hi >> foo
946 FIXME: This shouldn't start the editor.
947 $ HGEDITOR=cat hg commit --amend --no-edit
948 editor should be suppressed
949
950
951 HG: Enter commit message. Lines beginning with 'HG:' are removed.
952 HG: Leave message empty to abort commit.
953 HG: --
954 HG: user: test
955 HG: branch 'silliness'
956 HG: added foo
957 $ hg parents --template "{desc}\n"
958 editor should be suppressed
959 $ hg status -mar
960 (Let's undo adding that "hi" so later tests don't need to be adjusted)
961 $ mv foo.orig foo
962 $ hg commit --amend --no-edit
963
933 964 Test that "diff()" in committemplate works correctly for amending
934 965 -----------------------------------------------------------------
935 966
936 967 $ cat >> .hg/hgrc <<EOF
937 968 > [committemplate]
938 969 > changeset.commit.amend = {desc}\n
939 970 > HG: M: {file_mods}
940 971 > HG: A: {file_adds}
941 972 > HG: R: {file_dels}
942 973 > {splitlines(diff()) % 'HG: {line}\n'}
943 974 > EOF
944 975
945 976 $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n"
946 977 M:
947 978 A: foo
948 979 R:
949 980 $ hg status -amr
950 981 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo"
951 982 expecting diff of foo
952 983
953 984 HG: M:
954 985 HG: A: foo
955 986 HG: R:
956 987 HG: diff -r 1205ed810051 foo
957 988 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
958 989 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
959 990 HG: @@ -0,0 +1,1 @@
960 991 HG: +foo
961 992
962 993 $ echo y > y
963 994 $ hg add y
964 995 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y"
965 996 expecting diff of foo and y
966 997
967 998 HG: M:
968 999 HG: A: foo y
969 1000 HG: R:
970 1001 HG: diff -r 1205ed810051 foo
971 1002 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
972 1003 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
973 1004 HG: @@ -0,0 +1,1 @@
974 1005 HG: +foo
975 1006 HG: diff -r 1205ed810051 y
976 1007 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
977 1008 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
978 1009 HG: @@ -0,0 +1,1 @@
979 1010 HG: +y
980 1011
981 1012 $ hg rm a
982 1013 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y"
983 1014 expecting diff of a, foo and y
984 1015
985 1016 HG: M:
986 1017 HG: A: foo y
987 1018 HG: R: a
988 1019 HG: diff -r 1205ed810051 a
989 1020 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
990 1021 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
991 1022 HG: @@ -1,2 +0,0 @@
992 1023 HG: -a
993 1024 HG: -a
994 1025 HG: diff -r 1205ed810051 foo
995 1026 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
996 1027 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
997 1028 HG: @@ -0,0 +1,1 @@
998 1029 HG: +foo
999 1030 HG: diff -r 1205ed810051 y
1000 1031 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1001 1032 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1002 1033 HG: @@ -0,0 +1,1 @@
1003 1034 HG: +y
1004 1035
1005 1036 $ hg rm x
1006 1037 $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y"
1007 1038 expecting diff of a, foo, x and y
1008 1039
1009 1040 HG: M:
1010 1041 HG: A: foo y
1011 1042 HG: R: a x
1012 1043 HG: diff -r 1205ed810051 a
1013 1044 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
1014 1045 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1015 1046 HG: @@ -1,2 +0,0 @@
1016 1047 HG: -a
1017 1048 HG: -a
1018 1049 HG: diff -r 1205ed810051 foo
1019 1050 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1020 1051 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1021 1052 HG: @@ -0,0 +1,1 @@
1022 1053 HG: +foo
1023 1054 HG: diff -r 1205ed810051 x
1024 1055 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1025 1056 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1026 1057 HG: @@ -1,1 +0,0 @@
1027 1058 HG: -x
1028 1059 HG: diff -r 1205ed810051 y
1029 1060 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1030 1061 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1031 1062 HG: @@ -0,0 +1,1 @@
1032 1063 HG: +y
1033 1064
1034 1065 $ echo cccc >> cc
1035 1066 $ hg status -amr
1036 1067 M cc
1037 1068 $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc
1038 1069 cc should be excluded
1039 1070
1040 1071 HG: M:
1041 1072 HG: A: foo y
1042 1073 HG: R: a x
1043 1074 HG: diff -r 1205ed810051 a
1044 1075 HG: --- a/a Thu Jan 01 00:00:00 1970 +0000
1045 1076 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1046 1077 HG: @@ -1,2 +0,0 @@
1047 1078 HG: -a
1048 1079 HG: -a
1049 1080 HG: diff -r 1205ed810051 foo
1050 1081 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1051 1082 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000
1052 1083 HG: @@ -0,0 +1,1 @@
1053 1084 HG: +foo
1054 1085 HG: diff -r 1205ed810051 x
1055 1086 HG: --- a/x Thu Jan 01 00:00:00 1970 +0000
1056 1087 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1057 1088 HG: @@ -1,1 +0,0 @@
1058 1089 HG: -x
1059 1090 HG: diff -r 1205ed810051 y
1060 1091 HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1061 1092 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000
1062 1093 HG: @@ -0,0 +1,1 @@
1063 1094 HG: +y
1064 1095
1065 1096 Check for issue4405
1066 1097 -------------------
1067 1098
1068 1099 Setup the repo with a file that gets moved in a second commit.
1069 1100 $ hg init repo
1070 1101 $ cd repo
1071 1102 $ touch a0
1072 1103 $ hg add a0
1073 1104 $ hg commit -m a0
1074 1105 $ hg mv a0 a1
1075 1106 $ hg commit -m a1
1076 1107 $ hg up -q 0
1077 1108 $ hg log -G --template '{rev} {desc}'
1078 1109 o 1 a1
1079 1110 |
1080 1111 @ 0 a0
1081 1112
1082 1113
1083 1114 Now we branch the repro, but re-use the file contents, so we have a divergence
1084 1115 in the file revlog topology and the changelog topology.
1085 1116 $ hg revert --rev 1 --all
1086 1117 removing a0
1087 1118 adding a1
1088 1119 $ hg ci -qm 'a1-amend'
1089 1120 $ hg log -G --template '{rev} {desc}'
1090 1121 @ 2 a1-amend
1091 1122 |
1092 1123 | o 1 a1
1093 1124 |/
1094 1125 o 0 a0
1095 1126
1096 1127
1097 1128 The way mercurial does amends is by folding the working copy and old commit
1098 1129 together into another commit (rev 3). During this process, _findlimit is called
1099 1130 to check how far back to look for the transitive closure of file copy
1100 1131 information, but due to the divergence of the filelog and changelog graph
1101 1132 topologies, before _findlimit was fixed, it returned a rev which was not far
1102 1133 enough back in this case.
1103 1134 $ hg mv a1 a2
1104 1135 $ hg status --copies --rev 0
1105 1136 A a2
1106 1137 a0
1107 1138 R a0
1108 1139 $ hg ci --amend -q
1109 1140 $ hg log -G --template '{rev} {desc}'
1110 1141 @ 3 a1-amend
1111 1142 |
1112 1143 | o 1 a1
1113 1144 |/
1114 1145 o 0 a0
1115 1146
1116 1147
1117 1148 Before the fix, the copy information was lost.
1118 1149 $ hg status --copies --rev 0
1119 1150 A a2
1120 1151 a0
1121 1152 R a0
1122 1153 $ cd ..
1123 1154
1124 1155 Check that amend properly preserve rename from directory rename (issue-4516)
1125 1156
1126 1157 If a parent of the merge renames a full directory, any files added to the old
1127 1158 directory in the other parent will be renamed to the new directory. For some
1128 1159 reason, the rename metadata was when amending such merge. This test ensure we
1129 1160 do not regress. We have a dedicated repo because it needs a setup with renamed
1130 1161 directory)
1131 1162
1132 1163 $ hg init issue4516
1133 1164 $ cd issue4516
1134 1165 $ mkdir olddirname
1135 1166 $ echo line1 > olddirname/commonfile.py
1136 1167 $ hg add olddirname/commonfile.py
1137 1168 $ hg ci -m first
1138 1169
1139 1170 $ hg branch newdirname
1140 1171 marked working directory as branch newdirname
1141 1172 (branches are permanent and global, did you want a bookmark?)
1142 1173 $ hg mv olddirname newdirname
1143 1174 moving olddirname/commonfile.py to newdirname/commonfile.py
1144 1175 $ hg ci -m rename
1145 1176
1146 1177 $ hg update default
1147 1178 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1148 1179 $ echo line1 > olddirname/newfile.py
1149 1180 $ hg add olddirname/newfile.py
1150 1181 $ hg ci -m log
1151 1182
1152 1183 $ hg up newdirname
1153 1184 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1154 1185 $ # create newdirname/newfile.py
1155 1186 $ hg merge default
1156 1187 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1157 1188 (branch merge, don't forget to commit)
1158 1189 $ hg ci -m add
1159 1190 $
1160 1191 $ hg debugrename newdirname/newfile.py
1161 1192 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def
1162 1193 $ hg status -C --change .
1163 1194 A newdirname/newfile.py
1164 1195 $ hg status -C --rev 1
1165 1196 A newdirname/newfile.py
1166 1197 $ hg status -C --rev 2
1167 1198 A newdirname/commonfile.py
1168 1199 olddirname/commonfile.py
1169 1200 A newdirname/newfile.py
1170 1201 olddirname/newfile.py
1171 1202 R olddirname/commonfile.py
1172 1203 R olddirname/newfile.py
1173 1204 $ hg debugindex newdirname/newfile.py
1174 1205 rev linkrev nodeid p1 p2
1175 1206 0 3 34a4d536c0c0 000000000000 000000000000
1176 1207
1177 1208 $ echo a >> newdirname/commonfile.py
1178 1209 $ hg ci --amend -m bug
1179 1210 $ hg debugrename newdirname/newfile.py
1180 1211 newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def
1181 1212 $ hg debugindex newdirname/newfile.py
1182 1213 rev linkrev nodeid p1 p2
1183 1214 0 3 34a4d536c0c0 000000000000 000000000000
1184 1215
1185 1216 #if execbit
1186 1217
1187 1218 Test if amend preserves executable bit changes
1188 1219 $ chmod +x newdirname/commonfile.py
1189 1220 $ hg ci -m chmod
1190 1221 $ hg ci --amend -m "chmod amended"
1191 1222 $ hg ci --amend -m "chmod amended second time"
1192 1223 $ hg log -p --git -r .
1193 1224 changeset: 7:b1326f52dddf
1194 1225 branch: newdirname
1195 1226 tag: tip
1196 1227 parent: 4:7fd235f7cb2f
1197 1228 user: test
1198 1229 date: Thu Jan 01 00:00:00 1970 +0000
1199 1230 summary: chmod amended second time
1200 1231
1201 1232 diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py
1202 1233 old mode 100644
1203 1234 new mode 100755
1204 1235
1205 1236 #endif
1206 1237
1207 1238 Test amend with file inclusion options
1208 1239 --------------------------------------
1209 1240
1210 1241 These tests ensure that we are always amending some files that were part of the
1211 1242 pre-amend commit. We want to test that the remaining files in the pre-amend
1212 1243 commit were not changed in the amended commit. We do so by performing a diff of
1213 1244 the amended commit against its parent commit.
1214 1245 $ cd ..
1215 1246 $ hg init testfileinclusions
1216 1247 $ cd testfileinclusions
1217 1248 $ echo a > a
1218 1249 $ echo b > b
1219 1250 $ hg commit -Aqm "Adding a and b"
1220 1251
1221 1252 Only add changes to a particular file
1222 1253 $ echo a >> a
1223 1254 $ echo b >> b
1224 1255 $ hg commit --amend -I a
1225 1256 $ hg diff --git -r null -r .
1226 1257 diff --git a/a b/a
1227 1258 new file mode 100644
1228 1259 --- /dev/null
1229 1260 +++ b/a
1230 1261 @@ -0,0 +1,2 @@
1231 1262 +a
1232 1263 +a
1233 1264 diff --git a/b b/b
1234 1265 new file mode 100644
1235 1266 --- /dev/null
1236 1267 +++ b/b
1237 1268 @@ -0,0 +1,1 @@
1238 1269 +b
1239 1270
1240 1271 $ echo a >> a
1241 1272 $ hg commit --amend b
1242 1273 $ hg diff --git -r null -r .
1243 1274 diff --git a/a b/a
1244 1275 new file mode 100644
1245 1276 --- /dev/null
1246 1277 +++ b/a
1247 1278 @@ -0,0 +1,2 @@
1248 1279 +a
1249 1280 +a
1250 1281 diff --git a/b b/b
1251 1282 new file mode 100644
1252 1283 --- /dev/null
1253 1284 +++ b/b
1254 1285 @@ -0,0 +1,2 @@
1255 1286 +b
1256 1287 +b
1257 1288
1258 1289 Exclude changes to a particular file
1259 1290 $ echo b >> b
1260 1291 $ hg commit --amend -X a
1261 1292 $ hg diff --git -r null -r .
1262 1293 diff --git a/a b/a
1263 1294 new file mode 100644
1264 1295 --- /dev/null
1265 1296 +++ b/a
1266 1297 @@ -0,0 +1,2 @@
1267 1298 +a
1268 1299 +a
1269 1300 diff --git a/b b/b
1270 1301 new file mode 100644
1271 1302 --- /dev/null
1272 1303 +++ b/b
1273 1304 @@ -0,0 +1,3 @@
1274 1305 +b
1275 1306 +b
1276 1307 +b
1277 1308
1278 1309 Check the addremove flag
1279 1310 $ echo c > c
1280 1311 $ rm a
1281 1312 $ hg commit --amend -A
1282 1313 removing a
1283 1314 adding c
1284 1315 $ hg diff --git -r null -r .
1285 1316 diff --git a/b b/b
1286 1317 new file mode 100644
1287 1318 --- /dev/null
1288 1319 +++ b/b
1289 1320 @@ -0,0 +1,3 @@
1290 1321 +b
1291 1322 +b
1292 1323 +b
1293 1324 diff --git a/c b/c
1294 1325 new file mode 100644
1295 1326 --- /dev/null
1296 1327 +++ b/c
1297 1328 @@ -0,0 +1,1 @@
1298 1329 +c
General Comments 0
You need to be logged in to leave comments. Login now