如何查找 CVS 版本之间更改的行数?

发布于 2024-07-08 06:28:55 字数 320 浏览 9 评论 0原文

我花了一天的大部分时间对我们的一个项目的代码库进行一些基本的内务更改(用 log4j 替换所有 System.out.println() 调用)。

我有点好奇我用这组更改更新了多少行代码。

无论如何,是否可以使用 cvs diff 或其他命令来准确计算已更改的行数?

我试图

cvs diff -b -B -R

获取工作目录(以及递归子目录)中的所有更改,但对于每个更改的文件,它还会打印出文件/版本信息,这使得仅计算输出行数毫无用处。

有任何想法吗?

I've spent most of the day making what are basically some housekeeping changes to the codebase of one of our projects (replacing all System.out.println() calls with log4j).

I'm kind of curious how many lines of code I've updated with this set of changes.

Is there anyway with cvs diff or another command to get an accurate count of how many lines have changed?

I've tried

cvs diff -b -B -R

to get all of the changes in the working directory (and recursively the subdirectories), but for each file changed it also prints out file/version information, which makes just counting the lines of output useless.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

鸩远一方 2024-07-15 06:28:55

diffstat 实用程序是一个很好的工具,用于从 cvs、svn 或其他差异的输出中获取一些简单的指标。

The diffstat utility is a nice tool for getting some simple metrics from the output of cvs, svn or other diffs.

后知后觉 2024-07-15 06:28:55

从 diff 输出中过滤掉多余的行,然后对行进行计数。

例如,grep 仅以 < 开头的行 或>

cvs diff -b -B -R | egrep '^<|>' | wc -l

Filter out extra lines from the diff output and then count the lines.

For example, grep only lines starting with < or >

cvs diff -b -B -R | egrep '^<|>' | wc -l
心清如水 2024-07-15 06:28:55

您可以简单地将 cvs diff 的输出传输到 diffstat。

You can simply pipe output of cvs diff to diffstat.

赴月观长安 2024-07-15 06:28:55

验证您是否已使用类似以下内容更改了所有实例怎么样:

find . | egrep -v -e '(CVS|<other patterns you don't want>)' | \
    xargs egrep -e 'System\.out\.println[(][)]' | wc -l

这应该给您零。

然后用“log4j”替换第二个egrep中的正则表达式应该让 wc -l 返回您更改的行数。

HTH。

干杯,

罗布

What about verify that you've changed all instances with something like:

find . | egrep -v -e '(CVS|<other patterns you don't want>)' | \
    xargs egrep -e 'System\.out\.println[(][)]' | wc -l

that should give you zero.

Then replacing the regex in the second egrep with 'log4j' should have wc -l returning the number of lines you've changed.

HTH.

cheers,

Rob

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