计算两个版本之间的代码行数
有没有什么方法可以比较两个clearcase版本之间的代码行,或者无论版本控制器如何,我想比较两个不同的版本,比如比较主分支与开发分支。我正在寻找 Java 的这个主题
Is there any way to compare lines of code between two clearcase versions , or for that matter whatever the version controller , I want to compare two different version say compare main branch with the development branch. I'm looking this topic for Java
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您需要比较+查看+编辑行,那么 VonC 推荐的 WinMerge 非常好,但是如果您需要比较代码行数(计数),那么使用 sloc diff 工具,例如 ProjectCodeMeter 或 CLOC会更好。
if you need to compare+view+edit the lines then VonC's recommendation of WinMerge is excellent, but if you need to compare the Number Of Lines Of Code (count) then a sloc diff tool like ProjectCodeMeter or CLOC would be better.
虽然您可以使用任何差异/合并工具(例如 Windows 上的 WinMerge)来对所有文件集进行比较,我建议使用:
While you can use any diff/merge tool (like WinMerge on Windows) to get a comparison on an all set of files, I would recommend using:
有很多合并/差异工具。
我使用 meld 它具有出色的可视化效果以及文件和目录比较的处理能力
there are loads of merge/diff tools.
i use meld which has great visualisation and handling of file and directory comparision
如果你唯一想做的就是计算行数并且你正在使用 svn 我建议你运行
我无法检查这个命令行现在是否正常工作但想法是在 2 之间使用 svnblame有趣的修订(N 和 M),然后运行 wc -l (行数)。
我相信每个源代码管理都有类似于 svnblame 的命令。
If the only thing you want to do is to count lines and you are using svn I suggest you to run
I cannot check that this command line is working right now but the idea is to use
svn blame
between 2 interesting revisions (N and M) and then runwc -l
(line count).I believe that every source control has command similar to
svn blame
.您可以按照 VonC 的建议使用两种不同的视图。或者,如果您确切知道要查找的内容,则可以使用
file@@version
语法直接访问这两个版本。如果你要自动化某些东西(我建议用 java 实现某些东西),那么两个视图可能是最好的选择。当您说“比较两个clearcase版本之间的代码行”时,我假设您正在寻找标准
cleartool diff
以外的东西(顺便说一句,KDiff3 是一个优秀的 diff 实用程序,它具有 Clearcase 集成,我强烈推荐它),并假设它更多地在您正在寻找的“行数”方向。然而,仅计算行中的差异只能提供有限的信息,通常了解构成差异的行是否大部分被添加或删除也很有趣。要提供此类信息,您可以使用 diffstat (请参阅 此答案作为示例输出)。
在我的上一份工作中,我编写了一个java gui来运行
给定的两个标签,迭代多个文件,但随后我依赖于cygwin的bash、diff和diffstat,我不知道这里有任何纯java替代品。
You can as VonC suggest use two different views. Alternatively you can use the
file@@version
syntax to access both versions directly if you know exactly what you are looking for. Two views are probably the best option if you are going to automate something (which implementing something in java suggests to me).When you say "compare lines of code between two clearcase versions" I assume you are looking for something other than the standard
cleartool diff
(btw, KDiff3 is an excellent diff utility which have clearcase integration, I highly reccommend it), and assume it is more in the "count number of lines" direction you are looking.However just counting difference in lines will only give limited information, usually it is also interesting to know if the lines that constitutes the difference are mostly added or removed. To give this kind of information you can use diffstat (see this answer for example output).
At my last job I wrote a java gui for running
given two labels, iterating over several files, but I then depended on bash, diff and diffstat from cygwin, I am not aware of any pure java alternatives here.