Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programatically get the latest commit date on a CVS checkout

Tags:

cvs

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.

like image 295
Thomas Vander Stichele Avatar asked Jun 25 '09 15:06

Thomas Vander Stichele


People also ask

How do I check my cvs commit history?

Whenever you commit a file you specify a log message. To look through the log messages which have been specified for every revision which has been committed, use the cvs log command (see section log--Print out log information for files).

What is cvs commit?

cvs commit Put your changes in CVS The commit command is used to place the changes you made to files in your local working directory back into the CVS repository.

Do git commits have timestamp?

There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.

How do I commit a code to cvs?

Technically, the way to send files to the CVS repository is to add them to Eclipse's version control and then commit them. You do that by right-clicking the files and selecting Team→ Add to Version Control. Then select Team→ Commit to commit the files.


1 Answers

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)

like image 92
nik Avatar answered Oct 13 '22 21:10

nik