|< Day Day Up >|
Recipe 18.6. Using CVS for a Single-User Local Repository
You would rather use CVS for your local, personal repository because you plan to also use it for larger projects, and you want to stick to learning a single system. Or your personal repository is getting complex, so you need the additional abilities of CVS to manage it, such as more complex directory structures, and being able to checkout multiple files or entire directories at once.
CVS scales nicely from small personal projects to large projects without a problem. Installation is simple. Both RPMs and .debs are named "cvs"; if you prefer to install from sources, get them from https://www.cvshome.org/.
After installing CVS, create your personal repository with these commands:
$ mkdir ~/cvsroot $ chmod -R 700 ~/cvsroot $ cvs -d ~/cvsroot init
Now select a directory of files to store in your repository. Change to that directory, and import the directory into your CVS repository:
$ cd /scripts $ cvs -d ~/cvsroot import scripts jenns_configs version_1 N scripts/useradd.txt N scripts/postfix_ube.txt N scripts/logparse.pl No conflicts created by this import
During the import, your default editor will open, displaying this text:
CVS: ----------------------------------------------------- CVS: Enter Log. Lines beginning with `CVS:' are removed automatically CVS: CVS: -----------------------------------------------------
Enter your project description here (e.g., "Jenn's system administration scripts for Slackware 9"). Make this detailed enough so that six months from now, it will still make sense.
To check out a file for editing, you must first create a working directory. This directory must be outside of the directory that holds your CVS repository. Then change to the working directory, and check out a file:
$ mkdir ~/sandbox $ cd ~/sandbox $ cvs -d ~/cvsroot checkout scripts/postfix_ube.txt cvs checkout: Updating scripts U scripts/postfix_ube.txt
Checking out files from the CVS repository creates a CVS sandbox in your working directory. The sandbox is the local working directory where all of your actual work takes place. When you check out files from CVS, a batch of CVS admininistrative files are installed in the sandbox. Always work from a sandbox; never enter a CVS repository to edit files. Your sandbox can have any name you choose.
The file you just checked out is in the scripts directory, so that is your sandbox, and you should change to that directory to edit the file:
$ cd scripts $ vim postfix_ube.txt
$ cvs commit cvs commit: Examining . /home/jenn/cvsroot/scripts/postfix_ube.txt,v <-- postfix_ube.txt new revision: 1.2; previous revision: 1.1
Again, your default editor will open, and you'll be asked to write a log entry detailing your changes.
As long as you are in the sandbox, which in this example is ~/sandbox/scripts, you can omit specifying the name of the repository for checkouts and commits.
cvs [ global_options ] command [ command_options ] [ command_args ]
CVS is all about record keeping. Take the time to make useful log entries—you will thank yourself many times during the life of your CVS project.
You can name your CVS root directory anything you like.
jenns_configs and version_1 are the vendor tag and release number, respectively. While you may not care about these, CVS requires them. The vendor tag usually identifies whoever supplies the source files, and the version number is the starting version number for the project.
You can collect all the files you want for a new project in a temporary directory, then delete it after they are safely imported into the repository. Test the import by checking out a sandbox and verifying that the files in the sandbox are correct before you delete the originals. Once you have created your sandbox and imported the files into the repository, you don't need to keep the originals; they're just taking up space.
A single directory, and all of its files and subdirectories, is a project. Every project must be stored in a directory, even if it is just a single file.
You can check out single files, space-delimited lists of files, or entire directories:
$ cvs checkout scripts/postfix_ube.txt $ cvs checkout scripts/postfix_ube.txt scripts/logparse.pl $ cvs checkout scripts
18.6.4 See Also
|< Day Day Up >|