MATLAB: How to make use of the CVS Source Control System in MATLAB 7.6 (R2008a) on a Linux machine

controlMATLABversion

I am trying to "checkin" the files I created to the CVS repository using the following command in MATLAB:
checkin('foo1.m','comments','my_comment1');
However, the function "foo1.m" is not added to the repository and I get the following error message:
??? Error using ==> cvs at 64
cvs add: in directory .:
cvs [add aborted]: there is no version here; do 'cvs checkout' first
Error in ==> checkin at 78
feval(system, fileNames, arguments);

Best Answer

In order to "checkin" a file to the CVS repository, either the relevant "file" or a "project folder" must first be checked out. The following steps illustrates the case where a "project folder" is used to checkin a file; additionally, it also assumes that the CVS application has already been installed and is working properly.
Step1: Create a CVS root repository and set up the CVSROOT environment variable like so:
mkdir cvsroot
cvs -d /home/jyoung/cvsroot init
setenv CVSROOT /home/jyoung/cvsroot
  • Note that the environment variable CVSROOT, defined above using the SETENV command, will only persist until the current linux session is closed. Thus, the customer would need to find out how to set the environment variable permanently on his own as there is no generic way of accomplishing this task.
Step2: Create and add the "project folder" (i.e. myproj1) to the repository like so:
mkdir myproj1
cd myproj1
cvs import -m 'myproj1 comment' myproj1 myproj1_name ver1
  • Note that if the import operation was successful, you should see "myproj1" folder added to the "cvsroot" directory. In which case, you might want to delete the original "myproj1" folder.
Step3: Make sure that the appropriate Source Control System has been selected in MATLAB under File->Preferences->General->Source Control. Then you can execute the following command in MATLAB to checkout the "project folder" you created earlier:
checkout('myproj1','lock','off'); % this command results in the project folder to be created in your current working directory
checkout('myproj1'); % this command locks the project so that access to the file for others is read-only
  • Note that if the above commands are successful, you should see a "myproj1" folder created in the current working directory.
Step4: Create/ Modify files inside the "working project folder" created in Step3.
Step5: After completing the modifications, you can check-in your files using the following commands in MATLAB:
- Check-in a modified version of a file that was already in the Project folder:
checkin('foo1.m','comments','Script 1');
- Check-in a new file created in the Project folder:
checkin('new_foo2.m','comments','New Script 2');
checkin('new_foo2.m','comments','New Script 2');
  • Note that for new files, the above command must be executed twice since the first execution only signals CVS that the file should be added to the repository, while the second execution "commits" the file into the repository.