diff --git a/hgext/histedit.py b/hgext/histedit.py index 0768cda8b5799dc803dc0ee27a832cd64e05f28a_aGdleHQvaGlzdGVkaXQucHk=..213fd1a99cd9b330652d6fd28e8476f7cfe85e09_aGdleHQvaGlzdGVkaXQucHk= 100644 --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -402,8 +402,8 @@ if stats and stats[3] > 0: raise error.InterventionRequired( _('Fix up the change and run hg histedit --continue')) - message = oldctx.description() + '\n' - message = ui.edit(message, ui.username()) - repo.savecommitmessage(message) + message = oldctx.description() + def editor(repo, ctx, subs): + return ui.edit(ctx.description() + "\n", ctx.user()) commit = commitfuncfor(repo, oldctx) new = commit(text=message, user=oldctx.user(), date=oldctx.date(), @@ -408,6 +408,6 @@ commit = commitfuncfor(repo, oldctx) new = commit(text=message, user=oldctx.user(), date=oldctx.date(), - extra=oldctx.extra()) + extra=oldctx.extra(), editor=editor) newctx = repo[new] if oldctx.node() != newctx.node(): return newctx, [(oldctx.node(), (new,))] diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t index 0768cda8b5799dc803dc0ee27a832cd64e05f28a_dGVzdHMvdGVzdC1oaXN0ZWRpdC1lZGl0LnQ=..213fd1a99cd9b330652d6fd28e8476f7cfe85e09_dGVzdHMvdGVzdC1oaXN0ZWRpdC1lZGl0LnQ= 100644 --- a/tests/test-histedit-edit.t +++ b/tests/test-histedit-edit.t @@ -200,5 +200,5 @@ > raise util.Abort('emulating unexpected abort') > repo.__class__ = commitfailure > EOF - $ cat > .hg/hgrc <<EOF + $ cat >> .hg/hgrc <<EOF > [extensions] @@ -204,4 +204,5 @@ > [extensions] + > # this failure occurs before editor invocation > commitfailure = $TESTTMP/commitfailure.py > EOF @@ -211,6 +212,34 @@ > echo "====" > echo "check saving last-message.txt" >> \$1 > EOF + +(test that editor is not invoked before transaction starting) + + $ rm -f .hg/last-message.txt + $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF | fixbundle + > mess 1fd3b2fe7754 f + > EOF + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + abort: emulating unexpected abort + $ cat .hg/last-message.txt + cat: .hg/last-message.txt: No such file or directory + [1] + + $ cat >> .hg/hgrc <<EOF + > [extensions] + > commitfailure = ! + > EOF + $ hg histedit --abort -q + +(test that editor is invoked and commit message is saved into +"last-message.txt") + + $ cat >> .hg/hgrc <<EOF + > [hooks] + > # this failure occurs after editor invocation + > pretxncommit.unexpectedabort = false + > EOF + $ rm -f .hg/last-message.txt $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit tip --commands - 2>&1 << EOF | fixbundle > mess 1fd3b2fe7754 f @@ -219,8 +248,11 @@ ==== before editing f ==== - abort: emulating unexpected abort + transaction abort! + rollback completed + note: commit message saved in .hg/last-message.txt + abort: pretxncommit.unexpectedabort hook exited with status 1 $ cat .hg/last-message.txt f check saving last-message.txt @@ -223,10 +255,10 @@ $ cat .hg/last-message.txt f check saving last-message.txt - $ cat > .hg/hgrc <<EOF - > [extensions] - > commitfailure = ! + $ cat >> .hg/hgrc <<EOF + > [hooks] + > pretxncommit.unexpectedabort = > EOF $ hg histedit --abort -q