Mercurial > hg-stable
changeset 17475:63e45aee46d4
amend: add obsolete support
If the obsolete feature is enabled, `hg commit --amend` marks a
changeset as obsolete instead of stripping it.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Tue, 11 Sep 2012 00:12:07 +0200 |
parents | f85816af6294 |
children | 31f32a96e1e3 |
files | mercurial/cmdutil.py tests/test-commit-amend.t |
diffstat | 2 files changed, 84 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Aug 24 21:16:23 2012 +0200 +++ b/mercurial/cmdutil.py Tue Sep 11 00:12:07 2012 +0200 @@ -10,7 +10,7 @@ import os, sys, errno, re, tempfile import util, scmutil, templater, patch, error, templatekw, revlog, copies import match as matchmod -import subrepo, context, repair, bookmarks, graphmod, revset, phases +import subrepo, context, repair, bookmarks, graphmod, revset, phases, obsolete import lock as lockmod def parsealiases(cmd): @@ -1697,12 +1697,20 @@ repo._bookmarks[bm] = newid bookmarks.write(repo) #commit the whole amend process + if obsolete._enabled and newid != old.node(): + # mark the new changeset as successor of the rewritten one + new = repo[newid] + obs = [(old, (new,))] + if node: + obs.append((ctx, (new,))) + + obsolete.createmarkers(repo, obs) tr.close() finally: tr.release() - # Strip the intermediate commit (if there was one) and the amended - # commit - if newid != old.node(): + if (not obsolete._enabled) and newid != old.node(): + # Strip the intermediate commit (if there was one) and the amended + # commit if node: ui.note(_('stripping intermediate changeset %s\n') % ctx) ui.note(_('stripping amended changeset %s\n') % old)
--- a/tests/test-commit-amend.t Fri Aug 24 21:16:23 2012 +0200 +++ b/tests/test-commit-amend.t Tue Sep 11 00:12:07 2012 +0200 @@ -370,3 +370,75 @@ 11: draft 13: secret +Test amend with obsolete +--------------------------- + +Enable obsolete + + $ cat > ${TESTTMP}/obs.py << EOF + > import mercurial.obsolete + > mercurial.obsolete._enabled = True + > EOF + $ echo '[extensions]' >> $HGRCPATH + $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH + + +Amend with no files changes + + $ hg id -n + 13 + $ hg ci --amend -m 'babar' + $ hg id -n + 14 + $ hg log -Gl 3 --style=compact + @ 14[tip]:11 43df5a5434ad 1970-01-01 00:00 +0000 test + | babar + | + | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test + | | fork + | | + o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test + | | a'' + | | + $ hg log -Gl 4 --hidden --style=compact + @ 14[tip]:11 43df5a5434ad 1970-01-01 00:00 +0000 test + | babar + | + | x 13:11 175fafee6f44 1970-01-01 00:00 +0000 test + |/ amend for phase + | + | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test + | | fork + | | + o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test + | | a'' + | | + +Amend with files changes + +(note: the extra commit over 15 is a temporary junk I would be happy to get +ride of) + + $ echo 'babar' >> a + $ hg commit --amend + $ hg log -Gl 6 --hidden --style=compact + @ 16[tip]:11 31e0a4a1b04a 1970-01-01 00:00 +0000 test + | babar + | + | x 15 053c696ada75 1970-01-01 00:00 +0000 test + | | temporary amend commit for 43df5a5434ad + | | + | x 14:11 43df5a5434ad 1970-01-01 00:00 +0000 test + |/ babar + | + | x 13:11 175fafee6f44 1970-01-01 00:00 +0000 test + |/ amend for phase + | + | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test + | | fork + | | + o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test + | | a'' + | | + +