获取 CVS 中文件前两个版本之间的差异

发布于 2024-11-17 16:13:39 字数 82 浏览 2 评论 0原文

有没有办法在 CVS 存储库中创建文件的前两个修订版本的差异?我不关心修订号和我本地的签出文件。我所需要的只是最后一次提交和提交前最后一次的黑白差异。

Is there way to create the diff of a file b/w its top two revisions in the CVS repo? I doesn't care about the revision numbers and my local checked-out file. All I need is, the diff b/w the last commit and the last before commit.

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

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

发布评论

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

评论(3

年少掌心 2024-11-24 16:13:39

您可以用来

cvs diff -r FIRSTREVISION -r SECONDREVISION filename

比较两个修订版。

也许可以直接进行您需要的比较,但我们也可以通过处理cvs log filename的结果来自动化它。因此,例如,您获得最新版本号

cvs log filename | grep ^revision | head -n 1 | cut -c 10-

和上一个版本号

cvs log filename | grep ^revision | head -n 2 | tail -n 1 | cut -c 10-

您想要将它们合并在一起,因此创建一个 BASH 脚本文件(例如名为 lastdiff.sh),其中包含

cvs diff -r $(cvs log $1 | grep ^revision | head -n 2 | tail -n 1 | cut -c 10-) -r $(cvs log $1 | grep ^revision | head -n 1 | cut -c 10-) $1

:将能够通过使用文件名作为参数执行它来获取差异,例如 ./lastdiff.sh 文件名。

You can use

cvs diff -r FIRSTREVISION -r SECONDREVISION filename

to compare two revisions.

It may be possible to do the comparison you require directly, but we can also automate it by processing the results of cvs log filename. So, for example, you get the latest revision number with

cvs log filename | grep ^revision | head -n 1 | cut -c 10-

and the previous revision with

cvs log filename | grep ^revision | head -n 2 | tail -n 1 | cut -c 10-

You want to merge these together, so create a BASH script file (say called lastdiff.sh) that contains:

cvs diff -r $(cvs log $1 | grep ^revision | head -n 2 | tail -n 1 | cut -c 10-) -r $(cvs log $1 | grep ^revision | head -n 1 | cut -c 10-) $1

and then you'll be able to get your diff by executing it with the filename as a parameter, e.g. ./lastdiff.sh filename.

终难愈 2024-11-24 16:13:39

您可以使用cvs diff来找出本地检出版本和头部存在的版本之间的差异。

cvs diff -r ver1 -r ver2 <FILE-NAME> 

You can use cvs diff to find out the differences between the local checked out version and the version present on the head.

cvs diff -r ver1 -r ver2 <FILE-NAME> 
月亮坠入山谷 2024-11-24 16:13:39

我曾希望我缺少一个明显的 cvs 选项,但 borrible 的脚本解决方案似乎就是这样。如果出于某种原因您仍在使用 cvs,您可能会发现这种改进很有用:

cvs diff $(cvs log $FILE |
grep "^revision" |
sed "s/^revision/-r/
2q") $FILE

这使用 sed 从一次“cvs log”调用中获取两个最新修订版本,并直接从该输出创建 -r 选项。

I had hoped there was an obvious cvs option I was missing, but borrible's scripted solution seems to be it. If for whatever reason you're still using cvs, you might find this refinement useful:

cvs diff $(cvs log $FILE |
grep "^revision" |
sed "s/^revision/-r/
2q") $FILE

This uses sed to both grab the two latest revisions from a single invocation of "cvs log" and create the -r options directly from that output.

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