Show More
@@ -11,6 +11,7 b' import os, sys, errno, re, tempfile' | |||
|
11 | 11 | import util, scmutil, templater, patch, error, templatekw, revlog, copies |
|
12 | 12 | import match as matchmod |
|
13 | 13 | import subrepo, context, repair, bookmarks, graphmod, revset, phases, obsolete |
|
14 | import changelog | |
|
14 | 15 | import lock as lockmod |
|
15 | 16 | |
|
16 | 17 | def parsealiases(cmd): |
@@ -1696,6 +1697,9 b' def amend(ui, repo, commitfunc, old, ext' | |||
|
1696 | 1697 | if not message: |
|
1697 | 1698 | message = old.description() |
|
1698 | 1699 | |
|
1700 | pureextra = extra.copy() | |
|
1701 | extra['amend_source'] = old.hex() | |
|
1702 | ||
|
1699 | 1703 | new = context.memctx(repo, |
|
1700 | 1704 | parents=[base.node(), nullid], |
|
1701 | 1705 | text=message, |
@@ -1705,6 +1709,19 b' def amend(ui, repo, commitfunc, old, ext' | |||
|
1705 | 1709 | date=date, |
|
1706 | 1710 | extra=extra) |
|
1707 | 1711 | new._text = commitforceeditor(repo, new, []) |
|
1712 | ||
|
1713 | newdesc = changelog.stripdesc(new.description()) | |
|
1714 | if ((not node) | |
|
1715 | and newdesc == old.description() | |
|
1716 | and user == old.user() | |
|
1717 | and date == old.date() | |
|
1718 | and pureextra == old.extra()): | |
|
1719 | # nothing changed. continuing here would create a new node | |
|
1720 | # anyway because of the amend_source noise. | |
|
1721 | # | |
|
1722 | # This not what we expect from amend. | |
|
1723 | return old.node() | |
|
1724 | ||
|
1708 | 1725 | ph = repo.ui.config('phases', 'new-commit', phases.draft) |
|
1709 | 1726 | try: |
|
1710 | 1727 | repo.ui.setconfig('phases', 'new-commit', old.phase()) |
@@ -32,12 +32,12 b' Amending changeset with changes in worki' | |||
|
32 | 32 | |
|
33 | 33 | $ echo a >> a |
|
34 | 34 | $ hg ci --amend -m 'amend base1' |
|
35 | pretxncommit 9cd25b479c51be2f4ed2c38e7abdf7ce67d8e0dc | |
|
36 | 9cd25b479c51 tip | |
|
35 | pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 | |
|
36 | 43f1ba15f28a tip | |
|
37 | 37 | saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg (glob) |
|
38 | 38 | $ echo 'pretxncommit.foo = ' >> $HGRCPATH |
|
39 | 39 | $ hg diff -c . |
|
40 |
diff -r ad120869acf0 -r |
|
|
40 | diff -r ad120869acf0 -r 43f1ba15f28a a | |
|
41 | 41 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
42 | 42 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
43 | 43 | @@ -1,1 +1,3 @@ |
@@ -45,7 +45,7 b' Amending changeset with changes in worki' | |||
|
45 | 45 | +a |
|
46 | 46 | +a |
|
47 | 47 | $ hg log |
|
48 |
changeset: 1: |
|
|
48 | changeset: 1:43f1ba15f28a | |
|
49 | 49 | tag: tip |
|
50 | 50 | user: test |
|
51 | 51 | date: Thu Jan 01 00:00:00 1970 +0000 |
@@ -62,36 +62,36 b' Add new file:' | |||
|
62 | 62 | $ echo b > b |
|
63 | 63 | $ hg ci --amend -Am 'amend base1 new file' |
|
64 | 64 | adding b |
|
65 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
65 | saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-amend-backup.hg (glob) | |
|
66 | 66 | |
|
67 | 67 | Remove file that was added in amended commit: |
|
68 | 68 | |
|
69 | 69 | $ hg rm b |
|
70 | 70 | $ hg ci --amend -m 'amend base1 remove new file' |
|
71 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
71 | saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-amend-backup.hg (glob) | |
|
72 | 72 | |
|
73 | 73 | $ hg cat b |
|
74 |
b: no such file in rev |
|
|
74 | b: no such file in rev 74609c7f506e | |
|
75 | 75 | [1] |
|
76 | 76 | |
|
77 | 77 | No changes, just a different message: |
|
78 | 78 | |
|
79 | 79 | $ hg ci -v --amend -m 'no changes, new message' |
|
80 |
amending changeset |
|
|
81 |
copying changeset |
|
|
80 | amending changeset 74609c7f506e | |
|
81 | copying changeset 74609c7f506e to ad120869acf0 | |
|
82 | 82 | a |
|
83 |
stripping amended changeset |
|
|
83 | stripping amended changeset 74609c7f506e | |
|
84 | 84 | 1 changesets found |
|
85 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
85 | saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-amend-backup.hg (glob) | |
|
86 | 86 | 1 changesets found |
|
87 | 87 | adding branch |
|
88 | 88 | adding changesets |
|
89 | 89 | adding manifests |
|
90 | 90 | adding file changes |
|
91 | 91 | added 1 changesets with 1 changes to 1 files |
|
92 |
committed changeset 1: |
|
|
92 | committed changeset 1:1cd866679df8 | |
|
93 | 93 | $ hg diff -c . |
|
94 |
diff -r ad120869acf0 -r |
|
|
94 | diff -r ad120869acf0 -r 1cd866679df8 a | |
|
95 | 95 | --- a/a Thu Jan 01 00:00:00 1970 +0000 |
|
96 | 96 | +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
97 | 97 | @@ -1,1 +1,3 @@ |
@@ -99,7 +99,7 b' No changes, just a different message:' | |||
|
99 | 99 | +a |
|
100 | 100 | +a |
|
101 | 101 | $ hg log |
|
102 |
changeset: 1: |
|
|
102 | changeset: 1:1cd866679df8 | |
|
103 | 103 | tag: tip |
|
104 | 104 | user: test |
|
105 | 105 | date: Thu Jan 01 00:00:00 1970 +0000 |
@@ -119,12 +119,12 b' Disable default date on commit so when -' | |||
|
119 | 119 | Test -u/-d: |
|
120 | 120 | |
|
121 | 121 | $ hg ci --amend -u foo -d '1 0' |
|
122 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
122 | saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-amend-backup.hg (glob) | |
|
123 | 123 | $ echo a >> a |
|
124 | 124 | $ hg ci --amend -u foo -d '1 0' |
|
125 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
125 | saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-amend-backup.hg (glob) | |
|
126 | 126 | $ hg log -r . |
|
127 |
changeset: 1: |
|
|
127 | changeset: 1:5f357c7560ab | |
|
128 | 128 | tag: tip |
|
129 | 129 | user: foo |
|
130 | 130 | date: Thu Jan 01 00:00:01 1970 +0000 |
@@ -139,8 +139,8 b' Open editor with old commit message if a' | |||
|
139 | 139 | > echo "another precious commit message" > "$1" |
|
140 | 140 | > __EOF__ |
|
141 | 141 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
|
142 |
amending changeset |
|
|
143 |
copying changeset |
|
|
142 | amending changeset 5f357c7560ab | |
|
143 | copying changeset 5f357c7560ab to ad120869acf0 | |
|
144 | 144 | no changes, new message |
|
145 | 145 | |
|
146 | 146 | |
@@ -151,24 +151,24 b' Open editor with old commit message if a' | |||
|
151 | 151 | HG: branch 'default' |
|
152 | 152 | HG: changed a |
|
153 | 153 | a |
|
154 |
stripping amended changeset |
|
|
154 | stripping amended changeset 5f357c7560ab | |
|
155 | 155 | 1 changesets found |
|
156 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
156 | saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-amend-backup.hg (glob) | |
|
157 | 157 | 1 changesets found |
|
158 | 158 | adding branch |
|
159 | 159 | adding changesets |
|
160 | 160 | adding manifests |
|
161 | 161 | adding file changes |
|
162 | 162 | added 1 changesets with 1 changes to 1 files |
|
163 |
committed changeset 1: |
|
|
163 | committed changeset 1:7ab3bf440b54 | |
|
164 | 164 | |
|
165 | 165 | Same, but with changes in working dir (different code path): |
|
166 | 166 | |
|
167 | 167 | $ echo a >> a |
|
168 | 168 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v |
|
169 |
amending changeset |
|
|
169 | amending changeset 7ab3bf440b54 | |
|
170 | 170 | a |
|
171 |
copying changeset a |
|
|
171 | copying changeset a0ea9b1a4c8c to ad120869acf0 | |
|
172 | 172 | another precious commit message |
|
173 | 173 | |
|
174 | 174 | |
@@ -179,21 +179,21 b' Same, but with changes in working dir (d' | |||
|
179 | 179 | HG: branch 'default' |
|
180 | 180 | HG: changed a |
|
181 | 181 | a |
|
182 |
stripping intermediate changeset a |
|
|
183 |
stripping amended changeset |
|
|
182 | stripping intermediate changeset a0ea9b1a4c8c | |
|
183 | stripping amended changeset 7ab3bf440b54 | |
|
184 | 184 | 2 changesets found |
|
185 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
185 | saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-amend-backup.hg (glob) | |
|
186 | 186 | 1 changesets found |
|
187 | 187 | adding branch |
|
188 | 188 | adding changesets |
|
189 | 189 | adding manifests |
|
190 | 190 | adding file changes |
|
191 | 191 | added 1 changesets with 1 changes to 1 files |
|
192 |
committed changeset 1: |
|
|
192 | committed changeset 1:ea22a388757c | |
|
193 | 193 | |
|
194 | 194 | $ rm editor.sh |
|
195 | 195 | $ hg log -r . |
|
196 |
changeset: 1: |
|
|
196 | changeset: 1:ea22a388757c | |
|
197 | 197 | tag: tip |
|
198 | 198 | user: foo |
|
199 | 199 | date: Thu Jan 01 00:00:01 1970 +0000 |
@@ -205,16 +205,16 b' Moving bookmarks, preserve active bookma' | |||
|
205 | 205 | $ hg book book1 |
|
206 | 206 | $ hg book book2 |
|
207 | 207 | $ hg ci --amend -m 'move bookmarks' |
|
208 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
208 | saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-amend-backup.hg (glob) | |
|
209 | 209 | $ hg book |
|
210 |
book1 1: |
|
|
211 |
* book2 1: |
|
|
210 | book1 1:6cec5aa930e2 | |
|
211 | * book2 1:6cec5aa930e2 | |
|
212 | 212 | $ echo a >> a |
|
213 | 213 | $ hg ci --amend -m 'move bookmarks' |
|
214 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
214 | saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-amend-backup.hg (glob) | |
|
215 | 215 | $ hg book |
|
216 |
book1 1: |
|
|
217 |
* book2 1: |
|
|
216 | book1 1:48bb6e53a15f | |
|
217 | * book2 1:48bb6e53a15f | |
|
218 | 218 | |
|
219 | 219 | $ echo '[defaults]' >> $HGRCPATH |
|
220 | 220 | $ echo "commit=-d '0 0'" >> $HGRCPATH |
@@ -230,9 +230,9 b' Moving branches:' | |||
|
230 | 230 | marked working directory as branch default |
|
231 | 231 | (branches are permanent and global, did you want a bookmark?) |
|
232 | 232 | $ hg ci --amend -m 'back to default' |
|
233 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
233 | saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-amend-backup.hg (glob) | |
|
234 | 234 | $ hg branches |
|
235 |
default 2: |
|
|
235 | default 2:ce12b0b57d46 | |
|
236 | 236 | |
|
237 | 237 | Close branch: |
|
238 | 238 | |
@@ -255,9 +255,9 b' Same thing, different code path:' | |||
|
255 | 255 | reopening closed branch head 4 |
|
256 | 256 | $ echo b >> b |
|
257 | 257 | $ hg ci --amend --close-branch |
|
258 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
258 | saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-amend-backup.hg (glob) | |
|
259 | 259 | $ hg branches |
|
260 |
default 2: |
|
|
260 | default 2:ce12b0b57d46 | |
|
261 | 261 | |
|
262 | 262 | Refuse to amend merges: |
|
263 | 263 | |
@@ -279,7 +279,7 b' Follow copies/renames:' | |||
|
279 | 279 | $ hg ci -m 'b -> c' |
|
280 | 280 | $ hg mv c d |
|
281 | 281 | $ hg ci --amend -m 'b -> d' |
|
282 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
282 | saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-amend-backup.hg (glob) | |
|
283 | 283 | $ hg st --rev '.^' --copies d |
|
284 | 284 | A d |
|
285 | 285 | b |
@@ -287,7 +287,7 b' Follow copies/renames:' | |||
|
287 | 287 | $ hg ci -m 'e = d' |
|
288 | 288 | $ hg cp e f |
|
289 | 289 | $ hg ci --amend -m 'f = d' |
|
290 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
290 | saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-amend-backup.hg (glob) | |
|
291 | 291 | $ hg st --rev '.^' --copies f |
|
292 | 292 | A f |
|
293 | 293 | d |
@@ -298,7 +298,7 b' Follow copies/renames:' | |||
|
298 | 298 | $ hg cp a f |
|
299 | 299 | $ mv f.orig f |
|
300 | 300 | $ hg ci --amend -m replacef |
|
301 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
301 | saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-amend-backup.hg (glob) | |
|
302 | 302 | $ hg st --change . --copies |
|
303 | 303 | $ hg log -r . --template "{file_copies}\n" |
|
304 | 304 | |
@@ -310,7 +310,7 b' Move added file (issue3410):' | |||
|
310 | 310 | adding g |
|
311 | 311 | $ hg mv g h |
|
312 | 312 | $ hg ci --amend |
|
313 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
313 | saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-amend-backup.hg (glob) | |
|
314 | 314 | $ hg st --change . --copies h |
|
315 | 315 | A h |
|
316 | 316 | $ hg log -r . --template "{file_copies}\n" |
@@ -330,11 +330,11 b' Preserve extra dict (issue3430):' | |||
|
330 | 330 | $ echo a >> a |
|
331 | 331 | $ hg ci -ma |
|
332 | 332 | $ hg ci --amend -m "a'" |
|
333 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
333 | saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-amend-backup.hg (glob) | |
|
334 | 334 | $ hg log -r . --template "{branch}\n" |
|
335 | 335 | a |
|
336 | 336 | $ hg ci --amend -m "a''" |
|
337 |
saved backup bundle to $TESTTMP/.hg/strip-backup/c |
|
|
337 | saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-amend-backup.hg (glob) | |
|
338 | 338 | $ hg log -r . --template "{branch}\n" |
|
339 | 339 | a |
|
340 | 340 | |
@@ -351,8 +351,9 b" first graft something so there's an addi" | |||
|
351 | 351 | $ hg graft 12 |
|
352 | 352 | grafting revision 12 |
|
353 | 353 | $ hg ci --amend -m 'graft amend' |
|
354 |
saved backup bundle to $TESTTMP/.hg/strip-backup/ |
|
|
354 | saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-amend-backup.hg (glob) | |
|
355 | 355 | $ hg log -r . --debug | grep extra |
|
356 | extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e | |
|
356 | 357 | extra: branch=a |
|
357 | 358 | extra: source=2647734878ef0236dda712fae9c1651cf694ea8a |
|
358 | 359 | |
@@ -391,26 +392,26 b' Amend with no files changes' | |||
|
391 | 392 | $ hg id -n |
|
392 | 393 | 14 |
|
393 | 394 | $ hg log -Gl 3 --style=compact |
|
394 |
@ 14[tip]:11 |
|
|
395 | @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test | |
|
395 | 396 | | babar |
|
396 | 397 | | |
|
397 | 398 | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
|
398 | 399 | | | fork |
|
399 | 400 | | | |
|
400 |
o | 11 |
|
|
401 | o | 11 3334b7925910 1970-01-01 00:00 +0000 test | |
|
401 | 402 | | | a'' |
|
402 | 403 | | | |
|
403 | 404 | $ hg log -Gl 4 --hidden --style=compact |
|
404 |
@ 14[tip]:11 |
|
|
405 | @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test | |
|
405 | 406 | | babar |
|
406 | 407 | | |
|
407 |
| x 13:11 |
|
|
408 | | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test | |
|
408 | 409 | |/ amend for phase |
|
409 | 410 | | |
|
410 | 411 | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
|
411 | 412 | | | fork |
|
412 | 413 | | | |
|
413 |
o | 11 |
|
|
414 | o | 11 3334b7925910 1970-01-01 00:00 +0000 test | |
|
414 | 415 | | | a'' |
|
415 | 416 | | | |
|
416 | 417 | |
@@ -422,23 +423,34 b' ride of)' | |||
|
422 | 423 | $ echo 'babar' >> a |
|
423 | 424 | $ hg commit --amend |
|
424 | 425 | $ hg log -Gl 6 --hidden --style=compact |
|
425 |
@ 16[tip]:11 |
|
|
426 | @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test | |
|
426 | 427 | | babar |
|
427 | 428 | | |
|
428 |
| x 15 |
|
|
429 |
| | temporary amend commit for |
|
|
429 | | x 15 90fef497c56f 1970-01-01 00:00 +0000 test | |
|
430 | | | temporary amend commit for b650e6ee8614 | |
|
430 | 431 | | | |
|
431 |
| x 14:11 |
|
|
432 | | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test | |
|
432 | 433 | |/ babar |
|
433 | 434 | | |
|
434 |
| x 13:11 |
|
|
435 | | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test | |
|
435 | 436 | |/ amend for phase |
|
436 | 437 | | |
|
437 | 438 | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test |
|
438 | 439 | | | fork |
|
439 | 440 | | | |
|
440 |
o | 11 |
|
|
441 | o | 11 3334b7925910 1970-01-01 00:00 +0000 test | |
|
441 | 442 | | | a'' |
|
442 | 443 | | | |
|
443 | 444 | |
|
444 | 445 | |
|
446 | Test that amend does not make it easy to create obsoletescence cycle | |
|
447 | --------------------------------------------------------------------- | |
|
448 | ||
|
449 | ||
|
450 | $ hg id -r 14 | |
|
451 | b650e6ee8614 (a) | |
|
452 | $ hg revert -ar 14 | |
|
453 | reverting a | |
|
454 | $ hg commit --amend | |
|
455 | $ hg id | |
|
456 | b99e5df575f7 (a) tip |
@@ -509,9 +509,9 b' amend' | |||
|
509 | 509 | $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords |
|
510 | 510 | overwriting a expanding keywords |
|
511 | 511 | $ hg -q id |
|
512 | 577e60613a88 | |
|
512 | 67d8c481a6be | |
|
513 | 513 | $ head -1 a |
|
514 |
expand $Id: a,v |
|
|
514 | expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $ | |
|
515 | 515 | |
|
516 | 516 | $ hg -q strip -n tip |
|
517 | 517 |
General Comments 0
You need to be logged in to leave comments.
Login now