mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
qnew: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "hg qnew -e" isn't 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 "hg qnew -e" into ".hg/last-message.txt" just after user editing. This patch doesn't save the message specified by -m/-l options as same as other commands. 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.
This commit is contained in:
parent
3acb83dcfb
commit
84f2d9a815
@ -1083,6 +1083,7 @@ class queue(object):
|
||||
p.write("# Date %s %s\n\n" % date)
|
||||
if util.safehasattr(msg, '__call__'):
|
||||
msg = msg()
|
||||
repo.savecommitmessage(msg)
|
||||
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
|
||||
n = newcommit(repo, None, commitmsg, user, date, match=match,
|
||||
force=True)
|
||||
|
@ -233,3 +233,39 @@ hg headers
|
||||
use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
|
||||
abort: cannot manage merge changesets
|
||||
$ rm -r sandbox
|
||||
|
||||
Test saving last-message.txt
|
||||
|
||||
$ hg init repo
|
||||
$ cd repo
|
||||
|
||||
$ 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 "test saving last-message.txt" >> \$1
|
||||
> EOF
|
||||
|
||||
$ rm -f .hg/last-message.txt
|
||||
$ HGEDITOR="sh $TESTDIR/editor.sh" hg qnew -e patch
|
||||
==== before editing
|
||||
====
|
||||
abort: emulating unexpected abort
|
||||
[255]
|
||||
$ cat .hg/last-message.txt
|
||||
test saving last-message.txt
|
||||
|
||||
$ cd ..
|
||||
|
Loading…
Reference in New Issue
Block a user