如何在Mercurial中打印特定文件的所有修订版的内容?

时间:2022-09-16 00:39:03

Let's say I have 5 revisions of a README file. How do I view them all in Mercurial?

假设我有一个README文件的5个修订版。如何在Mercurial中查看它们?

It would be nice to be able to limit the output, similar to:

能够限制输出会很好,类似于:

hg log -l 10

I'm using PowerShell, so combined solutions are also welcome.

我正在使用PowerShell,因此也欢迎使用组合解决方案。

1 个解决方案

#1


I don't know Powershell syntax, but you're looking for the hg cat command. Combined with the answer to your other question I would do it like this in a Unix shell (zsh in my case):

我不知道Powershell语法,但你正在寻找hg cat命令。结合你的另一个问题的答案,我会在Unix shell中这样做(在我的情况下为zsh):

for r in $(hg log --template '{rev} ' README); do hg cat -r $r README; done

I first get all the revisions in which README was changed. They will be put into a big string like this:

我首先得到所有修改README的修订版。他们将被放入一个像这样的大字符串:

% hg log --template '{rev} ' README
822 804 688 681 629 539 538

You then iterate over these revision numbers and call hg cat on each.

然后迭代这些修订号并在每个上调用hg cat。

#1


I don't know Powershell syntax, but you're looking for the hg cat command. Combined with the answer to your other question I would do it like this in a Unix shell (zsh in my case):

我不知道Powershell语法,但你正在寻找hg cat命令。结合你的另一个问题的答案,我会在Unix shell中这样做(在我的情况下为zsh):

for r in $(hg log --template '{rev} ' README); do hg cat -r $r README; done

I first get all the revisions in which README was changed. They will be put into a big string like this:

我首先得到所有修改README的修订版。他们将被放入一个像这样的大字符串:

% hg log --template '{rev} ' README
822 804 688 681 629 539 538

You then iterate over these revision numbers and call hg cat on each.

然后迭代这些修订号并在每个上调用hg cat。