mq: save qrefresh message for easy recovery in case it fails (
issue2062)
Currently, if you start editing a commit message from qrefresh -e and, for any
reason: forget you were editing it, leave the editor open and start qpopping
and qpushing, when you decide to save your commit message, it is going to fail.
This patch copies the commit behavior of saving the message contents in
$HGROOT/.hg/last-message.txt before continuing.
--- a/hgext/mq.py Tue Aug 17 17:38:19 2010 -0500
+++ b/hgext/mq.py Mon Aug 16 16:35:20 2010 -0300
@@ -2041,6 +2041,10 @@
If -s/--short is specified, files currently included in the patch
will be refreshed just like matched files and remain in the patch.
+ If -e/--edit is specified, Mercurial will start your configured editor for
+ you to enter a message. In case qrefresh fails, you will find a backup of
+ your message in ``.hg/last-message.txt``.
+
hg add/remove/copy/rename work as usual, though you might want to
use git-style patches (-g/--git or [diff] git=1) to track copies
and renames. See the diffs help topic for more information on the
@@ -2057,6 +2061,10 @@
patch = q.applied[-1].name
ph = patchheader(q.join(patch), q.plainmode)
message = ui.edit('\n'.join(ph.message), ph.user or ui.username())
+ # We don't want to lose the patch message if qrefresh fails (issue2062)
+ msgfile = repo.opener('last-message.txt', 'wb')
+ msgfile.write(message)
+ msgfile.close()
setupheaderopts(ui, opts)
ret = q.refresh(repo, pats, msg=message, **opts)
q.save_dirty()