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.
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.
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>
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.
© 2022 - 2024 — McMap. All rights reserved.