[ACCEPTED]-Getting diff between top two revisions of a file in CVS-cvs
You can use
cvs diff -r FIRSTREVISION -r SECONDREVISION filename
to compare two revisions.
It 9 may be possible to do the comparison you 8 require directly, but we can also automate 7 it by processing the results of cvs log filename
. So, for 6 example, you get the latest revision number 5 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 4 to merge these together, so create a BASH 3 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 2 then you'll be able to get your diff by 1 executing it with the filename as a parameter, e.g. ./lastdiff.sh
filename.
I had hoped there was an obvious cvs option 7 I was missing, but borrible's scripted solution 6 seems to be it. If for whatever reason 5 you're still using cvs, you might find this 4 refinement useful:
cvs diff $(cvs log $FILE |
grep "^revision" |
sed "s/^revision/-r/
2q") $FILE
This uses sed to both 3 grab the two latest revisions from a single 2 invocation of "cvs log" and create the -r 1 options directly from that output.
You can use cvs diff
to find out the differences 2 between the local checked out version and 1 the version present on the head.
cvs diff -r ver1 -r ver2 <FILE-NAME>
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.