如何获取 Mercurial 中文件的修订计数
使用模板,我想了解一个文件在所有变更集中被修改了多少次。换句话说,有多少变更集包含该文件。 有办法做到吗?可以通过关键字扩展来完成吗?
是的,我意识到这并不是 Mercurial 的真正目的。我的要求很糟糕:)
Using templates, I want to find out how many times a file has been revised across all changesets. So, put another way, how many changesets feature that file.
Is there a way to do it? And can it be done with the Keywords extension?
And yes, I realise it's not really what Mercurial is about. I have sucky requirements:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
hg log -q 文件名 | wc -l 将输出变更集的数量
hg log -q filename | wc -l
will output amount of changesets跟踪文件是 VCS 的一项正常功能,当文件发生更改时,只需运行 hg log THE_FILENAME 即可查看影响某个特定文件的所有更改集。
要对它们进行计数,请运行例如
hg log THE_FILENAME | grep -c“^变更集”
。It is a normal feature of an VCS to track, when a file was changed, just run
hg log THE_FILENAME
to see all changesets which affect one specific file.To count them, run for example
hg log THE_FILENAME | grep -c "^changeset"
.我想我应该在此处的列表中再添加一个选项,因为 grep 和 wc(字数统计)可能在您的控制台中不可用(尤其是 Windows 用户)。 PowerShell 中有一个等效的功能:
hg log -q filename | Measure-Object
这将默认返回计数(正如您所看到的,您可以使用 Measure-Object)
如果您对整个存储库完成了多少次提交感兴趣,您可以省略 -q 文件名参数
:测量对象
I thought I'd just add one more option to the list here since grep and wc (word count) may not be available in your console (Windows users especially). There is an equivalent functionality in PowerShell:
hg log -q filename | Measure-Object
This will return the count by default (and as you can see there are other options you can play with using Measure-Object)
And if you are interested in how many commits you have done for the entire repository you can omit the -q filename parameter:
hg log | Measure-Object