如何以编程方式获取 CVS 结账的最新提交日期

发布于 2024-07-25 09:43:17 字数 340 浏览 4 评论 0原文

对于我正在使用 CVS 实现二分的脚本,我想弄清楚当前结账的“时间戳”是什么。 换句话说,如果我位于分支/标签上,我想知道提交到该分支/标签的最后一个时间戳。 如果我在头上,我想知道头上的最后一个时间戳。

我知道这并不能 100% 保证,因为 cvs 签出可以在不同的时间戳/修订/...有不同的文件,但在大多数情况下正确的解决方案对我来说很好。

天真地,我认为这

cvs log -N | grep ^date: | sort | tail -n 1 | cut -d\; -f1

会做到这一点,但事实证明它会遍历所有分支/标签的整个提交历史记录。

For a script I'm working on to implement bisection using CVS, I want to figure out what the 'timestamp' is of the current checkout. In other words, if I'm on a branch/tag, I want to know the last timestamp something got commited to that branch/tag. If I'm on head, I want to know the last timestamp on head.

I know this is not 100% guaranteed, since cvs checkouts can have different files at different timestamps/revisions/..., but a correct-in-most-cases solution is fine by me.

Naively, I thought that

cvs log -N | grep ^date: | sort | tail -n 1 | cut -d\; -f1

was going to do it, but it turns out it goes through the whole commit history, for all branches/tags.

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

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

发布评论

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

评论(3

ぽ尐不点ル 2024-08-01 09:43:18

当我寻找一种通过标记以编程方式获取 CVS 中文件的时间戳的方法时,我遇到了这个线程。 其他答案就足够了,但我想添加自己的答案,如下所示:

cvs rlog -r<tag_or_revision> <file_path> | grep ^date | cut -c 7-25

我注意到 -r 之间不能有空格。 似乎一系列标签或修订版 –r: 也是合适的。

我还想获取包括完整时间戳的日期,并发现使用 cut 对静态字符范围执行子字符串似乎比使用 sed 更容易。

最后,最重要的是,对于我的需求,我发现 rlog 命令可用作远程日志,而 log 命令要求实际检出文件。 就我而言,我只是想根据标签查找文件的时间戳,而必须检查文件以执行日志的附加步骤是一个主要的阻碍,所以我只想添加 rlog > 命令可能对您的需要有用。

I came across this thread when looking for a way to grab the timestamp for a file in CVS via a tag programmatically. The other answers are sufficient but I wanted to add my own as follows:

cvs rlog -r<tag_or_revision> <file_path> | grep ^date | cut -c 7-25

I noticed that there cannot be a space between -r and <tag>. It seems a range of tags or revisions as –r<tag1>:<tag2> is also appropriate.

I also wanted to get the date including the full timestamp and found that using cut to perform a substring on the static range of characters seemed easier than using sed.

Finally, and most importantly for my needs I found that the rlog command works as a remote log, whereas the log command requires that the files are actually checked out. In my case I just wanted to lookup the timestamp for files based on a tag and the added step of having to check out the files to perform a log was a major deterrent so I just wanted to add that the rlog command may be useful for your needs.

时光是把杀猪刀 2024-08-01 09:43:17

分支上的 CVS 文件具有不同的时间戳,因此选择任何一个文件来获取该分支的最后时间信息的准确性几乎不值得。

但是,如果有一些文件经常更改,情况会更好。
例如,在我的一个基地中,有一个 version.h 文件,该文件在每次版本转换(次要或主要)时更新。 这可以用于当前版本的时间信息(同样不准确于分支中的所有文件,但它确实给出了底线)。

因此,如果您知道一个可以为您提供底线值的文件,

cvs log path/to/version.h -r branch/tag | grep ^date | sort | tail -1

将为您提供该文件的最后时间戳。


如果您可以像这样枚举基础的整个文件集,

find /base/dir -type f | grep -v CVS > files.txt

那么您可以为每个文件循环上面的 cvs 命令,

rm -f allFiles.txt
for f in $(<files.txt); do cvs log $f ...etc... tail -1 >> allFiles.txt
sort allFiles.txt | tail -1

排序的最后一行将为您提供最近提交的确切日期。
唉,你不会得到文件名(这也可以用更多的 fu 来完成)

CVS files on a branch being at different timestamps, the accuracy of picking any one file to get the last time-info for the branch is hardly worth.

But, it can get better if there is some file which will be changed often.
For, example, in one of my bases, there is a version.h file which is updated on every version shift (minor or major). That can be used for time-info on the current version (again not accurate to all the files in the branch, but it does give a bottom line).

So, if you know a file that can give you a bottom line value,

cvs log path/to/version.h -r branch/tag | grep ^date | sort | tail -1

will give you the last timestamp for that file.


If you can enumerate the entire file set of the base like this,

find /base/dir -type f | grep -v CVS > files.txt

then, you can loop the cvs command above for each file,

rm -f allFiles.txt
for f in $(<files.txt); do cvs log $f ...etc... tail -1 >> allFiles.txt
sort allFiles.txt | tail -1

Last line of the sort will give you exact date for the most recent commit.
Alas, you will not get the file name (which can also be done with some more fu)

陌伤浅笑 2024-08-01 09:43:17

获取文件更改的最新时间的更快方法(基于 nik 给出的答案)是:

cvs log -bd `date +%Y-%m-%d` ChangeLog | grep ^date

如果您只想获取日期,请使用:

cvs log -bd `date +%Y-%m-%d` ChangeLog | grep ^date | sed 's/date: \([^ ]*\).*/\1/'

这使用 -b 标志,该标志使用默认分支和 -d 标志允许您告诉 CVS 您只关心给定时间之前的最新版本。 然后 `` 表达式传递当前日期作为限制,为您提供最近的提交。

在 gnuplot CVS 存储库上,使用 -d 标志将执行时间从 ~4s 减少到 ~1.5s。

A faster way to get the latest time a file was changed (which builds upon the answer given by nik) is:

cvs log -bd `date +%Y-%m-%d` ChangeLog | grep ^date

If you want to get only the date, use:

cvs log -bd `date +%Y-%m-%d` ChangeLog | grep ^date | sed 's/date: \([^ ]*\).*/\1/'

This uses the -b flag which uses the default branch and -d which allows you to tell CVS you only care about the latest version up until a given time. The `` expression then passes the current date as the limit, giving you the most recent commit.

On the gnuplot CVS repository, using the -d flag decreases the execution time from ~4s to ~1.5s.

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