[PATCH] mq: save qrefresh message for easy recovery in case it fails (issue2062)

Brodie Rao brodie at bitheap.org
Mon Aug 16 14:05:12 CDT 2010


On Jul 26, 2010, at 9:25 AM, Renato Cunha wrote:

> When I started using mq, I was surprised when I discovered that
> qpushing/qpoping while editing a message would make me lose if  
> forever. With
> time I learned to pay attention to that. Today I was browsing the  
> BTS when I
> found issue 2062 and decided to give it a try.
>
> My approach copies that of commit in localrepo.py, which saves the  
> message
> before continuing. I used the API that seemed more natural, as there  
> doesn't
> seem to exist a last-message creation API. Also, if the last- 
> message.txt name
> isn't appropriate because it would clash with the name used with  
> commit, I'd
> like to hear from you.
>
> Regards.
>
> # HG changeset patch
> # User Renato Cunha <renatoc at gmail.com>
> # Date 1280150464 10800
> # Node ID 231db1ef59393f76c6e9bc5527f6f9a77a65fe2f
> # Parent  c5e555e064d0ceed3a177b656a49f50890d17cfa
> 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.

Looks good to me, but I think the behavior should be mentioned in  
qrefresh's help message (in the same way that it's documented for hg  
commit).

> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -2037,6 +2037,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()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list