Search code examples
linuxbashsshcvs

How to define multiple CVS ROOT?


I had one CVS repository located in a remote location, which CVS can access via these environment variables:

export CVSROOT=:ext:xyz@abc.com:/home/xyz/cvsroot
export CVS_RSH=ssh
export CVS_SERVER=cvs

Recently I added another server which has a different location and a different repository. I tried adding the location via

export CVSROOT=$CVSROOT:ext:xyz@fgh.com:/cvs/cvsroot

However, I am unable to perform operations such as checkout and update with the following error:

Cannot access /home/xyz/cvsroot:xyz@fgh.com:/cvs/cvsroot
No such file or directory

What am I doing wrong?


Solution

  • When you are in a CVS repository, any cvs operations will take its CVSROOT information from the current directory's CVS/Root file, regardless of what any CVSROOT environment variables are there. So your only issue is how to initially checkout from your different repositories.

    When you type export CVSROOT=$CVSROOT:ext:xyz@fgh.com:/cvs/cvsroot that says "change the CVSROOT environment variable to be the old variable with ':ext:xyz@fgh.com:/cvs/cvsroot' appended to the end if it. That's likely not what you want. You need to take the $CVSROOT out of the right hand side.

    As a workable workflow, you can either

    • run cvs -d <newcvsroot> co <reponame> to specify each CVSROOT as you do your cvs co (you may need to unset CVS_RSH as well, I don't know about that), or
    • you could also export CVSROOT=<newcvsroot>; unset CVS_RSH; cvs co <reponame>.

    If you're frequently checking out from multiple repositories, you may want to have environment variables set up like this, and then you can easily check out from each repo. (Add repos as necessary.)

    # in your .bashrc or someting
    export REPO1ROOT=:ext:xyz@fgh.com:/cvs/cvsroot
    export REPO2ROOT=:ext:xyz@abc.com:/home/xyz/cvsroot
    export CVSROOT=$REPO1ROOT # default
    
    # when you use the command line
    cvs co repo1
    cvs -d $REPO2ROOT co repo2