Admittedly, this isn't something I run into often, but every once in a while I'll decide to qref -e a patch and add a commit message. Now, if I've written an essay in my editor and forget about it for a while, qpopping and qpushing in the same repository later on, when I save and exit my editor, qref will abort and my lengthy and thoughtful commit message is gone forever. Henrik suggested qrefresh could lock the patch queue while it's running. Here's a test for that behavior: diff --git a/tests/test-mq-qrefresh-replace-log-message b/tests/test-mq-qrefresh- replace-log-message --- a/tests/test-mq-qrefresh-replace-log-message +++ b/tests/test-mq-qrefresh-replace-log-message @@ -53,3 +53,12 @@ echo ======================= printf "Should display 'Fifth commit message\\\n This is the 5th log message'\n" hg log -l1 -v | sed -n '/description/,$p' echo + +# Testing qrefresh -e on a patch being popped elsewhere +echo > sleepy <<EOF +#!/bin/sh +sleep 3 +EOF +chmod +x sleepy +HGEDITOR=./sleepy hg qrefresh -e +hg qpop || echo "qpop failed as expected" diff --git a/tests/test-mq-qrefresh-replace-log-message.out b/tests/test-mq- qrefresh-replace-log-message.out --- a/tests/test-mq-qrefresh-replace-log-message.out +++ b/tests/test-mq-qrefresh-replace-log-message.out @@ -30,4 +30,4 @@ description: Fifth commit message - +qpop failed as expected I also noticed that qrefresh doesn't use any of the .hg/last-message.txt machinery from hg commit, and it seems like hg commit would also lose its message if it aborted, but I haven't looked into it deeply.
See: http://selenic.com/pipermail/mercurial-devel/2010-July/023102.html
FYI, trovao's approach looks good to me.
Fixed by http://hg.intevation.org/mercurial/crew/rev/59ec12093261 Renato Cunha <renatoc@gmail.com> mq: save qrefresh message for easy recovery in case it fails (issue2062)
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:06 EDT --- This bug was previously known as _bug_ 2062 at http://mercurial.selenic.com/bts/issue2062