计算存储库中随时间变化的代码行数
有没有办法获取 Mercurial 存储库中特定时间段内更改的代码行数?类似于 statsvn 所做的事情会很棒,但是任何计算其中更改的代码行数的东西6 个月就可以了(包括 hg log 参数的巧妙组合)。
Is there a way to obtain the number of changed lines of code over a certain time period in a mercurial repository? Something along the lines of what statsvn does would be great, but anything counting the number of changed lines of code within 6 months will do (including a clever combination of arguments to hg log).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
hg 流失扩展 就是您想要的。
您可以通过 hg 活动 或 汞图表。
The hg churn extension is what you want.
You can get visual results with hg activity or hg chart.
编辑:
hg diff
和hg log
都支持--stat
选项,只能为您执行此操作更好更快。我创建了一个名为
lines
的别名来为我计算更改的行数(不一定是代码行数)。尝试将此别名放入您的 .hgrc 文件中:然后首先传递修订版本,然后传递任何可选参数:
hglinestip
或hglines123:456 -u brian
有时您想知道更改的行数(不包括仅空格的更改)。这需要在下面使用
diff -w
而不是log -p
。我为此设置了一个linesw
别名:hglineswtip
或hglines123:456
请注意,它们的行为略有不同,因为
diff< /code> 和
log
的行为不同 - 例如,log
将采用--user
参数,而diff
不会,并且在传递范围时,log
将显示在范围内给定的第一个修订版中提交的更改,而diff
则不会。这仅使用 bash 进行过测试。
Edit:
hg diff
andhg log
both support a--stat
option that can do this for you, only better and quicker.I made an alias called
lines
to count changed lines (not necessarily lines of code) for me. Try putting this alias in your .hgrc file:Then pass it the revision first, followed by any optional arguments:
hg lines tip
orhg lines 123:456 -u brian
Sometimes you want to know the number of lines changed excluding whitespace-only changes. This requires using
diff -w
underneath instead oflog -p
. I set up alinesw
alias for this:hg linesw tip
orhg lines 123:456
Note they behave slightly differently because
diff
andlog
behave differently -- for example,log
will take a--user
parameter whilediff
will not, and when passing a range,log
will show changes commited in the first revision given in the range, whilediff
will not.This has only been tested using bash.
我需要这样做,并花了相当多的时间来研究 hg churn 扩展和类似的解决方案。
最后,我发现最适合我的是 CLOC(计算代码行数):http://cloc.sourceforge.net/
您可以给它两个包含项目的两个版本的文件夹,它会计算所有相同、修改、添加、删除的行。它可以识别多种语言并逐项列出代码、注释和空行。
为了使用它,我将代码的两个版本从 Hg 提取到两个并行文件夹中,然后使用 cloc --diff --ignore-whitespace
I needed to do this, and spent quite a bit of time with the hg churn extension and similar solutions.
In the end, I found that what worked best for me was CLOC (Count Lines of Code): http://cloc.sourceforge.net/
You can give it two folders containing two versions of a project, and it will count all of the lines that are the same, modified, added, removed. It recognises multiple languages and itemises code, comments and blank lines.
To use it, I pulled out the two versions of my code from Hg into two parallel folders, and then used cloc --diff --ignore-whitespace