检索文件的旧版本,而无需更改工作副本父对象 [英] Retrieve old version of a file without changing working copy parent
问题描述
如何在Mercurial中获得文件的较早版本的副本,而又不使文件在工作区中成为新的默认工作副本?
How do you get a copy of an earlier revision of a file in Mercurial without making that the new default working copy of the file in your workspace?
我找到了hg revert
命令,我认为它可以执行我想要的操作,但是我不确定.
I've found the hg revert
command and I think it does what I want but I'm not sure.
我需要获取我的代码的较早版本的副本,以便在几分钟内使用.但我不想打扰目前运行良好的版本.
I need to get a copy of an earlier revision of my code to work with for a few minutes. But I don't want to disturb the current version which is working fine.
所以我要这样做:
hg revert -r 10 myfile.pls
是否有一种方法可以将其输出到其他目录,以便不干扰我当前的文件版本?像这样:
Is there a way to output it to a different directory so my current working version of the file is not disturbed? Something like:
hg revert -r 10 myfile.pls > c:\temp\dump\myfile_revision10.pls
推荐答案
猫命令可用于检索文件的任何修订版本:
The cat command can be used to retrieve any revision of a file:
$ hg cat -r 10 myfile.pls
您可以使用以下方法将输出重定向到另一个文件
You can redirect the output to another file with
$ hg cat -r 10 myfile.pls > old.pls
或使用--output
标志.如果您需要对多个文件执行此操作,请查看 archive命令,它可以对整个项目执行此操作,例如
or by using the --output
flag. If you need to do this for several files, then take a look at the archive command, which can do this for an entire project, e.g.,
$ hg archive -r 10 ../revision-10
这将创建文件夹revision-10
,其中包含版本10中的存储库快照.
This creates the folder revision-10
which contains a snapshot of your repository as it looked in revision 10.
但是,大多数情况下,您应该只使用更新命令以检出较早的版本. Update是用于在引入新更改后使工作副本更新的命令,但是如果需要,该命令也可以用于使工作副本过期.所以
However, most of the time you should just use the update command to checkout an earlier revision. Update is the command you use to bring the working copy up to date after pulling in new changes, but the command can also be used to make your working copy outdated if needed. So
$ hg update -r 10 # go back
(look at your files, test, etc...)
$ hg update # go back to the tip
这篇关于检索文件的旧版本,而无需更改工作副本父对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!