Linux tips with CVS

Well, we use CVS for our version control at work, and yesterday we had to do something a bit unorthodox that entailed me updating an entire branch back to the trunk (long story). So, in the process, I was responsible for committing literally hundreds of files in our project, and after confirming and reconfirming that I had all the files up to date and modified correctly, I devised a way to “automate” a mass add and commit. In case this helps someone else out there, I thought I would share.

Anyway, if you use CVS to any extent, you are probably aware of how update (up for short) works and the fact that you can use the -n and -q modifiers to keep the actions from actually taking place so you can examine the results before carrying it out. Well, for quite some time now, I have been piping the results through a simple grep command to get me a list of specific files I need to work with. For instance, if I wanted just a list of files that I have created (not yet in CVS) and those I have locally modified in order to know a full list of files I have yet to commit, I would run something like this:

> cvs -nq up -d | grep ^[?M]

Obviously, the question mark is the new file listing and the M is for local modifications. If you have already added files to the repository but not yet committed them, you may also need to add the ‘A’ modifier in there to pull in those files as well (so your regexp for your grep would look like this instead: ^[?MA]).
Continue reading