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

我正在使用mercurial进行目录中几个文件的版本控制。 假设我有10个提交(10个变更集或修订版)。 我只想查看某个特定的文件,比如thisFile.py,在第七版中是如何查看的。 我不想恢复到这个较旧的版本。 我不想去修改或修复以前版本中的任何错误。 我只是想看看它,而不以任何方式影响最新版本的文件或mercurial历史。 有没有简单的方法来做到这一点?


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

hg cat path_to/myfile.cpp -r 46

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


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

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

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

这里,9是修订号。

甚至更好:

hg cat "<FileToBeExtractedPath>" -r 9 -o "<ExtractionPath>"
链接地址: http://www.djcxy.com/p/37549.html

上一篇: how to view previous version of a file in Mercurial

下一篇: Mercurial to Mercurial to Subversion Workflow Problem