CVS Status Like the One in SVN - Bash Script
Yeah, I know - CVS is an archaic mess and there's not a single reason in the entire world to be using it in 2009... except if you are a Drupal contributor and need to maintain a module (or contribute to one) on drupal.org. For reasons that are complicated and don't matter to this blog post, Drupal uses CVS and there's no word that it will switch to something decent like SVN (git users - stay quiet), any time soon.
Fine, but when you actively use a version control, you need to be able to quickly see modified files. Files that need to be added or committed to version control. If you use a GUI CVS client - fine, but I don't. I do most of my development on remote Linux servers and command-line is my only cvs tool. Now that can get tricky in many ways. One of the ways is 'cvs status' command.
For reasons that I will never understand, CVS authors decided to show status of all files when you run this command over a directory. Plus they show 5 lines of information for each file. In the end - you can't see anything, if you are just looking for the names of modified files. Classic case of "less is more" (by the way - fixed in SVN, the improved CVS).
To emulate the behaviour of "svn status" that just shows a list of modified and new files, I wrote a quick bash script that hopefully somebody else, unlucky enough to be stuck with CVS, may find useful, as well:
#!/bin/sh
patterns=(
'?'
'Locally Added'
'Locally Modified'
)
for i in "${patterns[@]}"
do
cvs -Q status -R . | grep -i "$i"
done


Slight improvement
My connection to a CVS server that I work with code on is quite slow, and it also displays a banner when I log in (its a government lab server) that gets written to std error. The following modification to your script not only speeds it up by a factor of 3, but also removes the banner. (I've added it to my bash profile as a function cvss)
function cvss { patterns=( '?' 'Locally Added' 'Locally Modified' ) (cvs -Q status -R . > .cvs_status) 2> /dev/null for i in "${patterns[@]}"; do cat .cvs_status | grep -i "$i" done rm .cvs_status }suppress tmp .cvs_status, create in home dir
Just one change I made to suppress the output of .cvs_status
function cvss { patterns=( '?' 'Locally Added' 'Locally Modified' ) (cvs -Q status -R . > ~/.cvs_status) 2> /dev/null for i in "${patterns[@]}"; do cat ~/.cvs_status | grep -i "$i" done rm ~/.cvs_status }Thanks - I'll pass this onto
Thanks - I'll pass this onto our programmers.
thanks
Thanks, this little script will help me keep my sanity...
-a svn/git user forced into using cvs at work :)
You might want to add the
You might want to add the "Needs Checkout" status for files which were deleted.
python script with more modern scm like output
I wrote a python script that also handles subdirs and uses a one char status marker:
$ cvss
? unknown
O common/Makefile.common
O devel/Makefile
? devel/xz-4.999.8beta
? devel/xz-4.999.8beta.tar.gz
M devel/xz.spec
O EL-5/Makefile
More information can be found in my blog post about it:
http://blogs.23.nu/till/2010/01/cvs-status-parser-script/
cvs -n -q update
You can just use "cvs -n -q update" to get a compact status output. (The "-n" makes it not actually perform the update, the "-q" suppresses the "cvs update: Updating ." type messages.) This trick is what Cervisia uses.