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.
The diff command is used to compare different revisions of files. The default action is to compare your working files with the revisions they were based on, and report any differences that are found. If any file names are given, only those files are compared.
You can call cvs diff with filenames, directories, or module names. If you don't give a filename, the current working directory is the default. Usually, you call cvs diff with at least one -r tag or -D date command option.
To see the changes that you have made since you checked out your local copy, use the command cvs diff. Keep in mind that cvs diff shows the difference between your working copy and the version it was based on.
You can use the history file (see section The history file) to log various CVS actions. To retrieve the information from the history file, use the cvs history command (see section history--Show status of files and users).
If you invoke it with a single -r or -D parameter, CVS compares the current copy in the working directory with the version in the repository. For example, if you check out revision 1.6 of Makefile, edit the file, then run cvs diff -r 1.6 Makefile, diff displays the changes you made to Makefile since you checked it out.
If for whatever reason you're still using cvs, you might find this refinement useful: 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. Show activity on this post.
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
This usually happens when several developers are working on the same file and you need to know which changes were made to a file since you last worked on it. The cvs diff command compares two revisions of a file and displays the differences.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With