CVS

From JasonAntmanWiki
Jump to: navigation, search


CVS is a Version Control System.

Contents

Quick Reference

Modules

Modules are the top-level components in a repository. They appear as subdirectories of the repository itself.

To add a directory of "stuff" as a module:
1) cd into the directory you want to add
2) run cvs import -m "First import" ModName tag1 tag2. This will import your CWD and all subdirectories as a module named ModName with an initial log message of "First import", vendor tag "tag1" and release tag "tag2".

To checkout a module to work on:
cvs checkout dirname

To update the current directory from CVS latest version:
cvs update -d

To release the module you're now working on:
cvs release -d dirname (in parent directory)
the -d flag deletes the local copy. To save the local copy, such as when working with documents on a web server, omit the -d flag.

Files

Add a file (that you just created in your working directory) to the current module:
cvs add filename


Commit the changes you just made:
cvs commit

Tagging

To tag a module for a release: cvs rtag tagName moduleName Or, when in the top-level directory of the module (when checked out): cvs tag [tagname]

Removing Files

To Remove a file but not remove its' old history (i.e. keep it in the repo with change history, so it's available for old tags, but won't be checked out in the future if you just check out the head):

  1. Make sure it hasn't been changed - commit and update
  2. Probably a good idea to tag the whole module now.
  3. rm the file from your working directory
  4. cvs remove [filename]
  5. cvs commit [filename]

The file is now moved to Attic/ in the repository. It won't be checked out if you just do a normal checkout, but it will still be there if you retrieve a specific tag.

Working with files

Web Apps/Documents

Web documents/applications/scripts/etc. provide for an unusual situation with CVS. Typically when working with CVS, you start in an empty directory, checkout what you need to work on, do your work, then check it back in. The problem lies in the fact that if you checkout from CVS to a local directory that already has code in it, it will be overwritten with the CVS copy. Obviously, this is not a good thing when working with documents in your web server's root directory.

So, what is the solution?

Re-import. Let's assume that we want to add our website to CVS. We cd into /var/www/htdocs (our server's root directory) and issue the command:
cvs import htdocs vendorTag releaseTag This creates the module htdocs and adds everything in the current directory and all subdirectories to the module.

Now, if we change something in /var/www/htdocs we can update the repository without ever having to checkout by cd'ing into /var/www/htdocs, and issuing the exact same command as before. It will update and add files as needed, while leaving the local copies alone and not requiring a checkout.

We could easily add all of this to a shell script to be called manually or via cron.

Web Interfaces

You can also setup a web interface to CVS, which allows browsing of the repository, viewing logs, viewing files, diff'ing, and automatically generating tarballs. I personally use ViewVC which supports CVS, SVN, and others. My CVS repo can be browsed via ViewVC here.

External Links

CVS HowTos:
http://www.akadia.com/services/cvs_howto.html

Other Software:
ViewVC

Views
Notice - this is a static HTML mirror of a previous MediaWiki installation. Pages are for historical reference only, and are greatly outdated (circa 2009).