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