##// END OF EJS Templates
amend: add noise in extra to avoid creating obsolescence cycle (issue3664)...
Pierre-Yves David -
r17811:a8aba292 default
parent child Browse files
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 9cd25b479c51 a
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:9cd25b479c51
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/9cd25b479c51-amend-backup.hg (glob)
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/e2bb3ecffd2f-amend-backup.hg (glob)
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 664a9b2d60cd
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 664a9b2d60cd
81 copying changeset 664a9b2d60cd to ad120869acf0
80 amending changeset 74609c7f506e
81 copying changeset 74609c7f506e to ad120869acf0
82 82 a
83 stripping amended changeset 664a9b2d60cd
83 stripping amended changeset 74609c7f506e
84 84 1 changesets found
85 saved backup bundle to $TESTTMP/.hg/strip-backup/664a9b2d60cd-amend-backup.hg (glob)
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:ea6e356ff2ad
92 committed changeset 1:1cd866679df8
93 93 $ hg diff -c .
94 diff -r ad120869acf0 -r ea6e356ff2ad a
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:ea6e356ff2ad
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/ea6e356ff2ad-amend-backup.hg (glob)
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/377b91ce8b56-amend-backup.hg (glob)
125 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-amend-backup.hg (glob)
126 126 $ hg log -r .
127 changeset: 1:2c94e4a5756f
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 2c94e4a5756f
143 copying changeset 2c94e4a5756f to ad120869acf0
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 2c94e4a5756f
154 stripping amended changeset 5f357c7560ab
155 155 1 changesets found
156 saved backup bundle to $TESTTMP/.hg/strip-backup/2c94e4a5756f-amend-backup.hg (glob)
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:ffb49186f961
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 ffb49186f961
169 amending changeset 7ab3bf440b54
170 170 a
171 copying changeset a4f8a65b7c6a to ad120869acf0
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 a4f8a65b7c6a
183 stripping amended changeset ffb49186f961
182 stripping intermediate changeset a0ea9b1a4c8c
183 stripping amended changeset 7ab3bf440b54
184 184 2 changesets found
185 saved backup bundle to $TESTTMP/.hg/strip-backup/ffb49186f961-amend-backup.hg (glob)
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:fb6cca43446f
192 committed changeset 1:ea22a388757c
193 193
194 194 $ rm editor.sh
195 195 $ hg log -r .
196 changeset: 1:fb6cca43446f
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/fb6cca43446f-amend-backup.hg (glob)
208 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-amend-backup.hg (glob)
209 209 $ hg book
210 book1 1:0cf1c7a51bcf
211 * book2 1:0cf1c7a51bcf
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/0cf1c7a51bcf-amend-backup.hg (glob)
214 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-amend-backup.hg (glob)
215 215 $ hg book
216 book1 1:7344472bd951
217 * book2 1:7344472bd951
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/1661ca36a2db-amend-backup.hg (glob)
233 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-amend-backup.hg (glob)
234 234 $ hg branches
235 default 2:f24ee5961967
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/5e302dcc12b8-amend-backup.hg (glob)
258 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-amend-backup.hg (glob)
259 259 $ hg branches
260 default 2:f24ee5961967
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/9c207120aa98-amend-backup.hg (glob)
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/fda2b3b27b22-amend-backup.hg (glob)
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/20a7413547f9-amend-backup.hg (glob)
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/5daa77a5d616-amend-backup.hg (glob)
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/167f8e3031df-amend-backup.hg (glob)
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/ceac1a44c806-amend-backup.hg (glob)
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/18a5124daf7a-amend-backup.hg (glob)
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 43df5a5434ad 1970-01-01 00:00 +0000 test
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 7e09f708a0e9 1970-01-01 00:00 +0000 test
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 43df5a5434ad 1970-01-01 00:00 +0000 test
405 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
405 406 | babar
406 407 |
407 | x 13:11 175fafee6f44 1970-01-01 00:00 +0000 test
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 7e09f708a0e9 1970-01-01 00:00 +0000 test
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 31e0a4a1b04a 1970-01-01 00:00 +0000 test
426 @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test
426 427 | babar
427 428 |
428 | x 15 053c696ada75 1970-01-01 00:00 +0000 test
429 | | temporary amend commit for 43df5a5434ad
429 | x 15 90fef497c56f 1970-01-01 00:00 +0000 test
430 | | temporary amend commit for b650e6ee8614
430 431 | |
431 | x 14:11 43df5a5434ad 1970-01-01 00:00 +0000 test
432 | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test
432 433 |/ babar
433 434 |
434 | x 13:11 175fafee6f44 1970-01-01 00:00 +0000 test
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 7e09f708a0e9 1970-01-01 00:00 +0000 test
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 577e60613a88 1970/01/01 00:00:15 test $
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