views:

750

answers:

3

How do I prevent a developer from committing changes into a particular branch in CVS?

Recently, a fellow developer committed code into the main branch, leaving me with a lot of rolling back to do ;-( How can I prevent this?

+1  A: 

Change the access permissions for this user for this particular branch to read only.

Honestly, I don't have a clue. But this may help: CVS Access Control List Extension Patch

Eduard Wirch
Could you please tell me how I could do that? A little spoon feeding never hurt anyone ;-)
Preets
If you use are on windows make the repository directory ready-only, on linux use chmod to change the access permission. This will prevent "accidental" commits.
Mohit Ranka
+1  A: 

Might not be the case but if you're running CVSNT on the server you can simply use the cvs chacl command. See http://cvsnt.org/manual/html/chacl.html for details. I haven't used TortoiseCVS in a while but I guess there might even be a GUI option for that in there (your server would still have to be CVSNT for it to actually work).

Note that TortoiseCVS is just a graphical frontend for the CVSNT client. Your questions will be easier to answer if you supplied some information about your server.

Oliver Giesen
thank you for your response, will check the svr details
Preets
A: 

This approach works for me:-

1) Create a shell script that checks the branch being committed against a parameter. I store this in CVSROOT for convenience, but it can be anywhere on the CVS server.

#!/bin/bash

if [ -f CVS/Tag ]
then
  TAG=`cat CVS/Tag`
else
  TAG=THEAD
fi

if [ "$TAG" == "T$1" ]
then
  echo Cannot commit to $1
  exit 1
else
  echo Commit ok
fi
exit 0

Then modify the commitinfo file to run this script for a particular branch:-

ALL /cvs/repos/CVSROOT/checkbranch.sh YOUR-BRANCH-NAME-HERE

This will then cause the script to run for all checkins. It will pass the branch name as a parameter. The script will compare the parameter against the branch for the code being checked in, and will throw an error if they match. If you want to lock multiple branches, then add multiple lines to commitinfo.

Obviously if a developer really wants to commit something, they can hack the commitinfo file, but it prevents mistakes rather than deliberate attempts to break things.

Mark