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