Monthly Archives: November 2016

Making a CVS project read-only

Published / by Steve

As I posted last time, I’ve been incrementally moving CVS projects to Git repositories. After each project is migrated I’ve been making its portion of the CVS repository read-only, so that access is still possible in case we need to go back and look at something but new commits can’t come in and cause the CVS repository to get out of sync with the Git repository.

The Internet contains a number of ways to make a CVS project read-only; the first one that actually worked for me was to set up a pre-commit hook for the project that blocks commits for that project. It’s based on the “Your Catchphrase Here!” post Read-only CVS access for only certain projects, in particular the read-only-project.sh script.

Pre-commit hooks are defined in the CVSROOT project, so the first step was to check that out with ‘cvs checkout CVSROOT’. Next I created a read-only-project.sh script based on the “Your Catchphrase Here!” blog. I made it executable so I could test locally; I’m not sure if this is necessary but since it was working I left it. Then I added it to CVS and committed.

But initially the hook didn’t work. In order for the hook to run the script, the CVS repository needs to contain the file “read-only-project.sh”, not just the file “read-only-project.sh,v”. To do that I modified the file checkoutlist (in the CVSROOT project). I added read-only-project.sh to its contents and committed. As soon as that finished the CVSROOT project directory on the CVS server now contained the file “read-only-project.sh”.

The next step was to modify the commitinfo file, which is where the hooks are configured. I added a line like
^project-name /[path]/read-only-project.sh
This is the biggest difference from the “Your Catchphrase Here!” blog: I don’t have anything after project name and don’t have anything after the script name either. I don’t know why this is, it’s just the result of trial and error. For the record the CVS server I’m working with is version “1.11.23 (c) 2006”.

Once set up, this approach works nicely. Commits are blocked and you get informative message explaining why when you try to commit.