Mercurial > hg
comparison tests/test-commit-amend.t @ 34085:e8a7c1a0565a
cmdutil: remove the redundant commit during amend
There was an extra commit made during the amend operation to track the
changes to the working copy. However, this logic was written a long time back
and newer API's make this extra commit redundant. Therefore, I am removing the
extra commit. After this change, I noticed that
- Execution time of the cmdutil.amend improved by over 40%.
- Execution time of "hg commit --amend" improved by over 20%.
Test Plan:
I ensured that the all the hg tests passed after the change. I had
to fix a few tests which were aware of the extra commit made during the amend.
Differential Revision: https://phab.mercurial-scm.org/D636
author | Saurabh Singh <singhsrb@fb.com> |
---|---|
date | Fri, 01 Sep 2017 12:34:36 -0700 |
parents | 6fb5a06b92c6 |
children | 1644623ab096 |
comparison
equal
deleted
inserted
replaced
34084:6c5cdb02f2f9 | 34085:e8a7c1a0565a |
---|---|
38 | 38 |
39 $ echo a >> a | 39 $ echo a >> a |
40 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1' | 40 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1' |
41 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 | 41 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 |
42 43f1ba15f28a tip | 42 43f1ba15f28a tip |
43 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-f1bf3ab8-amend.hg (glob) | 43 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg (glob) |
44 $ echo 'pretxncommit.foo = ' >> $HGRCPATH | 44 $ echo 'pretxncommit.foo = ' >> $HGRCPATH |
45 $ hg diff -c . | 45 $ hg diff -c . |
46 diff -r ad120869acf0 -r 43f1ba15f28a a | 46 diff -r ad120869acf0 -r 43f1ba15f28a a |
47 --- a/a Thu Jan 01 00:00:00 1970 +0000 | 47 --- a/a Thu Jan 01 00:00:00 1970 +0000 |
48 +++ b/a Thu Jan 01 00:00:00 1970 +0000 | 48 +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
67 | 67 |
68 $ cat > editor.sh << '__EOF__' | 68 $ cat > editor.sh << '__EOF__' |
69 > #!/bin/sh | 69 > #!/bin/sh |
70 > echo "" > "$1" | 70 > echo "" > "$1" |
71 > __EOF__ | 71 > __EOF__ |
72 | |
73 Update the existing file to ensure that the dirstate is not in pending state | |
74 (where the status of some files in the working copy is not known yet). This in | |
75 turn ensures that when the transaction is aborted due to an empty message during | |
76 the amend, there should be no rollback. | |
77 $ echo a >> a | |
78 | |
72 $ echo b > b | 79 $ echo b > b |
73 $ hg add b | 80 $ hg add b |
74 $ hg summary | 81 $ hg summary |
75 parent: 1:43f1ba15f28a tip | 82 parent: 1:43f1ba15f28a tip |
76 amend base1 | 83 amend base1 |
77 branch: default | 84 branch: default |
78 commit: 1 added, 1 unknown | 85 commit: 1 modified, 1 added, 1 unknown |
79 update: (current) | 86 update: (current) |
80 phases: 2 draft | 87 phases: 2 draft |
81 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend | 88 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend |
82 transaction abort! | |
83 rollback completed | |
84 abort: empty commit message | 89 abort: empty commit message |
85 [255] | 90 [255] |
86 $ hg summary | 91 $ hg summary |
87 parent: 1:43f1ba15f28a tip | 92 parent: 1:43f1ba15f28a tip |
88 amend base1 | 93 amend base1 |
89 branch: default | 94 branch: default |
90 commit: 1 added, 1 unknown | 95 commit: 1 modified, 1 added, 1 unknown |
91 update: (current) | 96 update: (current) |
92 phases: 2 draft | 97 phases: 2 draft |
93 | 98 |
94 Add new file: | 99 Add new file along with modified existing file: |
95 $ hg ci --amend -m 'amend base1 new file' | 100 $ hg ci --amend -m 'amend base1 new file' |
96 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-7a3b3496-amend.hg (glob) | 101 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg (glob) |
97 | 102 |
98 Remove file that was added in amended commit: | 103 Remove file that was added in amended commit: |
99 (and test logfile option) | 104 (and test logfile option) |
100 (and test that logfile option do not trigger an editor) | 105 (and test that logfile option do not trigger an editor) |
101 | 106 |
102 $ hg rm b | 107 $ hg rm b |
103 $ echo 'amend base1 remove new file' > ../logfile | 108 $ echo 'amend base1 remove new file' > ../logfile |
104 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile | 109 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile |
105 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-0b55739a-amend.hg (glob) | 110 saved backup bundle to $TESTTMP/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg (glob) |
106 | 111 |
107 $ hg cat b | 112 $ hg cat b |
108 b: no such file in rev 74609c7f506e | 113 b: no such file in rev 47343646fa3d |
109 [1] | 114 [1] |
110 | 115 |
111 No changes, just a different message: | 116 No changes, just a different message: |
112 | 117 |
113 $ hg ci -v --amend -m 'no changes, new message' | 118 $ hg ci -v --amend -m 'no changes, new message' |
114 amending changeset 74609c7f506e | 119 amending changeset 47343646fa3d |
115 copying changeset 74609c7f506e to ad120869acf0 | 120 copying changeset 47343646fa3d to ad120869acf0 |
116 committing files: | 121 committing files: |
117 a | 122 a |
118 committing manifest | 123 committing manifest |
119 committing changelog | 124 committing changelog |
120 1 changesets found | 125 1 changesets found |
121 uncompressed size of bundle content: | 126 uncompressed size of bundle content: |
122 254 (changelog) | 127 254 (changelog) |
123 163 (manifests) | 128 163 (manifests) |
124 129 a | 129 131 a |
125 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-1bfde511-amend.hg (glob) | 130 saved backup bundle to $TESTTMP/.hg/strip-backup/47343646fa3d-c2758885-amend.hg (glob) |
126 1 changesets found | 131 1 changesets found |
127 uncompressed size of bundle content: | 132 uncompressed size of bundle content: |
128 250 (changelog) | 133 250 (changelog) |
129 163 (manifests) | 134 163 (manifests) |
130 129 a | 135 131 a |
131 adding branch | 136 adding branch |
132 adding changesets | 137 adding changesets |
133 adding manifests | 138 adding manifests |
134 adding file changes | 139 adding file changes |
135 added 1 changesets with 1 changes to 1 files | 140 added 1 changesets with 1 changes to 1 files |
136 committed changeset 1:1cd866679df8 | 141 committed changeset 1:401431e913a1 |
137 $ hg diff -c . | 142 $ hg diff -c . |
138 diff -r ad120869acf0 -r 1cd866679df8 a | 143 diff -r ad120869acf0 -r 401431e913a1 a |
139 --- a/a Thu Jan 01 00:00:00 1970 +0000 | 144 --- a/a Thu Jan 01 00:00:00 1970 +0000 |
140 +++ b/a Thu Jan 01 00:00:00 1970 +0000 | 145 +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
141 @@ -1,1 +1,3 @@ | 146 @@ -1,1 +1,4 @@ |
142 a | 147 a |
143 +a | 148 +a |
144 +a | 149 +a |
150 +a | |
145 $ hg log | 151 $ hg log |
146 changeset: 1:1cd866679df8 | 152 changeset: 1:401431e913a1 |
147 tag: tip | 153 tag: tip |
148 user: test | 154 user: test |
149 date: Thu Jan 01 00:00:00 1970 +0000 | 155 date: Thu Jan 01 00:00:00 1970 +0000 |
150 summary: no changes, new message | 156 summary: no changes, new message |
151 | 157 |
166 > env | grep HGEDITFORM | 172 > env | grep HGEDITFORM |
167 > true | 173 > true |
168 > EOF | 174 > EOF |
169 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0' | 175 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0' |
170 HGEDITFORM=commit.amend.normal | 176 HGEDITFORM=commit.amend.normal |
171 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-5f5bcb85-amend.hg (glob) | 177 saved backup bundle to $TESTTMP/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg (glob) |
172 $ echo a >> a | 178 $ echo a >> a |
173 $ hg ci --amend -u foo -d '1 0' | 179 $ hg ci --amend -u foo -d '1 0' |
174 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-83b10a27-amend.hg (glob) | 180 saved backup bundle to $TESTTMP/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg (glob) |
175 $ hg log -r . | 181 $ hg log -r . |
176 changeset: 1:5f357c7560ab | 182 changeset: 1:a9a13940fc03 |
177 tag: tip | 183 tag: tip |
178 user: foo | 184 user: foo |
179 date: Thu Jan 01 00:00:01 1970 +0000 | 185 date: Thu Jan 01 00:00:01 1970 +0000 |
180 summary: no changes, new message | 186 summary: no changes, new message |
181 | 187 |
195 > pretxncommit.test-saving-last-message = false | 201 > pretxncommit.test-saving-last-message = false |
196 > __EOF__ | 202 > __EOF__ |
197 | 203 |
198 $ rm -f .hg/last-message.txt | 204 $ rm -f .hg/last-message.txt |
199 $ hg commit --amend -v -m "message given from command line" | 205 $ hg commit --amend -v -m "message given from command line" |
200 amending changeset 5f357c7560ab | 206 amending changeset a9a13940fc03 |
201 copying changeset 5f357c7560ab to ad120869acf0 | 207 copying changeset a9a13940fc03 to ad120869acf0 |
202 committing files: | 208 committing files: |
203 a | 209 a |
204 committing manifest | 210 committing manifest |
205 committing changelog | 211 committing changelog |
206 running hook pretxncommit.test-saving-last-message: false | 212 running hook pretxncommit.test-saving-last-message: false |
211 $ cat .hg/last-message.txt | 217 $ cat .hg/last-message.txt |
212 message given from command line (no-eol) | 218 message given from command line (no-eol) |
213 | 219 |
214 $ rm -f .hg/last-message.txt | 220 $ rm -f .hg/last-message.txt |
215 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v | 221 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
216 amending changeset 5f357c7560ab | 222 amending changeset a9a13940fc03 |
217 copying changeset 5f357c7560ab to ad120869acf0 | 223 copying changeset a9a13940fc03 to ad120869acf0 |
218 no changes, new message | 224 no changes, new message |
219 | 225 |
220 | 226 |
221 HG: Enter commit message. Lines beginning with 'HG:' are removed. | 227 HG: Enter commit message. Lines beginning with 'HG:' are removed. |
222 HG: Leave message empty to abort commit. | 228 HG: Leave message empty to abort commit. |
243 > __EOF__ | 249 > __EOF__ |
244 | 250 |
245 then, test editing custom commit message | 251 then, test editing custom commit message |
246 | 252 |
247 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v | 253 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
248 amending changeset 5f357c7560ab | 254 amending changeset a9a13940fc03 |
249 copying changeset 5f357c7560ab to ad120869acf0 | 255 copying changeset a9a13940fc03 to ad120869acf0 |
250 no changes, new message | 256 no changes, new message |
251 | 257 |
252 | 258 |
253 HG: Enter commit message. Lines beginning with 'HG:' are removed. | 259 HG: Enter commit message. Lines beginning with 'HG:' are removed. |
254 HG: Leave message empty to abort commit. | 260 HG: Leave message empty to abort commit. |
262 committing changelog | 268 committing changelog |
263 1 changesets found | 269 1 changesets found |
264 uncompressed size of bundle content: | 270 uncompressed size of bundle content: |
265 249 (changelog) | 271 249 (changelog) |
266 163 (manifests) | 272 163 (manifests) |
267 131 a | 273 133 a |
268 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-e7c84ade-amend.hg (glob) | 274 saved backup bundle to $TESTTMP/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg (glob) |
269 1 changesets found | 275 1 changesets found |
270 uncompressed size of bundle content: | 276 uncompressed size of bundle content: |
271 257 (changelog) | 277 257 (changelog) |
272 163 (manifests) | 278 163 (manifests) |
273 131 a | 279 133 a |
274 adding branch | 280 adding branch |
275 adding changesets | 281 adding changesets |
276 adding manifests | 282 adding manifests |
277 adding file changes | 283 adding file changes |
278 added 1 changesets with 1 changes to 1 files | 284 added 1 changesets with 1 changes to 1 files |
279 committed changeset 1:7ab3bf440b54 | 285 committed changeset 1:64a124ba1b44 |
280 | 286 |
281 Same, but with changes in working dir (different code path): | 287 Same, but with changes in working dir (different code path): |
282 | 288 |
283 $ echo a >> a | 289 $ echo a >> a |
284 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v | 290 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
285 amending changeset 7ab3bf440b54 | 291 amending changeset 64a124ba1b44 |
286 committing files: | |
287 a | |
288 committing manifest | |
289 committing changelog | |
290 copying changeset a0ea9b1a4c8c to ad120869acf0 | |
291 another precious commit message | 292 another precious commit message |
292 | 293 |
293 | 294 |
294 HG: Enter commit message. Lines beginning with 'HG:' are removed. | 295 HG: Enter commit message. Lines beginning with 'HG:' are removed. |
295 HG: Leave message empty to abort commit. | 296 HG: Leave message empty to abort commit. |
299 HG: changed a | 300 HG: changed a |
300 committing files: | 301 committing files: |
301 a | 302 a |
302 committing manifest | 303 committing manifest |
303 committing changelog | 304 committing changelog |
304 2 changesets found | |
305 uncompressed size of bundle content: | |
306 464 (changelog) | |
307 322 (manifests) | |
308 249 a | |
309 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-8e3b5088-amend.hg (glob) | |
310 1 changesets found | 305 1 changesets found |
311 uncompressed size of bundle content: | 306 uncompressed size of bundle content: |
312 257 (changelog) | 307 257 (changelog) |
313 163 (manifests) | 308 163 (manifests) |
314 133 a | 309 133 a |
310 saved backup bundle to $TESTTMP/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg (glob) | |
311 1 changesets found | |
312 uncompressed size of bundle content: | |
313 257 (changelog) | |
314 163 (manifests) | |
315 135 a | |
315 adding branch | 316 adding branch |
316 adding changesets | 317 adding changesets |
317 adding manifests | 318 adding manifests |
318 adding file changes | 319 adding file changes |
319 added 1 changesets with 1 changes to 1 files | 320 added 1 changesets with 1 changes to 1 files |
320 committed changeset 1:ea22a388757c | 321 committed changeset 1:7892795b8e38 |
321 | 322 |
322 $ rm editor.sh | 323 $ rm editor.sh |
323 $ hg log -r . | 324 $ hg log -r . |
324 changeset: 1:ea22a388757c | 325 changeset: 1:7892795b8e38 |
325 tag: tip | 326 tag: tip |
326 user: foo | 327 user: foo |
327 date: Thu Jan 01 00:00:01 1970 +0000 | 328 date: Thu Jan 01 00:00:01 1970 +0000 |
328 summary: another precious commit message | 329 summary: another precious commit message |
329 | 330 |
331 Moving bookmarks, preserve active bookmark: | 332 Moving bookmarks, preserve active bookmark: |
332 | 333 |
333 $ hg book book1 | 334 $ hg book book1 |
334 $ hg book book2 | 335 $ hg book book2 |
335 $ hg ci --amend -m 'move bookmarks' | 336 $ hg ci --amend -m 'move bookmarks' |
336 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-e51094db-amend.hg (glob) | 337 saved backup bundle to $TESTTMP/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg (glob) |
337 $ hg book | 338 $ hg book |
338 book1 1:6cec5aa930e2 | 339 book1 1:8311f17e2616 |
339 * book2 1:6cec5aa930e2 | 340 * book2 1:8311f17e2616 |
340 $ echo a >> a | 341 $ echo a >> a |
341 $ hg ci --amend -m 'move bookmarks' | 342 $ hg ci --amend -m 'move bookmarks' |
342 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-e9b06de4-amend.hg (glob) | 343 saved backup bundle to $TESTTMP/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg (glob) |
343 $ hg book | 344 $ hg book |
344 book1 1:48bb6e53a15f | 345 book1 1:a3b65065808c |
345 * book2 1:48bb6e53a15f | 346 * book2 1:a3b65065808c |
346 | 347 |
347 abort does not loose bookmarks | 348 abort does not loose bookmarks |
348 | 349 |
349 $ cat > editor.sh << '__EOF__' | 350 $ cat > editor.sh << '__EOF__' |
350 > #!/bin/sh | 351 > #!/bin/sh |
351 > echo "" > "$1" | 352 > echo "" > "$1" |
352 > __EOF__ | 353 > __EOF__ |
353 $ echo a >> a | 354 $ echo a >> a |
354 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend | 355 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend |
355 transaction abort! | |
356 rollback completed | |
357 abort: empty commit message | 356 abort: empty commit message |
358 [255] | 357 [255] |
359 $ hg book | 358 $ hg book |
360 book1 1:48bb6e53a15f | 359 book1 1:a3b65065808c |
361 * book2 1:48bb6e53a15f | 360 * book2 1:a3b65065808c |
362 $ hg revert -Caq | 361 $ hg revert -Caq |
363 $ rm editor.sh | 362 $ rm editor.sh |
364 | 363 |
365 $ echo '[defaults]' >> $HGRCPATH | 364 $ echo '[defaults]' >> $HGRCPATH |
366 $ echo "commit=-d '0 0'" >> $HGRCPATH | 365 $ echo "commit=-d '0 0'" >> $HGRCPATH |
373 $ echo a >> a | 372 $ echo a >> a |
374 $ hg ci -m 'branch foo' | 373 $ hg ci -m 'branch foo' |
375 $ hg branch default -f | 374 $ hg branch default -f |
376 marked working directory as branch default | 375 marked working directory as branch default |
377 $ hg ci --amend -m 'back to default' | 376 $ hg ci --amend -m 'back to default' |
378 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-fd962fef-amend.hg (glob) | 377 saved backup bundle to $TESTTMP/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg (glob) |
379 $ hg branches | 378 $ hg branches |
380 default 2:ce12b0b57d46 | 379 default 2:9c07515f2650 |
381 | 380 |
382 Close branch: | 381 Close branch: |
383 | 382 |
384 $ hg up -q 0 | 383 $ hg up -q 0 |
385 $ echo b >> b | 384 $ echo b >> b |
389 $ hg ci -Am 'fork' | 388 $ hg ci -Am 'fork' |
390 adding b | 389 adding b |
391 $ echo b >> b | 390 $ echo b >> b |
392 $ hg ci -mb | 391 $ hg ci -mb |
393 $ hg ci --amend --close-branch -m 'closing branch foo' | 392 $ hg ci --amend --close-branch -m 'closing branch foo' |
394 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-6701c392-amend.hg (glob) | 393 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-54245dc7-amend.hg (glob) |
395 | 394 |
396 Same thing, different code path: | 395 Same thing, different code path: |
397 | 396 |
398 $ echo b >> b | 397 $ echo b >> b |
399 $ hg ci -m 'reopen branch' | 398 $ hg ci -m 'reopen branch' |
400 reopening closed branch head 4 | 399 reopening closed branch head 4 |
401 $ echo b >> b | 400 $ echo b >> b |
402 $ hg ci --amend --close-branch | 401 $ hg ci --amend --close-branch |
403 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-49c0c55d-amend.hg (glob) | 402 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-b900d9fa-amend.hg (glob) |
404 $ hg branches | 403 $ hg branches |
405 default 2:ce12b0b57d46 | 404 default 2:9c07515f2650 |
406 | 405 |
407 Refuse to amend during a merge: | 406 Refuse to amend during a merge: |
408 | 407 |
409 $ hg up -q default | 408 $ hg up -q default |
410 $ hg merge foo | 409 $ hg merge foo |
419 | 418 |
420 $ hg mv b c | 419 $ hg mv b c |
421 $ hg ci -m 'b -> c' | 420 $ hg ci -m 'b -> c' |
422 $ hg mv c d | 421 $ hg mv c d |
423 $ hg ci --amend -m 'b -> d' | 422 $ hg ci --amend -m 'b -> d' |
424 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-adaaa8b1-amend.hg (glob) | 423 saved backup bundle to $TESTTMP/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg (glob) |
425 $ hg st --rev '.^' --copies d | 424 $ hg st --rev '.^' --copies d |
426 A d | 425 A d |
427 b | 426 b |
428 $ hg cp d e | 427 $ hg cp d e |
429 $ hg ci -m 'e = d' | 428 $ hg ci -m 'e = d' |
430 $ hg cp e f | 429 $ hg cp e f |
431 $ hg ci --amend -m 'f = d' | 430 $ hg ci --amend -m 'f = d' |
432 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-d37aa788-amend.hg (glob) | 431 saved backup bundle to $TESTTMP/.hg/strip-backup/9198f73182d5-251d584a-amend.hg (glob) |
433 $ hg st --rev '.^' --copies f | 432 $ hg st --rev '.^' --copies f |
434 A f | 433 A f |
435 d | 434 d |
436 | 435 |
437 $ mv f f.orig | 436 $ mv f f.orig |
438 $ hg rm -A f | 437 $ hg rm -A f |
439 $ hg ci -m removef | 438 $ hg ci -m removef |
440 $ hg cp a f | 439 $ hg cp a f |
441 $ mv f.orig f | 440 $ mv f.orig f |
442 $ hg ci --amend -m replacef | 441 $ hg ci --amend -m replacef |
443 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-90259f67-amend.hg (glob) | 442 saved backup bundle to $TESTTMP/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg (glob) |
444 $ hg st --change . --copies | 443 $ hg st --change . --copies |
445 $ hg log -r . --template "{file_copies}\n" | 444 $ hg log -r . --template "{file_copies}\n" |
446 | 445 |
447 | 446 |
448 Move added file (issue3410): | 447 Move added file (issue3410): |
450 $ echo g >> g | 449 $ echo g >> g |
451 $ hg ci -Am g | 450 $ hg ci -Am g |
452 adding g | 451 adding g |
453 $ hg mv g h | 452 $ hg mv g h |
454 $ hg ci --amend | 453 $ hg ci --amend |
455 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-7059e0f1-amend.hg (glob) | 454 saved backup bundle to $TESTTMP/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg (glob) |
456 $ hg st --change . --copies h | 455 $ hg st --change . --copies h |
457 A h | 456 A h |
458 $ hg log -r . --template "{file_copies}\n" | 457 $ hg log -r . --template "{file_copies}\n" |
459 | 458 |
460 | 459 |
470 marked working directory as branch a | 469 marked working directory as branch a |
471 (branches are permanent and global, did you want a bookmark?) | 470 (branches are permanent and global, did you want a bookmark?) |
472 $ echo a >> a | 471 $ echo a >> a |
473 $ hg ci -ma | 472 $ hg ci -ma |
474 $ hg ci --amend -m "a'" | 473 $ hg ci --amend -m "a'" |
475 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-2be01fd1-amend.hg (glob) | 474 saved backup bundle to $TESTTMP/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg (glob) |
476 $ hg log -r . --template "{branch}\n" | 475 $ hg log -r . --template "{branch}\n" |
477 a | 476 a |
478 $ hg ci --amend -m "a''" | 477 $ hg ci --amend -m "a''" |
479 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-ed28c4cd-amend.hg (glob) | 478 saved backup bundle to $TESTTMP/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg (glob) |
480 $ hg log -r . --template "{branch}\n" | 479 $ hg log -r . --template "{branch}\n" |
481 a | 480 a |
482 | 481 |
483 Also preserve other entries in the dict that are in the old commit, | 482 Also preserve other entries in the dict that are in the old commit, |
484 first graft something so there's an additional entry: | 483 first graft something so there's an additional entry: |
491 $ hg up 11 | 490 $ hg up 11 |
492 5 files updated, 0 files merged, 1 files removed, 0 files unresolved | 491 5 files updated, 0 files merged, 1 files removed, 0 files unresolved |
493 $ hg graft 12 | 492 $ hg graft 12 |
494 grafting 12:2647734878ef "fork" (tip) | 493 grafting 12:2647734878ef "fork" (tip) |
495 $ hg ci --amend -m 'graft amend' | 494 $ hg ci --amend -m 'graft amend' |
496 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-eedb103b-amend.hg (glob) | 495 saved backup bundle to $TESTTMP/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg (glob) |
497 $ hg log -r . --debug | grep extra | 496 $ hg log -r . --debug | grep extra |
498 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e | 497 extra: amend_source=fe8c6f7957ca1665ed77496ed7a07657d469ac60 |
499 extra: branch=a | 498 extra: branch=a |
500 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a | 499 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a |
501 | 500 |
502 Preserve phase | 501 Preserve phase |
503 | 502 |
529 13 | 528 13 |
530 $ hg ci --amend -m 'babar' | 529 $ hg ci --amend -m 'babar' |
531 $ hg id -n | 530 $ hg id -n |
532 14 | 531 14 |
533 $ hg log -Gl 3 --style=compact | 532 $ hg log -Gl 3 --style=compact |
534 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test | 533 @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test |
535 | babar | 534 | babar |
536 | | 535 | |
537 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test | 536 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
538 | | fork | 537 | | fork |
539 | ~ | 538 | ~ |
540 o 11 3334b7925910 1970-01-01 00:00 +0000 test | 539 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test |
541 | a'' | 540 | a'' |
542 ~ | 541 ~ |
543 $ hg log -Gl 4 --hidden --style=compact | 542 $ hg log -Gl 4 --hidden --style=compact |
544 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test | 543 @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test |
545 | babar | 544 | babar |
546 | | 545 | |
547 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test | 546 | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test |
548 |/ amend for phase | 547 |/ amend for phase |
549 | | 548 | |
550 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test | 549 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
551 | | fork | 550 | | fork |
552 | ~ | 551 | ~ |
553 o 11 3334b7925910 1970-01-01 00:00 +0000 test | 552 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test |
554 | a'' | 553 | a'' |
555 ~ | 554 ~ |
556 | 555 |
557 Amend with files changes | 556 Amend with files changes |
558 | 557 |
560 ride of) | 559 ride of) |
561 | 560 |
562 $ echo 'babar' >> a | 561 $ echo 'babar' >> a |
563 $ hg commit --amend | 562 $ hg commit --amend |
564 $ hg log -Gl 6 --hidden --style=compact | 563 $ hg log -Gl 6 --hidden --style=compact |
565 @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test | 564 @ 15[tip]:11 a5b42b49b0d5 1970-01-01 00:00 +0000 test |
566 | babar | 565 | babar |
567 | | 566 | |
568 | x 15 90fef497c56f 1970-01-01 00:00 +0000 test | 567 | x 14:11 682950e85999 1970-01-01 00:00 +0000 test |
569 | | temporary amend commit for b650e6ee8614 | |
570 | | | |
571 | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test | |
572 |/ babar | 568 |/ babar |
573 | | 569 | |
574 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test | 570 | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test |
575 |/ amend for phase | 571 |/ amend for phase |
576 | | 572 | |
577 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test | 573 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
578 | | fork | 574 | | fork |
579 | ~ | 575 | ~ |
580 o 11 3334b7925910 1970-01-01 00:00 +0000 test | 576 o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test |
581 | a'' | 577 | a'' |
578 | | |
579 o 10 5fa75032e226 1970-01-01 00:00 +0000 test | |
580 | g | |
582 ~ | 581 ~ |
583 | 582 |
584 | 583 |
585 Test that amend does not make it easy to create obsolescence cycle | 584 Test that amend does not make it easy to create obsolescence cycle |
586 --------------------------------------------------------------------- | 585 --------------------------------------------------------------------- |
587 | 586 |
588 $ hg id -r 14 --hidden | 587 $ hg id -r 14 --hidden |
589 b650e6ee8614 (a) | 588 682950e85999 (a) |
590 $ hg revert -ar 14 --hidden | 589 $ hg revert -ar 14 --hidden |
591 reverting a | 590 reverting a |
592 $ hg commit --amend | 591 $ hg commit --amend |
593 $ hg id | 592 $ hg id |
594 b99e5df575f7 (a) tip | 593 37973c7e0b61 (a) tip |
595 | 594 |
596 Test that rewriting leaving instability behind is allowed | 595 Test that rewriting leaving instability behind is allowed |
597 --------------------------------------------------------------------- | 596 --------------------------------------------------------------------- |
598 | 597 |
599 $ hg up '.^' | 598 $ hg up '.^' |
600 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | 599 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
601 $ echo 'b' >> a | 600 $ echo 'b' >> a |
602 $ hg log --style compact -r 'children(.)' | 601 $ hg log --style compact -r 'children(.)' |
603 18[tip]:11 b99e5df575f7 1970-01-01 00:00 +0000 test | 602 16[tip]:11 37973c7e0b61 1970-01-01 00:00 +0000 test |
604 babar | 603 babar |
605 | 604 |
606 $ hg commit --amend | 605 $ hg commit --amend |
607 $ hg log -r 'orphan()' | 606 $ hg log -r 'orphan()' |
608 changeset: 18:b99e5df575f7 | 607 changeset: 16:37973c7e0b61 |
609 branch: a | 608 branch: a |
610 parent: 11:3334b7925910 | 609 parent: 11:0ddb275cfad1 |
611 user: test | 610 user: test |
612 date: Thu Jan 01 00:00:00 1970 +0000 | 611 date: Thu Jan 01 00:00:00 1970 +0000 |
613 instability: orphan | 612 instability: orphan |
614 summary: babar | 613 summary: babar |
615 | 614 |
633 [1] | 632 [1] |
634 $ hg resolve -m cc | 633 $ hg resolve -m cc |
635 (no more unresolved files) | 634 (no more unresolved files) |
636 $ hg ci -m 'merge bar' | 635 $ hg ci -m 'merge bar' |
637 $ hg log --config diff.git=1 -pr . | 636 $ hg log --config diff.git=1 -pr . |
638 changeset: 23:163cfd7219f7 | 637 changeset: 20:163cfd7219f7 |
639 tag: tip | 638 tag: tip |
640 parent: 22:30d96aeaf27b | 639 parent: 19:30d96aeaf27b |
641 parent: 21:1aa437659d19 | 640 parent: 18:1aa437659d19 |
642 user: test | 641 user: test |
643 date: Thu Jan 01 00:00:00 1970 +0000 | 642 date: Thu Jan 01 00:00:00 1970 +0000 |
644 summary: merge bar | 643 summary: merge bar |
645 | 644 |
646 diff --git a/a b/aa | 645 diff --git a/a b/aa |
666 $ hg debugrename cc | 665 $ hg debugrename cc |
667 cc not renamed | 666 cc not renamed |
668 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit | 667 $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit |
669 HGEDITFORM=commit.amend.merge | 668 HGEDITFORM=commit.amend.merge |
670 $ hg log --config diff.git=1 -pr . | 669 $ hg log --config diff.git=1 -pr . |
671 changeset: 24:bca52d4ed186 | 670 changeset: 21:bca52d4ed186 |
672 tag: tip | 671 tag: tip |
673 parent: 22:30d96aeaf27b | 672 parent: 19:30d96aeaf27b |
674 parent: 21:1aa437659d19 | 673 parent: 18:1aa437659d19 |
675 user: test | 674 user: test |
676 date: Thu Jan 01 00:00:00 1970 +0000 | 675 date: Thu Jan 01 00:00:00 1970 +0000 |
677 summary: merge bar (amend message) | 676 summary: merge bar (amend message) |
678 | 677 |
679 diff --git a/a b/aa | 678 diff --git a/a b/aa |
699 $ hg debugrename cc | 698 $ hg debugrename cc |
700 cc not renamed | 699 cc not renamed |
701 $ hg mv zz z | 700 $ hg mv zz z |
702 $ hg ci --amend -m 'merge bar (undo rename)' | 701 $ hg ci --amend -m 'merge bar (undo rename)' |
703 $ hg log --config diff.git=1 -pr . | 702 $ hg log --config diff.git=1 -pr . |
704 changeset: 26:12594a98ca3f | 703 changeset: 22:12594a98ca3f |
705 tag: tip | 704 tag: tip |
706 parent: 22:30d96aeaf27b | 705 parent: 19:30d96aeaf27b |
707 parent: 21:1aa437659d19 | 706 parent: 18:1aa437659d19 |
708 user: test | 707 user: test |
709 date: Thu Jan 01 00:00:00 1970 +0000 | 708 date: Thu Jan 01 00:00:00 1970 +0000 |
710 summary: merge bar (undo rename) | 709 summary: merge bar (undo rename) |
711 | 710 |
712 diff --git a/a b/aa | 711 diff --git a/a b/aa |
735 $ hg merge -q bar | 734 $ hg merge -q bar |
736 $ hg mv aa aaa | 735 $ hg mv aa aaa |
737 $ echo aa >> aaa | 736 $ echo aa >> aaa |
738 $ hg ci -m 'merge bar again' | 737 $ hg ci -m 'merge bar again' |
739 $ hg log --config diff.git=1 -pr . | 738 $ hg log --config diff.git=1 -pr . |
740 changeset: 28:dffde028b388 | 739 changeset: 24:dffde028b388 |
741 tag: tip | 740 tag: tip |
742 parent: 26:12594a98ca3f | 741 parent: 22:12594a98ca3f |
743 parent: 27:4c94d5bc65f5 | 742 parent: 23:4c94d5bc65f5 |
744 user: test | 743 user: test |
745 date: Thu Jan 01 00:00:00 1970 +0000 | 744 date: Thu Jan 01 00:00:00 1970 +0000 |
746 summary: merge bar again | 745 summary: merge bar again |
747 | 746 |
748 diff --git a/aa b/aa | 747 diff --git a/aa b/aa |
770 $ hg debugrename aaa | 769 $ hg debugrename aaa |
771 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980 | 770 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980 |
772 $ hg mv aaa aa | 771 $ hg mv aaa aa |
773 $ hg ci --amend -m 'merge bar again (undo rename)' | 772 $ hg ci --amend -m 'merge bar again (undo rename)' |
774 $ hg log --config diff.git=1 -pr . | 773 $ hg log --config diff.git=1 -pr . |
775 changeset: 30:18e3ba160489 | 774 changeset: 25:18e3ba160489 |
776 tag: tip | 775 tag: tip |
777 parent: 26:12594a98ca3f | 776 parent: 22:12594a98ca3f |
778 parent: 27:4c94d5bc65f5 | 777 parent: 23:4c94d5bc65f5 |
779 user: test | 778 user: test |
780 date: Thu Jan 01 00:00:00 1970 +0000 | 779 date: Thu Jan 01 00:00:00 1970 +0000 |
781 summary: merge bar again (undo rename) | 780 summary: merge bar again (undo rename) |
782 | 781 |
783 diff --git a/aa b/aa | 782 diff --git a/aa b/aa |
812 > EOF | 811 > EOF |
813 local [working copy] changed aa which other [merge rev] deleted | 812 local [working copy] changed aa which other [merge rev] deleted |
814 use (c)hanged version, (d)elete, or leave (u)nresolved? c | 813 use (c)hanged version, (d)elete, or leave (u)nresolved? c |
815 $ hg ci -m 'merge bar (with conflicts)' | 814 $ hg ci -m 'merge bar (with conflicts)' |
816 $ hg log --config diff.git=1 -pr . | 815 $ hg log --config diff.git=1 -pr . |
817 changeset: 33:b4c3035e2544 | 816 changeset: 28:b4c3035e2544 |
818 tag: tip | 817 tag: tip |
819 parent: 32:4b216ca5ba97 | 818 parent: 27:4b216ca5ba97 |
820 parent: 31:67db8847a540 | 819 parent: 26:67db8847a540 |
821 user: test | 820 user: test |
822 date: Thu Jan 01 00:00:00 1970 +0000 | 821 date: Thu Jan 01 00:00:00 1970 +0000 |
823 summary: merge bar (with conflicts) | 822 summary: merge bar (with conflicts) |
824 | 823 |
825 | 824 |
826 $ hg rm aa | 825 $ hg rm aa |
827 $ hg ci --amend -m 'merge bar (with conflicts, amended)' | 826 $ hg ci --amend -m 'merge bar (with conflicts, amended)' |
828 $ hg log --config diff.git=1 -pr . | 827 $ hg log --config diff.git=1 -pr . |
829 changeset: 35:1205ed810051 | 828 changeset: 29:1205ed810051 |
830 tag: tip | 829 tag: tip |
831 parent: 32:4b216ca5ba97 | 830 parent: 27:4b216ca5ba97 |
832 parent: 31:67db8847a540 | 831 parent: 26:67db8847a540 |
833 user: test | 832 user: test |
834 date: Thu Jan 01 00:00:00 1970 +0000 | 833 date: Thu Jan 01 00:00:00 1970 +0000 |
835 summary: merge bar (with conflicts, amended) | 834 summary: merge bar (with conflicts, amended) |
836 | 835 |
837 diff --git a/aa b/aa | 836 diff --git a/aa b/aa |
868 | 867 |
869 Test that amend with --secret creates new secret changeset forcibly | 868 Test that amend with --secret creates new secret changeset forcibly |
870 --------------------------------------------------------------------- | 869 --------------------------------------------------------------------- |
871 | 870 |
872 $ hg phase '.^::.' | 871 $ hg phase '.^::.' |
873 35: draft | 872 29: draft |
874 36: draft | 873 30: draft |
875 $ hg commit --amend --secret -m 'amend as secret' -q | 874 $ hg commit --amend --secret -m 'amend as secret' -q |
876 $ hg phase '.^::.' | 875 $ hg phase '.^::.' |
877 35: draft | 876 29: draft |
878 38: secret | 877 31: secret |
879 | 878 |
880 Test that amend with --edit invokes editor forcibly | 879 Test that amend with --edit invokes editor forcibly |
881 --------------------------------------------------- | 880 --------------------------------------------------- |
882 | 881 |
883 $ hg parents --template "{desc}\n" | 882 $ hg parents --template "{desc}\n" |
1063 | o 1 a1 | 1062 | o 1 a1 |
1064 |/ | 1063 |/ |
1065 o 0 a0 | 1064 o 0 a0 |
1066 | 1065 |
1067 | 1066 |
1068 The way mercurial does amends is to create a temporary commit (rev 3) and then | 1067 The way mercurial does amends is by folding the working copy and old commit |
1069 fold the new and old commits together into another commit (rev 4). During this | 1068 together into another commit (rev 3). During this process, _findlimit is called |
1070 process, _findlimit is called to check how far back to look for the transitive | 1069 to check how far back to look for the transitive closure of file copy |
1071 closure of file copy information, but due to the divergence of the filelog | 1070 information, but due to the divergence of the filelog and changelog graph |
1072 and changelog graph topologies, before _findlimit was fixed, it returned a rev | 1071 topologies, before _findlimit was fixed, it returned a rev which was not far |
1073 which was not far enough back in this case. | 1072 enough back in this case. |
1074 $ hg mv a1 a2 | 1073 $ hg mv a1 a2 |
1075 $ hg status --copies --rev 0 | 1074 $ hg status --copies --rev 0 |
1076 A a2 | 1075 A a2 |
1077 a0 | 1076 a0 |
1078 R a0 | 1077 R a0 |
1079 $ hg ci --amend -q | 1078 $ hg ci --amend -q |
1080 $ hg log -G --template '{rev} {desc}' | 1079 $ hg log -G --template '{rev} {desc}' |
1081 @ 4 a1-amend | 1080 @ 3 a1-amend |
1082 | | 1081 | |
1083 | o 1 a1 | 1082 | o 1 a1 |
1084 |/ | 1083 |/ |
1085 o 0 a0 | 1084 o 0 a0 |
1086 | 1085 |
1159 $ chmod +x newdirname/commonfile.py | 1158 $ chmod +x newdirname/commonfile.py |
1160 $ hg ci -m chmod | 1159 $ hg ci -m chmod |
1161 $ hg ci --amend -m "chmod amended" | 1160 $ hg ci --amend -m "chmod amended" |
1162 $ hg ci --amend -m "chmod amended second time" | 1161 $ hg ci --amend -m "chmod amended second time" |
1163 $ hg log -p --git -r . | 1162 $ hg log -p --git -r . |
1164 changeset: 8:b1326f52dddf | 1163 changeset: 7:b1326f52dddf |
1165 branch: newdirname | 1164 branch: newdirname |
1166 tag: tip | 1165 tag: tip |
1167 parent: 5:7fd235f7cb2f | 1166 parent: 4:7fd235f7cb2f |
1168 user: test | 1167 user: test |
1169 date: Thu Jan 01 00:00:00 1970 +0000 | 1168 date: Thu Jan 01 00:00:00 1970 +0000 |
1170 summary: chmod amended second time | 1169 summary: chmod amended second time |
1171 | 1170 |
1172 diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py | 1171 diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py |