Mercurial > hg
changeset 20770:5d22cadd1938 stable
histedit: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "fold" command
in histedit-ing is never saved into ".hg/last-message.txt", because it
uses "localrepository.commitctx()" instead of
"localrepository.commit()": saving into ".hg/last-message.txt" is
executed only in the latter.
This patch saves manually edited commit message for "fold" command in
histedit-ing into ".hg/last-message.txt" just after user editing.
This is the simplest implementation to fix on stable. Editing and
saving commit message for memctx should be centralized into the
framework like "localrepository.commit()" with "editor" argument or so
in the future.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 19 Mar 2014 01:07:41 +0900 |
parents | 1e686e55780c |
children | 434619dae569 |
files | hgext/histedit.py tests/test-histedit-fold.t |
diffstat | 2 files changed, 64 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Wed Mar 19 01:07:41 2014 +0900 +++ b/hgext/histedit.py Wed Mar 19 01:07:41 2014 +0900 @@ -294,6 +294,7 @@ date=date, extra=extra) new._text = cmdutil.commitforceeditor(repo, new, []) + repo.savecommitmessage(new.description()) return repo.commitctx(new) def pick(ui, repo, ctx, ha, opts):
--- a/tests/test-histedit-fold.t Wed Mar 19 01:07:41 2014 +0900 +++ b/tests/test-histedit-fold.t Wed Mar 19 01:07:41 2014 +0900 @@ -105,6 +105,69 @@ +check saving last-message.txt + + $ cat > $TESTDIR/abortfolding.py <<EOF + > from mercurial import util + > def abortfolding(ui, repo, hooktype, **kwargs): + > ctx = repo[kwargs.get('node')] + > if set(ctx.files()) == set(['c', 'd', 'f']): + > return True # abort folding commit only + > ui.warn('allow non-folding commit\\n') + > EOF + $ cat > .hg/hgrc <<EOF + > [hooks] + > pretxncommit.abortfolding = python:$TESTDIR/abortfolding.py:abortfolding + > EOF + + $ cat > $TESTDIR/editor.sh << EOF + > echo "==== before editing" + > cat \$1 + > echo "====" + > echo "check saving last-message.txt" >> \$1 + > EOF + + $ rm -f .hg/last-message.txt + $ HGEDITOR="sh $TESTDIR/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle + > pick 6de59d13424a f + > fold 9c277da72c9b d + > EOF + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + allow non-folding commit + 0 files updated, 0 files merged, 3 files removed, 0 files unresolved + ==== before editing + f + *** + c + *** + d + + + + HG: Enter commit message. Lines beginning with 'HG:' are removed. + HG: Leave message empty to abort commit. + HG: -- + HG: user: test + HG: branch 'default' + HG: changed c + HG: changed d + HG: changed f + ==== + transaction abort! + rollback completed + abort: pretxncommit.abortfolding hook failed + + $ cat .hg/last-message.txt + f + *** + c + *** + d + + + + check saving last-message.txt + $ cd .. folding and creating no new change doesn't break: