Mercurial > hg-stable
comparison tests/test-mq-qfold.t @ 20769:1e686e55780c stable
qfold: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "hg qfold -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 qfold -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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 19 Mar 2014 01:07:41 +0900 |
parents | 97ffc68f71d3 |
children | e259d4c462b5 |
comparison
equal
deleted
inserted
replaced
20768:57d0c8c3b947 | 20769:1e686e55780c |
---|---|
138 a | 138 a |
139 a | 139 a |
140 b | 140 b |
141 +b | 141 +b |
142 | 142 |
143 Test saving last-message.txt: | |
144 | |
145 $ hg qrefresh -m "original message" | |
146 | |
147 $ cat > $TESTDIR/commitfailure.py <<EOF | |
148 > from mercurial import util | |
149 > def reposetup(ui, repo): | |
150 > class commitfailure(repo.__class__): | |
151 > def commit(self, *args, **kwargs): | |
152 > raise util.Abort('emulating unexpected abort') | |
153 > repo.__class__ = commitfailure | |
154 > EOF | |
155 | |
156 $ cat > .hg/hgrc <<EOF | |
157 > [extensions] | |
158 > commitfailure = $TESTDIR/commitfailure.py | |
159 > EOF | |
160 | |
161 $ cat > $TESTDIR/editor.sh << EOF | |
162 > echo "==== before editing" | |
163 > cat \$1 | |
164 > echo "====" | |
165 > (echo; echo "test saving last-message.txt") >> \$1 | |
166 > EOF | |
167 | |
168 $ rm -f .hg/last-message.txt | |
169 $ HGEDITOR="sh $TESTDIR/editor.sh" hg qfold -e p3 | |
170 ==== before editing | |
171 original message==== | |
172 refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
173 abort: emulating unexpected abort | |
174 [255] | |
175 $ cat .hg/last-message.txt | |
176 original message | |
177 test saving last-message.txt | |
178 | |
143 $ cd .. | 179 $ cd .. |
144 | 180 |