##// END OF EJS Templates
tests: add test showing that merge state is not cleared by amend...
Martin von Zweigbergk -
r45947:cf21cda4 default
parent child Browse files
Show More
@@ -1,508 +1,532 b''
1 1 #testcases obsstore-off obsstore-on
2 2
3 3 $ cat << EOF >> $HGRCPATH
4 4 > [extensions]
5 5 > amend=
6 6 > debugdrawdag=$TESTDIR/drawdag.py
7 7 > [diff]
8 8 > git=1
9 9 > EOF
10 10
11 11 #if obsstore-on
12 12 $ cat << EOF >> $HGRCPATH
13 13 > [experimental]
14 14 > evolution.createmarkers=True
15 15 > EOF
16 16 #endif
17 17
18 18 Basic amend
19 19
20 20 $ hg init repo1
21 21 $ cd repo1
22 22 $ hg debugdrawdag <<'EOS'
23 23 > B
24 24 > |
25 25 > A
26 26 > EOS
27 27
28 28 $ hg update B -q
29 29 $ echo 2 >> B
30 30
31 31 $ hg amend
32 32 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/112478962961-7e959a55-amend.hg (obsstore-off !)
33 33 #if obsstore-off
34 34 $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n'
35 35 @ 1 be169c7e8dbe B
36 36 | diff --git a/B b/B
37 37 | new file mode 100644
38 38 | --- /dev/null
39 39 | +++ b/B
40 40 | @@ -0,0 +1,1 @@
41 41 | +B2
42 42 |
43 43 o 0 426bada5c675 A
44 44 diff --git a/A b/A
45 45 new file mode 100644
46 46 --- /dev/null
47 47 +++ b/A
48 48 @@ -0,0 +1,1 @@
49 49 +A
50 50 \ No newline at end of file
51 51
52 52 #else
53 53 $ hg log -p -G --hidden -T '{rev} {node|short} {desc}\n'
54 54 @ 2 be169c7e8dbe B
55 55 | diff --git a/B b/B
56 56 | new file mode 100644
57 57 | --- /dev/null
58 58 | +++ b/B
59 59 | @@ -0,0 +1,1 @@
60 60 | +B2
61 61 |
62 62 | x 1 112478962961 B
63 63 |/ diff --git a/B b/B
64 64 | new file mode 100644
65 65 | --- /dev/null
66 66 | +++ b/B
67 67 | @@ -0,0 +1,1 @@
68 68 | +B
69 69 | \ No newline at end of file
70 70 |
71 71 o 0 426bada5c675 A
72 72 diff --git a/A b/A
73 73 new file mode 100644
74 74 --- /dev/null
75 75 +++ b/A
76 76 @@ -0,0 +1,1 @@
77 77 +A
78 78 \ No newline at end of file
79 79
80 80 #endif
81 81
82 82 Nothing changed
83 83
84 84 $ hg amend
85 85 nothing changed
86 86 [1]
87 87
88 88 $ hg amend -d "0 0"
89 89 nothing changed
90 90 [1]
91 91
92 92 $ hg amend -d "Thu Jan 01 00:00:00 1970 UTC"
93 93 nothing changed
94 94 [1]
95 95
96 #if obsstore-on
97 $ hg init repo-merge-state
98 $ cd repo-merge-state
99 $ echo a > f
100 $ hg ci -Aqm a
101 $ echo b > f
102 $ hg ci -Aqm b
103 $ echo c > f
104 $ hg co -m '.^'
105 merging f
106 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
107 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
108 use 'hg resolve' to retry unresolved file merges
109 [1]
110 $ echo d > f
111 $ hg resolve -m f
112 (no more unresolved files)
113 $ hg ci --amend --config experimental.evolution.allowunstable=True
114 1 new orphan changesets
115 $ hg resolve -l
116 R f
117 $ cd ..
118 #endif
119
96 120 Matcher and metadata options
97 121
98 122 $ echo 3 > C
99 123 $ echo 4 > D
100 124 $ hg add C D
101 125 $ hg amend -m NEWMESSAGE -I C
102 126 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/be169c7e8dbe-7684ddc5-amend.hg (obsstore-off !)
103 127 $ hg log -r . -T '{node|short} {desc} {files}\n'
104 128 c7ba14d9075b NEWMESSAGE B C
105 129 $ echo 5 > E
106 130 $ rm C
107 131 $ hg amend -d '2000 1000' -u 'Foo <foo@example.com>' -A C D
108 132 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/c7ba14d9075b-b3e76daa-amend.hg (obsstore-off !)
109 133 $ hg log -r . -T '{node|short} {desc} {files} {author} {date}\n'
110 134 14f6c4bcc865 NEWMESSAGE B D Foo <foo@example.com> 2000.01000
111 135
112 136 Amend with editor
113 137
114 138 $ cat > $TESTTMP/prefix.sh <<'EOF'
115 139 > printf 'EDITED: ' > $TESTTMP/msg
116 140 > cat "$1" >> $TESTTMP/msg
117 141 > mv $TESTTMP/msg "$1"
118 142 > EOF
119 143 $ chmod +x $TESTTMP/prefix.sh
120 144
121 145 $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend --edit
122 146 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/14f6c4bcc865-6591f15d-amend.hg (obsstore-off !)
123 147 $ hg log -r . -T '{node|short} {desc}\n'
124 148 298f085230c3 EDITED: NEWMESSAGE
125 149 $ HGEDITOR="sh $TESTTMP/prefix.sh" hg amend -e -m MSG
126 150 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/298f085230c3-d81a6ad3-amend.hg (obsstore-off !)
127 151 $ hg log -r . -T '{node|short} {desc}\n'
128 152 974f07f28537 EDITED: MSG
129 153
130 154 $ echo FOO > $TESTTMP/msg
131 155 $ hg amend -l $TESTTMP/msg -m BAR
132 156 abort: cannot specify both --message and --logfile
133 157 [255]
134 158 $ hg amend -l $TESTTMP/msg
135 159 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/974f07f28537-edb6470a-amend.hg (obsstore-off !)
136 160 $ hg log -r . -T '{node|short} {desc}\n'
137 161 507be9bdac71 FOO
138 162
139 163 Interactive mode
140 164
141 165 $ touch F G
142 166 $ hg add F G
143 167 $ cat <<EOS | hg amend -i --config ui.interactive=1
144 168 > y
145 169 > n
146 170 > EOS
147 171 diff --git a/F b/F
148 172 new file mode 100644
149 173 examine changes to 'F'?
150 174 (enter ? for help) [Ynesfdaq?] y
151 175
152 176 diff --git a/G b/G
153 177 new file mode 100644
154 178 examine changes to 'G'?
155 179 (enter ? for help) [Ynesfdaq?] n
156 180
157 181 saved backup bundle to $TESTTMP/repo1/.hg/strip-backup/507be9bdac71-c8077452-amend.hg (obsstore-off !)
158 182 $ hg log -r . -T '{files}\n'
159 183 B D F
160 184
161 185 Amend in the middle of a stack
162 186
163 187 $ hg init $TESTTMP/repo2
164 188 $ cd $TESTTMP/repo2
165 189 $ hg debugdrawdag <<'EOS'
166 190 > C
167 191 > |
168 192 > B
169 193 > |
170 194 > A
171 195 > EOS
172 196
173 197 $ hg update -q B
174 198 $ echo 2 >> B
175 199 $ hg amend
176 200 abort: cannot amend changeset with children
177 201 [255]
178 202
179 203 #if obsstore-on
180 204
181 205 With allowunstable, amend could work in the middle of a stack
182 206
183 207 $ cat >> $HGRCPATH <<EOF
184 208 > [experimental]
185 209 > evolution.createmarkers=True
186 210 > evolution.allowunstable=True
187 211 > EOF
188 212
189 213 $ hg amend
190 214 1 new orphan changesets
191 215 $ hg log -T '{rev} {node|short} {desc}\n' -G
192 216 @ 3 be169c7e8dbe B
193 217 |
194 218 | * 2 26805aba1e60 C
195 219 | |
196 220 | x 1 112478962961 B
197 221 |/
198 222 o 0 426bada5c675 A
199 223
200 224 Checking the note stored in the obsmarker
201 225
202 226 $ echo foo > bar
203 227 $ hg add bar
204 228 $ hg amend --note 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
205 229 abort: cannot store a note of more than 255 bytes
206 230 [255]
207 231 $ hg amend --note "adding bar"
208 232 $ hg debugobsolete -r .
209 233 112478962961147124edd43549aedd1a335e44bf be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
210 234 be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 16084da537dd8f84cfdb3055c633772269d62e1b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'note': 'adding bar', 'operation': 'amend', 'user': 'test'}
211 235 #endif
212 236
213 237 Cannot amend public changeset
214 238
215 239 $ hg phase -r A --public
216 240 $ hg update -C -q A
217 241 $ hg amend -m AMEND
218 242 abort: cannot amend public changesets
219 243 (see 'hg help phases' for details)
220 244 [255]
221 245
222 246 Amend a merge changeset
223 247
224 248 $ hg init $TESTTMP/repo3
225 249 $ cd $TESTTMP/repo3
226 250 $ hg debugdrawdag <<'EOS'
227 251 > C
228 252 > /|
229 253 > A B
230 254 > EOS
231 255 $ hg update -q C
232 256 $ hg amend -m FOO
233 257 saved backup bundle to $TESTTMP/repo3/.hg/strip-backup/a35c07e8a2a4-15ff4612-amend.hg (obsstore-off !)
234 258 $ rm .hg/localtags
235 259 $ hg log -G -T '{desc}\n'
236 260 @ FOO
237 261 |\
238 262 | o B
239 263 |
240 264 o A
241 265
242 266
243 267 More complete test for status changes (issue5732)
244 268 -------------------------------------------------
245 269
246 270 Generates history of files having 3 states, r0_r1_wc:
247 271
248 272 r0: ground (content/missing)
249 273 r1: old state to be amended (content/missing, where missing means removed)
250 274 wc: changes to be included in r1 (content/missing-tracked/untracked)
251 275
252 276 $ hg init $TESTTMP/wcstates
253 277 $ cd $TESTTMP/wcstates
254 278
255 279 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 1
256 280 $ hg addremove -q --similarity 0
257 281 $ hg commit -m0
258 282
259 283 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 2
260 284 $ hg addremove -q --similarity 0
261 285 $ hg commit -m1
262 286
263 287 $ "$PYTHON" $TESTDIR/generate-working-copy-states.py state 2 wc
264 288 $ hg addremove -q --similarity 0
265 289 $ hg forget *_*_*-untracked
266 290 $ rm *_*_missing-*
267 291
268 292 amend r1 to include wc changes
269 293
270 294 $ hg amend
271 295 saved backup bundle to * (glob) (obsstore-off !)
272 296
273 297 clean/modified/removed/added states of the amended revision
274 298
275 299 $ hg status --all --change . 'glob:content1_*_content1-tracked'
276 300 C content1_content1_content1-tracked
277 301 C content1_content2_content1-tracked
278 302 C content1_missing_content1-tracked
279 303 $ hg status --all --change . 'glob:content1_*_content[23]-tracked'
280 304 M content1_content1_content3-tracked
281 305 M content1_content2_content2-tracked
282 306 M content1_content2_content3-tracked
283 307 M content1_missing_content3-tracked
284 308 $ hg status --all --change . 'glob:content1_*_missing-tracked'
285 309 M content1_content2_missing-tracked
286 310 R content1_missing_missing-tracked
287 311 C content1_content1_missing-tracked
288 312 $ hg status --all --change . 'glob:content1_*_*-untracked'
289 313 R content1_content1_content1-untracked
290 314 R content1_content1_content3-untracked
291 315 R content1_content1_missing-untracked
292 316 R content1_content2_content1-untracked
293 317 R content1_content2_content2-untracked
294 318 R content1_content2_content3-untracked
295 319 R content1_content2_missing-untracked
296 320 R content1_missing_content1-untracked
297 321 R content1_missing_content3-untracked
298 322 R content1_missing_missing-untracked
299 323 $ hg status --all --change . 'glob:missing_content2_*'
300 324 A missing_content2_content2-tracked
301 325 A missing_content2_content3-tracked
302 326 A missing_content2_missing-tracked
303 327 $ hg status --all --change . 'glob:missing_missing_*'
304 328 A missing_missing_content3-tracked
305 329
306 330 working directory should be all clean (with some missing/untracked files)
307 331
308 332 $ hg status --all 'glob:*_content?-tracked'
309 333 C content1_content1_content1-tracked
310 334 C content1_content1_content3-tracked
311 335 C content1_content2_content1-tracked
312 336 C content1_content2_content2-tracked
313 337 C content1_content2_content3-tracked
314 338 C content1_missing_content1-tracked
315 339 C content1_missing_content3-tracked
316 340 C missing_content2_content2-tracked
317 341 C missing_content2_content3-tracked
318 342 C missing_missing_content3-tracked
319 343 $ hg status --all 'glob:*_missing-tracked'
320 344 ! content1_content1_missing-tracked
321 345 ! content1_content2_missing-tracked
322 346 ! content1_missing_missing-tracked
323 347 ! missing_content2_missing-tracked
324 348 ! missing_missing_missing-tracked
325 349 $ hg status --all 'glob:*-untracked'
326 350 ? content1_content1_content1-untracked
327 351 ? content1_content1_content3-untracked
328 352 ? content1_content2_content1-untracked
329 353 ? content1_content2_content2-untracked
330 354 ? content1_content2_content3-untracked
331 355 ? content1_missing_content1-untracked
332 356 ? content1_missing_content3-untracked
333 357 ? missing_content2_content2-untracked
334 358 ? missing_content2_content3-untracked
335 359 ? missing_missing_content3-untracked
336 360
337 361 =================================
338 362 Test backup-bundle config option|
339 363 =================================
340 364 $ hg init $TESTTMP/repo4
341 365 $ cd $TESTTMP/repo4
342 366 $ echo a>a
343 367 $ hg ci -Aqma
344 368 $ echo oops>b
345 369 $ hg ci -Aqm "b"
346 370 $ echo partiallyfixed > b
347 371
348 372 #if obsstore-off
349 373 $ hg amend
350 374 saved backup bundle to $TESTTMP/repo4/.hg/strip-backup/95e899acf2ce-f11cb050-amend.hg
351 375 When backup-bundle config option is set:
352 376 $ cat << EOF >> $HGRCPATH
353 377 > [rewrite]
354 378 > backup-bundle = False
355 379 > EOF
356 380 $ echo fixed > b
357 381 $ hg amend
358 382
359 383 #else
360 384 $ hg amend
361 385 When backup-bundle config option is set:
362 386 $ cat << EOF >> $HGRCPATH
363 387 > [rewrite]
364 388 > backup-bundle = False
365 389 > EOF
366 390 $ echo fixed > b
367 391 $ hg amend
368 392
369 393 #endif
370 394 ==========================================
371 395 Test update-timestamp config option|
372 396 ==========================================
373 397
374 398 $ cat >> $HGRCPATH << EOF
375 399 > [extensions]
376 400 > amend=
377 401 > mockmakedate = $TESTDIR/mockmakedate.py
378 402 > EOF
379 403
380 404 $ hg init $TESTTMP/repo5
381 405 $ cd $TESTTMP/repo5
382 406 $ cat <<'EOF' >> .hg/hgrc
383 407 > [ui]
384 408 > logtemplate = 'user: {user}
385 409 > date: {date|date}
386 410 > summary: {desc|firstline}\n'
387 411 > EOF
388 412
389 413 $ echo a>a
390 414 $ hg ci -Am 'commit 1'
391 415 adding a
392 416
393 417 When updatetimestamp is False
394 418
395 419 $ hg amend --date '1997-1-1 0:1'
396 420 $ hg log --limit 1
397 421 user: test
398 422 date: Wed Jan 01 00:01:00 1997 +0000
399 423 summary: commit 1
400 424
401 425 When update-timestamp is True and no other change than the date
402 426
403 427 $ hg amend --config rewrite.update-timestamp=True
404 428 nothing changed
405 429 [1]
406 430 $ hg log --limit 1
407 431 user: test
408 432 date: Wed Jan 01 00:01:00 1997 +0000
409 433 summary: commit 1
410 434
411 435 When update-timestamp is True and there is other change than the date
412 436 $ hg amend --user foobar --config rewrite.update-timestamp=True
413 437 $ hg log --limit 1
414 438 user: foobar
415 439 date: Thu Jan 01 00:00:02 1970 +0000
416 440 summary: commit 1
417 441
418 442 When date option is applicable and update-timestamp is True
419 443 $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True
420 444 $ hg log --limit 1
421 445 user: foobar
422 446 date: Thu Jan 01 00:01:00 1998 +0000
423 447 summary: commit 1
424 448
425 449 Unlike rewrite.update-timestamp, -D/--currentdate always updates the timestamp
426 450
427 451 $ hg amend -D
428 452 $ hg log --limit 1
429 453 user: foobar
430 454 date: Thu Jan 01 00:00:04 1970 +0000
431 455 summary: commit 1
432 456
433 457 $ hg amend -D --config rewrite.update-timestamp=True
434 458 $ hg log --limit 1
435 459 user: foobar
436 460 date: Thu Jan 01 00:00:05 1970 +0000
437 461 summary: commit 1
438 462
439 463 rewrite.update-timestamp can be negated by --no-currentdate
440 464
441 465 $ hg amend --config rewrite.update-timestamp=True --no-currentdate -u baz
442 466 $ hg log --limit 1
443 467 user: baz
444 468 date: Thu Jan 01 00:00:05 1970 +0000
445 469 summary: commit 1
446 470
447 471 Bad combination of date options:
448 472
449 473 $ hg amend -D --date '0 0'
450 474 abort: cannot specify both --date and --currentdate
451 475 [255]
452 476
453 477 Close branch
454 478
455 479 $ hg amend --secret --close-branch
456 480 $ hg log --limit 1 -T 'close={get(extras, "close")}\nphase={phase}\n'
457 481 close=1
458 482 phase=secret
459 483
460 484 $ cd ..
461 485
462 486 Corner case of amend from issue6157:
463 487 - working copy parent has a change to file `a`
464 488 - working copy has the inverse change
465 489 - we amend the working copy parent for files other than `a`
466 490 hg used to include the changes to `a` anyway.
467 491
468 492 $ hg init 6157; cd 6157
469 493 $ echo a > a; echo b > b; hg commit -qAm_
470 494 $ echo a2 > a; hg commit -qm_
471 495 $ hg diff --stat -c .
472 496 a | 2 +-
473 497 1 files changed, 1 insertions(+), 1 deletions(-)
474 498 $ echo a > a; echo b2 > b; hg amend -q b
475 499 $ hg diff --stat -c .
476 500 a | 2 +-
477 501 b | 2 +-
478 502 2 files changed, 2 insertions(+), 2 deletions(-)
479 503
480 504 Modifying a file while the editor is open can cause dirstate corruption
481 505 (issue6233)
482 506
483 507 $ cd $TESTTMP
484 508 $ hg init modify-during-amend; cd modify-during-amend
485 509 $ echo r0 > foo; hg commit -qAm "r0"
486 510 $ echo alpha > foo; hg commit -qm "alpha"
487 511 $ echo beta >> foo
488 512 $ cat > $TESTTMP/touchy_editor.sh <<EOF
489 513 > sleep 1
490 514 > echo delta >> "$TESTTMP/modify-during-amend/foo"
491 515 > sleep 1
492 516 > echo hi > "\$1"
493 517 > sleep 1
494 518 > EOF
495 519 $ HGEDITOR="sh $TESTTMP/touchy_editor.sh" hg commit --amend
496 520 $ if (hg diff -c . | grep 'delta' >/dev/null) || [ -n "$(hg status)" ]; then
497 521 > echo "OK."
498 522 > else
499 523 > echo "Bug detected. 'delta' is not part of the commit OR the wdir"
500 524 > echo "Diff and status before rebuild:"
501 525 > hg diff
502 526 > hg status
503 527 > hg debugrebuilddirstate
504 528 > echo "Diff and status after rebuild:"
505 529 > hg diff
506 530 > hg status
507 531 > fi
508 532 OK.
General Comments 0
You need to be logged in to leave comments. Login now