如何在Mercurial中恢复已删除的文件(如果有的话)?

问题描述:

偶然地,通过使用GUI而不是CLI,我删除了Mercurial项目中的每个文件.

Accidentally, by using a GUI as opposed to CLI, I removed every file in a Mercurial project.

我通过还原正常"恢复了工作,丢失了一些工作,由于有了时间机器,我可以轻松地恢复工作.但是,是否有一种方法可以取消/取消删除此类文件?遍历手册和谷歌搜索,但看不到任何东西.有插件吗?

I recovered with Revert ok and lost some work, which as I have time machine I could easily get back. But is there a way of un-remove/undelete such files? Trawled through the manual and googled but cannot see anything. Any plugins?

我可能会在这里回答我自己的问题,但是文件已从目录中删除并且不在垃圾桶中以进行恢复,因此我假设删除是不可撤消的吗?

I am probably answering my own question here but the files were gone from the directory and were not in the trash to recover so I am assuming Remove is irrevocable?

p.s.我知道hg forgethg remove -Af会删除而不从目录中删除,但我的问题与我犯的错误有关,而不是冷静地思考操作.

p.s. I know that hg forget or hg remove -Af will remove without deleting from the directory but my question has to do with the error I made as opposed to cool thinking the action through.

首先,使用hg grep查找要恢复的已删除文件.该命令的输出将向您显示文件所在的最新修订版本以及已删除文件的路径. 其次,运行hg revert -r <revision number> <path to deleted file> 现在,已删除的文件将在您的工作副本中,可以重新提交回头文件.

First, use hg grep to find the deleted file you wish to recover. The output of this command will show you the last revision for which the file was present, and the path to the deleted file. Second, run hg revert -r <revision number> <path to deleted file> The deleted file will now be in your working copy, ready to be committed back into head.