[PATCH STABLE] histedit: save manually edited commit message into ".hg/last-message.txt"
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Sun Mar 23 11:19:51 CDT 2014
At Mon, 24 Mar 2014 01:01:05 +0900,
FUJIWARA Katsunori wrote:
>
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1395590238 -32400
> # Mon Mar 24 00:57:18 2014 +0900
> # Branch stable
> # Node ID dd35a6ff046d4516384e32f55741b474b35f72b6
> # Parent e5641536e4d509b2dc5fab783344f86ea61b17c2
> histedit: save manually edited commit message into ".hg/last-message.txt"
This fixes one more "last-message.txt" saving problem which I
overlooked in the series already imported into stable branch.
> Before this patch, manually edited commit message for "message"
> command in histedit-ing is not saved into ".hg/last-message.txt" until
> it is saved by "localrepository.savecommitmessage()" in
> "localrepository.commit()".
>
> This may lose such commit message, if unexpected exception is raised.
>
> This patch saves manually edited commit message for "message" comand
> 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 should be centralized into the framework of
> "localrepository.commit()" with "editor" argument in the future.
>
> This patch uses repository wrapping class for exception raising before
> saving commit message in "localrepository.commit()" easily and
> certainly, because such exception requires corner case condition.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -398,6 +398,7 @@
> _('Fix up the change and run hg histedit --continue'))
> message = oldctx.description() + '\n'
> message = ui.edit(message, ui.username())
> + repo.savecommitmessage(message)
> commit = commitfuncfor(repo, oldctx)
> new = commit(text=message, user=oldctx.user(), date=oldctx.date(),
> extra=oldctx.extra())
> diff --git a/tests/test-histedit-edit.t b/tests/test-histedit-edit.t
> --- a/tests/test-histedit-edit.t
> +++ b/tests/test-histedit-edit.t
> @@ -189,6 +189,49 @@
>
>
> modify the message
> +
> +check saving last-message.txt, at first
> +
> + $ cat > $TESTDIR/commitfailure.py <<EOF
> + > from mercurial import util
> + > def reposetup(ui, repo):
> + > class commitfailure(repo.__class__):
> + > def commit(self, *args, **kwargs):
> + > raise util.Abort('emulating unexpected abort')
> + > repo.__class__ = commitfailure
> + > EOF
> + $ cat > .hg/hgrc <<EOF
> + > [extensions]
> + > commitfailure = $TESTDIR/commitfailure.py
> + > 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 tip --commands - 2>&1 << EOF | fixbundle
> + > mess 1fd3b2fe7754 f
> + > EOF
> + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> + ==== before editing
> + f
> + ====
> + abort: emulating unexpected abort
> + $ cat .hg/last-message.txt
> + f
> + check saving last-message.txt
> +
> + $ cat > .hg/hgrc <<EOF
> + > [extensions]
> + > commitfailure = !
> + > EOF
> + $ hg histedit --abort -q
> +
> +then, check "modify the message" itself
> +
> $ hg histedit tip --commands - 2>&1 << EOF | fixbundle
> > mess 1fd3b2fe7754 f
> > EOF
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
----------------------------------------------------------------------
[FUJIWARA Katsunori] foozy at lares.dti.ne.jp
More information about the Mercurial-devel
mailing list