Bug 2062 - qrefresh -e aborts and loses its commit message if the patch queue is modified elsewhere
Summary: qrefresh -e aborts and loses its commit message if the patch queue is modifie...
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Renato Cunha
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-24 09:45 UTC by brodie
Modified: 2010-08-18 04:00 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brodie 2010-02-24 09:45 UTC
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.
Comment 2 Benoit Boissinot 2010-08-14 14:20 UTC
FYI, trovao's approach looks good to me.
Comment 3 HG Bot 2010-08-18 04:00 UTC
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)
Comment 4 Bugzilla 2012-05-12 09:06 UTC

--- 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