##// END OF EJS Templates
amend: add obsolete support...
Pierre-Yves David -
r17475:63e45aee default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from i18n import _'
10 import os, sys, errno, re, tempfile
10 import os, sys, errno, re, tempfile
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
11 import util, scmutil, templater, patch, error, templatekw, revlog, copies
12 import match as matchmod
12 import match as matchmod
13 import subrepo, context, repair, bookmarks, graphmod, revset, phases
13 import subrepo, context, repair, bookmarks, graphmod, revset, phases, obsolete
14 import lock as lockmod
14 import lock as lockmod
15
15
16 def parsealiases(cmd):
16 def parsealiases(cmd):
@@ -1697,12 +1697,20 b' def amend(ui, repo, commitfunc, old, ext'
1697 repo._bookmarks[bm] = newid
1697 repo._bookmarks[bm] = newid
1698 bookmarks.write(repo)
1698 bookmarks.write(repo)
1699 #commit the whole amend process
1699 #commit the whole amend process
1700 if obsolete._enabled and newid != old.node():
1701 # mark the new changeset as successor of the rewritten one
1702 new = repo[newid]
1703 obs = [(old, (new,))]
1704 if node:
1705 obs.append((ctx, (new,)))
1706
1707 obsolete.createmarkers(repo, obs)
1700 tr.close()
1708 tr.close()
1701 finally:
1709 finally:
1702 tr.release()
1710 tr.release()
1703 # Strip the intermediate commit (if there was one) and the amended
1711 if (not obsolete._enabled) and newid != old.node():
1704 # commit
1712 # Strip the intermediate commit (if there was one) and the amended
1705 if newid != old.node():
1713 # commit
1706 if node:
1714 if node:
1707 ui.note(_('stripping intermediate changeset %s\n') % ctx)
1715 ui.note(_('stripping intermediate changeset %s\n') % ctx)
1708 ui.note(_('stripping amended changeset %s\n') % old)
1716 ui.note(_('stripping amended changeset %s\n') % old)
@@ -370,3 +370,75 b' Preserve phase'
370 11: draft
370 11: draft
371 13: secret
371 13: secret
372
372
373 Test amend with obsolete
374 ---------------------------
375
376 Enable obsolete
377
378 $ cat > ${TESTTMP}/obs.py << EOF
379 > import mercurial.obsolete
380 > mercurial.obsolete._enabled = True
381 > EOF
382 $ echo '[extensions]' >> $HGRCPATH
383 $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
384
385
386 Amend with no files changes
387
388 $ hg id -n
389 13
390 $ hg ci --amend -m 'babar'
391 $ hg id -n
392 14
393 $ hg log -Gl 3 --style=compact
394 @ 14[tip]:11 43df5a5434ad 1970-01-01 00:00 +0000 test
395 | babar
396 |
397 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
398 | | fork
399 | |
400 o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test
401 | | a''
402 | |
403 $ hg log -Gl 4 --hidden --style=compact
404 @ 14[tip]:11 43df5a5434ad 1970-01-01 00:00 +0000 test
405 | babar
406 |
407 | x 13:11 175fafee6f44 1970-01-01 00:00 +0000 test
408 |/ amend for phase
409 |
410 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
411 | | fork
412 | |
413 o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test
414 | | a''
415 | |
416
417 Amend with files changes
418
419 (note: the extra commit over 15 is a temporary junk I would be happy to get
420 ride of)
421
422 $ echo 'babar' >> a
423 $ hg commit --amend
424 $ hg log -Gl 6 --hidden --style=compact
425 @ 16[tip]:11 31e0a4a1b04a 1970-01-01 00:00 +0000 test
426 | babar
427 |
428 | x 15 053c696ada75 1970-01-01 00:00 +0000 test
429 | | temporary amend commit for 43df5a5434ad
430 | |
431 | x 14:11 43df5a5434ad 1970-01-01 00:00 +0000 test
432 |/ babar
433 |
434 | x 13:11 175fafee6f44 1970-01-01 00:00 +0000 test
435 |/ amend for phase
436 |
437 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
438 | | fork
439 | |
440 o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test
441 | | a''
442 | |
443
444
General Comments 0
You need to be logged in to leave comments. Login now