计算两个版本之间的代码行数

发布于 2024-10-05 21:10:12 字数 91 浏览 0 评论 0原文

有没有什么方法可以比较两个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

寒尘 2024-10-12 21:10:12

如果您需要比较+查看+编辑行,那么 VonC 推荐的 WinMerge 非常好,但是如果您需要比较代码行数(计数),那么使用 sloc diff 工具,例如 ProjectCodeMeterCLOC会更好。

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.

万劫不复 2024-10-12 21:10:12

虽然您可以使用任何差异/合并工具(例如 Windows 上的 WinMerge)来对所有文件集进行比较,我建议使用:

  • 两个具有正确配置的 ClearCase 视图来选择正确的版本
  • 两个动态视图,以便快速获取所有相关版本(快照视图加载时间太长)

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:

  • two ClearCase views with the right configuration to select the right versions
  • two dynamic views in order to quickly get all the relevant versions (snapshot views would be too long to load)
不爱素颜 2024-10-12 21:10:12

有很多合并/差异工具。
我使用 meld 它具有出色的可视化效果以及文件和目录比较的处理能力

there are loads of merge/diff tools.
i use meld which has great visualisation and handling of file and directory comparision

茶底世界 2024-10-12 21:10:12

如果你唯一想做的就是计算行数并且你正在使用 svn 我建议你运行

svn blame -r N:M | wc -l

我无法检查这个命令行现在是否正常工作但想法是在 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

svn blame -r N:M | wc -l

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 run wc -l (line count).

I believe that every source control has command similar to svn blame.

榆西 2024-10-12 21:10:12

您可以按照 VonC 的建议使用两种不同的视图。或者,如果您确切知道要查找的内容,则可以使用 file@@version 语法直接访问这两个版本。如果你要自动化某些东西(我建议用 java 实现某些东西),那么两个视图可能是最好的选择。

当您说“比较两个clearcase版本之间的代码行”时,我假设您正在寻找标准 cleartool diff 以外的东西(顺便说一句,KDiff3 是一个优秀的 diff 实用程序,它具有 Clearcase 集成,我强烈推荐它),并假设它更多地在您正在寻找的“行数”方向。

然而,仅计算行中的差异只能提供有限的信息,通常了解构成差异的行是否大部分被添加或删除也很有趣。要提供此类信息,您可以使用 diffstat (请参阅 此答案作为示例输出)。

在我的上一份工作中,我编写了一个java gui来运行

diff -u file@@/main/branch1/LABEL1 file@@/main/branch2/LABEL2 | diffstat

给​​定的两个标签,迭代多个文件,但随后我依赖于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

diff -u file@@/main/branch1/LABEL1 file@@/main/branch2/LABEL2 | diffstat

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文