[PATCH STABLE] amend: prevent loose of bookmark on failed amend
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sun Dec 30 02:56:36 UTC 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356835755 -3600
# Branch stable
# Node ID 6522e491b723939bcab26cede89058ed7eece300
# Parent a51a5199a672e378924066cd5103afef8de26fb8
amend: prevent loose of bookmark on failed amend
The active bookmark were moved to the temporary commit. When the transaction
were rollbacked, the bookmark were lost.
We now temporarly disable the bookmark to prevent this effect.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1633,14 +1633,17 @@ def amend(ui, repo, commitfunc, old, ext
# `logmessage` anyway.
opts.pop('logfile')
# First, do a regular commit to record all changes in the working
# directory (if there are any)
ui.callhooks = False
+ currentbookmark = repo._bookmarkcurrent
try:
+ repo._bookmarkcurrent = None
opts['message'] = 'temporary amend commit for %s' % old
node = commit(ui, repo, commitfunc, pats, opts)
finally:
+ repo._bookmarkcurrent = currentbookmark
ui.callhooks = True
ctx = repo[node]
# Participating changesets:
#
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
@@ -241,10 +241,28 @@ Moving bookmarks, preserve active bookma
saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-amend-backup.hg (glob)
$ hg book
book1 1:48bb6e53a15f
* book2 1:48bb6e53a15f
+abort does not loose bookmarks
+
+ $ cat > editor.sh << '__EOF__'
+ > #!/bin/sh
+ > echo "" > "$1"
+ > __EOF__
+ $ echo a >> a
+ $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
+ transaction abort!
+ rollback completed
+ abort: empty commit message
+ [255]
+ $ hg book
+ book1 1:48bb6e53a15f
+ * book2 1:48bb6e53a15f
+ $ hg revert -Caq
+ $ rm editor.sh
+
$ echo '[defaults]' >> $HGRCPATH
$ echo "commit=-d '0 0'" >> $HGRCPATH
Moving branches:
More information about the Mercurial-devel
mailing list