Friday, August 1, 2014

Emptying an entire CVS directory tree

Another one on CVS.
Keeping old projects in which one would spend so much effort to do a full migration to another version control system than just learn to live with the CVS limitations makes you find some weird workarrounds...
In CVS you can't rename a directory, you can't either remove a directory. In stead you can remove all files in the directory tree you want to remove, and do a "CVS update -P" pruning empty directories.
So, how to easily empty an entire directory tree? The find has a "-not" operator which lets you make an inverse logic. For example, you can find -name CVS to locate the CVS control directories and find -not -name CVS to find files other than the CVS control direcoties.
Finally, to empty an entire directory, but not touching the CVS control files and folders, one could run the following line:
find . -not -name CVS -a -not -name Entries -a -not -name Root -a -not -name Repository -not -type d | xargs rm; cvs remove

No comments:

Post a Comment