如何查看 Mercurial 文件的修订历史?

对于 Mercurial 存储库中的给定文件,如何查看修订历史记录?

如何区分文件的两个修订版本?

理想情况下,可以使用可视化工具完成所有这些工作(我们使用 ExamDiff 完成一些其他差异)。

我想说这是基本的源代码控制功能,但我似乎不知道如何做到这一点与 Mercurial。

82124 次浏览
hg log file


hg diff -r 10 -r 20 file

The hgk extension gives you hg view file command that shows a visual history, from which you can diff/vdiff arbitrary pair of revisions.

TortoiseHg gives you thg log file command that does the same thing but looks better.

For readability

hg diff -r revision1:revision2 file

Where revision1 and revision2 can be a tag, changeset etc.

If you use TortoiseHg: Windows users can use Windows Explorer and view the revision history by right-clicking on the file.

For Linux users, you can do it within TortoiseHg but it took me a while to figure out how. You need to right-click on the desired file and select "File History". However, for some mysterious reason, the file needs to be unaltered. Furthermore, to find the desired file there are two options:

In ### revision set query### one can type:

file("**<myfile>")

The double ** are necessary to search directories recursively. This gives you immediately an list of all repositories in which the desired file was changed.

Alternatively, next to the ### filter text ### click first on the question mark sign and select "clean" to see all files in the repository. Then inside the ### filter text ### box you can narrow down the number of files shown.

Alternatively, Linux users can do it from a terminal as suggested by Geoffrey Zheng above:

thg log file