检索文件的旧版本而不更改工作副本父级

发布于 2024-09-16 14:47:47 字数 376 浏览 9 评论 0原文

如何在 Mercurial 中获取文件早期版本的副本,而不将其作为工作区中文件的新默认工作副本?

我找到了 hg revert 命令,我认为它可以满足我的要求,但我不确定。

我需要获取代码早期版本的副本来使用几分钟。但我不想打扰当前运行良好的版本。

所以我打算这样做:

hg revert -r 10 myfile.pls

有没有办法将其输出到不同的目录,这样我当前的文件工作版本就不会受到干扰?像这样的东西:

hg revert -r 10 myfile.pls > c:\temp\dump\myfile_revision10.pls

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?

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.

So I was going to do this:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜司空 2024-09-23 14:47:47

cat 命令 可用于检索文件的任何修订版本

$ hg cat -r 10 myfile.pls

: 将输出重定向到另一个文件

$ hg cat -r 10 myfile.pls > old.pls

可以使用 --output 标志 。如果您需要对多个文件执行此操作,请查看 archive 命令< /a>,它可以对整个项目执行此操作,例如,

$ hg archive -r 10 ../revision-10

这将创建文件夹 revision-10,其中包含您的存储库的快照,如修订版 10 中所示。

但是,大多数时候您应该只使用更新命令来签出早期版本。更新是在引入新更改后用于使工作副本保持最新的命令,但如果需要,该命令也可用于使工作副本过时。所以

$ hg update -r 10   # go back
(look at your files, test, etc...)
$ hg update         # go back to the tip

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

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

This creates the folder revision-10 which contains a snapshot of your repository as it looked in revision 10.

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
谁对谁错谁最难过 2024-09-23 14:47:47

您使用的命令是这样的:

hg cat -r 10 myfile.pls > C:\temp\dump\myfile_revision10.pls

了解一点 Unix 有助于使用 Mercurial 命令。也许 cat 应该有一个内置别名 print 或类似的东西。

The command you use is this:

hg cat -r 10 myfile.pls > C:\temp\dump\myfile_revision10.pls

Knowing a bit of Unix helps with Mercurial commands. Perhaps cat should have a built in alias print or something similar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文