I had two patches in series, neither one applied, and I accidentally called qdelete on the wrong one. Is there any way to reverse this operation and get my patch back? I had a huge amount of work in this one!!!
-
@ gizmo - Thanks Gizmo, I tried using Windows 7 previous version, but the file wasn't saved recent enough for me to reuse it and a few undelete tools couldn't find it either, I guess it's just gone. A day of work down the drain...sigh... – David C Mar 25 '11 at 14:08
-
@Ry4an - Thanks, I am pretty new to Mercurial, and was trying to look for a decent way to manage different workflows, I will look into creating a patch repo as you suggested for future workflows. – David C Mar 25 '11 at 16:22
-
Just for future reference for people who need this. Using Windows 7 Previous Version feature, I was not able to save the patch file in .hg, but I was able to recover my files from Previous Version's of the Solution itself. After recovering the missing files, it was relatively easy to recreate the patch. This was partially luck though, and may not work for all users in all situations. The comment from @Ry4an seems to make the most sense. Put your patch queue under direct version control ahead of time. Also, as a habit, use -k when deleting as @gizmo recommended. – David C Mar 28 '11 at 17:16
2 Answers
The way to avoid this (and I know it's not helpful now, sorry) is to not just use Mercurial Queues, mq, but to use it with a patch repository. Mercurial/mq has great support for this.
When initially creating the queue you do:
hg qinit --create-repo
(instead of just hg qinit
), which creates a new Mercurial repository in your .hg/patches
directory. Then you can use:
hg commit --mq
to commit all your patch files, and bringing this back would be just a matter of:
hg revert --mq
The bottom line, and again I know it's not helping you now, but maybe it'll help the next guy or you later, is: if you're writing code and it isn't committed somewhere it doesn't exist -- commit and push early and often

- 78,112
- 7
- 148
- 169
Unfortunately, if you did not use the -k
option when calling the qdelete
command, the patch file also got deleted. Thus your only hope is either a backup or an tool that could perform some "undelete" operation.

- 11,819
- 6
- 44
- 61