如何在 Mercurial 中查看文件的先前版本

发布于 2024-10-09 04:18:52 字数 177 浏览 0 评论 0原文

我正在使用 Mercurial 对目录中的几个文件进行版本控制。假设我有 10 次提交(10 个变更集或修订)。我只想查看特定文件(例如 thisFile.py)在其第七个修订版中的外观。我不想恢复到这个旧版本。我不想对之前的版本进行任何更改或修复任何错误。我只是想查看它,而不以任何方式影响文件的最新版本或变化的历史记录。有简单的方法吗?

I am using mercurial for version control of a few files in a directory. Suppose I have 10 commits (10 changesets or revisions). I want to just view how a particular file, say thisFile.py, looked in its 7th revision. I don't want to revert back to this older version. I don't want to go and make any changes or fix any bugs in this previous version. I simply want to see it, without affecting the latest version of the file or the mercurial history in any way. Is there a simple way to do it?

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

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

发布评论

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

评论(3

爱的那么颓废 2024-10-16 04:18:52

使用带有 -r(修订版)参数的 hg cat 命令。

hg cat path_to/myfile.cpp -r 46

其中 46 是修订号(使用 hg log 查看修订历史记录)

Use the hg cat command with the -r (revision) argument.

hg cat path_to/myfile.cpp -r 46

where 46 is the revision number (use hg log to see revision history)

怀中猫帐中妖 2024-10-16 04:18:52
hg cat [OPTION]... FILE...

Print the specified files as they were at the given revision. 
If no revision is given, the parent of the working directory is used, 
or tip if no revision is checked out.

Output may be to a file, in which case the name of the file is given 
using a format string. The formatting rules are the same as for the 
export command, with the following additions:
%s: basename of file being printed
%d: dirname of file being printed, or '.' if in repository root
%p: root-relative path name of file being printed

Returns 0 on success.

options:
-o, --output    print output to file with formatted name
-r, --rev   print the given revision
--decode    apply any matching decode filter
-I, --include   include names matching the given patterns
-X, --exclude   exclude names matching the given patterns
hg cat [OPTION]... FILE...

Print the specified files as they were at the given revision. 
If no revision is given, the parent of the working directory is used, 
or tip if no revision is checked out.

Output may be to a file, in which case the name of the file is given 
using a format string. The formatting rules are the same as for the 
export command, with the following additions:
%s: basename of file being printed
%d: dirname of file being printed, or '.' if in repository root
%p: root-relative path name of file being printed

Returns 0 on success.

options:
-o, --output    print output to file with formatted name
-r, --rev   print the given revision
--decode    apply any matching decode filter
-I, --include   include names matching the given patterns
-X, --exclude   exclude names matching the given patterns
成熟的代价 2024-10-16 04:18:52

要提取特定文件的特定修订版,您可以在 Windows 中执行此操作:

hg cat "<FileToBeExtractedPath>" -r 9 > "<ExtractionPath>"

此处,9 是修订版号。

或者甚至更好:

hg cat "<FileToBeExtractedPath>" -r 9 -o "<ExtractionPath>"

To extract a specific revision of a specific file you can do this in Windows:

hg cat "<FileToBeExtractedPath>" -r 9 > "<ExtractionPath>"

Here, 9 is the revision number.

Or even better:

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