CVS Tool Reference Summer 2009

CVS Tool Reference Summer 2009

Guide Overview

We provide tools within the RCE that streamline common CVS commands and recommend that you use these tools from within your RCE session, particularly if you are unfamiliar with CVS. To learn more about our CVS workflow, please read Working with CVS in the RCE Summer 2009.

This guide is a reference for advanced users or for those who cannot make use of the RCE. It describes the following types of commands:

  • Core CVS commands
  • RCE-specific commands
  • Specialized commands
Core Commands

Core Commands

The following is a list of core commands for the RCE CVS workflow. All of these commands require you to enter your password when run.

  • Checking out a repository:
    • For csh and its derivatives use the following -
      set CVS_RSH ssh cvs -d 'USER@cvs.hmdc.harvard.edu:/CVS/REPOSITORY' co REPOSITORY
    • For bash and its derivatives use the following -
      export CVS_RSH=ssh cvs -d 'USER@cvs.hmdc.harvard.edu:/CVS/REPOSITORY' co REPOSITORY

    Replace USER with your RCE username. Replace REPOSITORY with the name of the CVS repository.

  • Updating a repository - Use the following command:
    cvs update [-d] [-P] [FILENAMES]
    You must be in your local check out of the repository in order to run the update. This by default updates the current directory and all sub-directories.
    The -d flag is optional, but recommended. It tells CVS to download any new directories during the update.
    The -P also is optional. This tells CVS to prune (delete) any empty directories from your local repository.
    You also can update files or directories selectively by supplying their names on the command line.
  • Adding files to a repository - Use the following command: 
    cvs add FILENAME
    To add files to a repository, you must have the respository checked out and the new files must be in the local check out of the repository.
  • Committing files to a repository - Use the following command:
    cvs commit [FILENAME]
    You must be in your local check out of the repository to run the commit command. This default commits changes in the current directory and all sub-directories.
    You also can commit files or directories selectively by supplying their names on the command line.
    Always run an update before trying to commit any changes. If another user worked on the same file, they could make changes and commit them before you do. Run an update to make CVS attempt to merge the two sets of changes together. You might need to resolve conflicts in situations where CVS cannot merge the changes. Conflicts are marked with >>>>>.
RCE-Specific Commands

RCE-Specific Commands

This list of extended commands available in the RCE to make using CVS a easier. All of these commands require you to enter your password when run. These commands are available only on systems running the RCE.

  • Removing files from a repository - Use the following command:
    cvsrm FILENAME
    This command removes the local copy of a file and remove the file from the CVS repository.
    Use this command with extreme caution!
    After you use cvsrm to delete a file, the only way to retrieve it is to restore from a recent backup.
  • Removing directories from a repository - Use the following command:
    cvsrmdir FILENAME
    This command removes all files within a given directory tree.
    Use this command with extreme caution!
    CVS leaves the empty directories behind. You can use cvs update -P to remove empty directories.
  • Renaming files or directories in a repository - Use the following command:
    cvscp SOURCE_FILENAME DESTINATION_FILENAME
    This command makes a copy of the directory or file. The old files remain unless you do either a cvsrm for a file or cvsrmdir for a directory.
Specialized Commands

Specialized Commands

The following is a list of specialized commands that you can use with CVS to allow for divergent development. Divergent development means that, while a team of developers continues to work on a new version of software, another team can be working on bug fixes for the older version. The two teams can work independently of each other using branching.

  • Viewing current tags on repository file: Use the following command -
    cvs status -v FILENAME
    This command must be run on a local checked out repository. It reports all of the current tags on the given file, which should be the same as for the whole repository.
    Example:

    cvs status -v rbuild.conf
    ============================================
    File: rbuild.conf Status: Up-to-date


    *Working revision: 1.30
    *Repository revision: 1.30 /CVS/skel/skel/rbuild.conf,v
    *Sticky Tag: (none)
    *Sticky Date: (none)
    *Sticky Options: (none)


    *Existing Tags:
    skel_2-2-12 *(revision: 1.29)
    skel_2-2-10 *(revision: 1.24)
    skel_2-2-7b *(branch: 1.10.2)
    skel_2-2-2b *(branch: 1.1.1.1.2)
    skel_2-2-9 *(revision: 1.12)
    skel_2-2-7 *(revision: 1.10)
    skel_2-2-4 *(revision: 1.7)
    skel_2-2-2 *(revision: 1.1.1.1)
    bar *(revision: 1.1.1.1)
    foo *(branch: 1.1.1)
  • Creating a new branch from an existing tag - Use the following command:
    cvs -d 'USER@cvs.hmdc.harvard.edu:/CVS/REPOSITORY' rtag -r EXISTING_TAG -b BRANCH_NAME REPOSITORY

    Use these guidelines:

    • Replace USER with the username you use to connect to HMDC's UNIX servers.
    • Replace REPOSITORY with the CVS group your are working on.
    • Replace EXISTING_TAG with the tag you wish to branch from (this tag must already exist).
    • Replace BRANCH_NAME with the name you want to give the branch (must be unique to this repository).

    This command does not have to be run from within the local checkout of the repository. This does not check any files out, it simply marks the start of a branch.
    Example:
    cvs -d bkinney@cvs.hmdc.harvard.edu:/CVS/skel rtag -r skel_2-2-12 -b skel_2-2-12-bkinney skel
    This creates the branch skel_2-2-12-bkinney starting from the label skel_2-2-12 on the module skel.

  • Checking out a new branch as a separate directory - Use the following command:
    cvs -d 'USER@cvs.hmdc.harvard.edu:/CVS/REPOSITORY' co -d LOCAL_DIR -r BRANCH_NAME REPOSITORY
    Use these guidelines:
    • Replace USER with the username you use to connect to HMDC's UNIX servers.
    • Replace REPOSITORY with the CVS group your are working on.
    • Replace LOCAL_DIR with the name of the local directory you want check out the branch to (should be different from your main checkout).
    • Replace BRANCH_NAME with the name you gave to your branch.

    This command should be run from your home directory (or wherever you keep your cvs checkouts). This creates a new directory structure from the repository, but it is based on the branch you created. All add, update, and commit commands only affect this branch. Users developing on the main trunk do not see your changes until you merge them.
    Example:
    cvs -dbkinney@cvs.hmdc.harvard.edu:/CVS/skel co -d skel-bkinney -r skel_2-2-12-bkinney skel
    This creates a directory skel-bkinney with the contents of the branch skel_2-2-12-bkinney.

  • Merging changes from a branch into the main trunk - Use the following command:
    cvs update -j EXISTING_TAG -j BRANCH_NAME
    Use these guidelines:
    • Replace EXISTING_TAG with the tag you initially branched from.
    • Replace BRANCH_NAME with the name of the branch you created.

    This command must be run in the local checkout of the main trunk. The result of this command is a repository with changes from both the main trunk and your branch. You must commit changes for them to be available to other users. Merging does often cause conflicts, so verify there are no conflict markers (>>>>) in your files before committing them.
    Example:
    cvs -dbkinney@cvs.hmdc.harvard.edu:/CVS/skel co skel
    cd skel
    cvs update -j skel_2-2-12 -j skel_2-2-12-bkinney

    These commands check out the main trunk of the skel module and merge the contents from the skel_2-2-12-bkinney branch. These changes still must be commited.

IQSS