[PATCH 5 of 5 V2] amend: obsolete support
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sat Aug 25 18:50:31 CDT 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1345904969 -7200
# Node ID 8f5098715be7917d39580e100ee9067bcb81f64d
# Parent fb9a14da018f776acd474987ead1d3a2c51733cd
amend: obsolete support
If the obsolete feature is enabled, `hg commit --amend` marks changeset as
obsolete instead of stripping them.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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
+import subrepo, context, repair, bookmarks, graphmod, revset, obsolete
import lock as lockmod
def parsealiases(cmd):
@@ -1685,12 +1685,20 @@
repo._bookmarks[bm] = newid
bookmarks.write(repo)
#commit the whole amend process
+ if obsolete._enabled and newid != old.node():
+ # mark the new changeset a 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)
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -355,3 +355,76 @@
$ hg log -r . --debug | grep extra
extra: branch=a
extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
+
+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 4daa970db9ef 1970-01-01 00:00 +0000 test
+ |/ graft amend
+ |
+ | 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 4daa970db9ef 1970-01-01 00:00 +0000 test
+ |/ graft amend
+ |
+ | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
+ | | fork
+ | |
+ o | 11 7e09f708a0e9 1970-01-01 00:00 +0000 test
+ | | a''
+ | |
+
+
More information about the Mercurial-devel
mailing list