Mercurial > hg-stable
comparison tests/test-mq-qnew.t @ 21234:b9a16ed5acec
qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
Before this patch, "hg qnew" invokes "ui.edit()" explicitly to get
commit message edited manually.
This requires explicit "localrepository.savecommitmessage()"
invocation to save edited commit message into ".hg/last-message.txt",
because unexpected exception raising may abort command execution
before saving it in "localrepository.commit()".
This patch uses "editor" argument of "localrepository.commit()"
instead of explicit "ui.edit()" invocation for "hg qnew".
"localrepository.commit()" will invoke "desceditor()" function newly
added by this patch, and save edited commit message into
".hg/last-message.txt" automatically.
This patch passes not "editor" but "desceditor" to "commit()", because
"hg qnew" requires editor function to return edited message if not
empty, or default message otherwise.
This patch applies "rstrip()" on "defaultmsg" at comparison between
"nctx.description()" and "defaultmsg", because the former should be
stripped by "changelog.stripdesc()" and the latter may have tail white
spaces inherited from "patchfn".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 05 May 2014 21:26:40 +0900 |
parents | e259d4c462b5 |
children | 19d6fec60b81 |
comparison
equal
deleted
inserted
replaced
21233:213fd1a99cd9 | 21234:b9a16ed5acec |
---|---|
245 > class commitfailure(repo.__class__): | 245 > class commitfailure(repo.__class__): |
246 > def commit(self, *args, **kwargs): | 246 > def commit(self, *args, **kwargs): |
247 > raise util.Abort('emulating unexpected abort') | 247 > raise util.Abort('emulating unexpected abort') |
248 > repo.__class__ = commitfailure | 248 > repo.__class__ = commitfailure |
249 > EOF | 249 > EOF |
250 $ cat > .hg/hgrc <<EOF | 250 $ cat >> .hg/hgrc <<EOF |
251 > [extensions] | 251 > [extensions] |
252 > # this failure occurs before editor invocation | |
252 > commitfailure = $TESTTMP/commitfailure.py | 253 > commitfailure = $TESTTMP/commitfailure.py |
253 > EOF | 254 > EOF |
254 | 255 |
255 $ cat > $TESTTMP/editor.sh << EOF | 256 $ cat > $TESTTMP/editor.sh << EOF |
256 > echo "==== before editing" | 257 > echo "==== before editing" |
257 > cat \$1 | 258 > cat \$1 |
258 > echo "====" | 259 > echo "====" |
259 > echo "test saving last-message.txt" >> \$1 | 260 > echo "test saving last-message.txt" >> \$1 |
260 > EOF | 261 > EOF |
261 | 262 |
263 (test that editor is not invoked before transaction starting) | |
264 | |
265 $ rm -f .hg/last-message.txt | |
266 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch | |
267 abort: emulating unexpected abort | |
268 [255] | |
269 $ cat .hg/last-message.txt | |
270 cat: .hg/last-message.txt: No such file or directory | |
271 [1] | |
272 | |
273 (test that editor is invoked and commit message is saved into | |
274 "last-message.txt") | |
275 | |
276 $ cat >> .hg/hgrc <<EOF | |
277 > [extensions] | |
278 > commitfailure = ! | |
279 > [hooks] | |
280 > # this failure occurs after editor invocation | |
281 > pretxncommit.unexpectedabort = false | |
282 > EOF | |
283 | |
262 $ rm -f .hg/last-message.txt | 284 $ rm -f .hg/last-message.txt |
263 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch | 285 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch |
264 ==== before editing | 286 ==== before editing |
287 | |
265 ==== | 288 ==== |
266 abort: emulating unexpected abort | 289 transaction abort! |
290 rollback completed | |
291 note: commit message saved in .hg/last-message.txt | |
292 abort: pretxncommit.unexpectedabort hook exited with status 1 | |
267 [255] | 293 [255] |
268 $ cat .hg/last-message.txt | 294 $ cat .hg/last-message.txt |
295 | |
269 test saving last-message.txt | 296 test saving last-message.txt |
270 | 297 |
298 $ cat >> .hg/hgrc <<EOF | |
299 > [hooks] | |
300 > pretxncommit.unexpectedabort = | |
301 > EOF | |
302 | |
303 Test handling default message with the patch filename with tail whitespaces | |
304 | |
305 $ cat > $TESTTMP/editor.sh << EOF | |
306 > echo "==== before editing" | |
307 > cat \$1 | |
308 > echo "====" | |
309 > echo "[mq]: patch " > \$1 | |
310 > EOF | |
311 | |
312 $ rm -f .hg/last-message.txt | |
313 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e "patch " | |
314 ==== before editing | |
315 | |
316 ==== | |
317 $ cat ".hg/patches/patch " | |
318 # HG changeset patch | |
319 # Parent 0000000000000000000000000000000000000000 | |
320 | |
271 $ cd .. | 321 $ cd .. |