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