Avinash Prasad

       CVS                                                     A useful Page

          Lets consider the way coding is done for large projects in real life. What are the issues:
           These are the kind of things that CVS (standing for concurrent versioning system looks at)
 Introduction to CVS's approach:
          We looked at the the various questions above now we understand how CVS tries to solve these problems:
Basic Functioning:

          Let's look at the basic set of commnads needed at working with CVS for a given project.(block letters indicate commands, assume that the project name is NetLib)
Basic setup:

    To make above add following lines to $HOME/.bash_profile (source the .bash_profile: source .bash_profile after making these changes)
                                  cvs [-d ~/cvsRoot import] -m "Start files" NetLib sample start
                                    N NetLib/Makefile
                                    cvs import: Importing /home/attic/avinash/cvsRoot/NetLib/lib
                                    cvs import: Importing /home/attic/avinash/cvsRoot/NetLib/bin
                                    cvs import: Importing /home/attic/avinash/cvsRoot/NetLib/src
                                    N NetLib/src/a.c
                                    N NetLib/src/b.c
                                    cvs import: Importing /home/attic/avinash/cvsRoot/NetLib/doc
                                    cvs import: Importing /home/attic/avinash/cvsRoot/NetLib/include
                                    N NetLib/include/a.h
                                    N NetLib/include/b.h

                                    No conflicts created by this import
                      Here  '-m ' is use to give the comment 'Start files' while -d option again gives the root. NetLib is the name under which the project appears in the $CVSROOT.
                      Rest of the options don't have much meaning . Have a look at the root repository now and see how does the project appear there.
                                  cvs -d ~/cvsRoot/ checkout NetLib
                                  U NetLib/Makefile
                                    cvs checkout: Updating NetLib/bin
                                    cvs checkout: Updating NetLib/doc
                                    cvs checkout: Updating NetLib/include
                                    U NetLib/include/a.h
                                    U NetLib/include/b.h
                                    cvs checkout: Updating NetLib/lib
                                    cvs checkout: Updating NetLib/src
                                    U NetLib/src/a.c
                                    U NetLib/src/b.c
                     You can use 'co' instead of  'checkout'. The entire NetLib gets replicated !!
                                  cvs -d ~/cvsRoot/ commit -m "Added all to makefile" Makefile
                             Checking in Makefile;
                                     /home/attic/avinash/cvsRoot/NetLib/Makefile,v  <--  Makefile
                                     new revision: 1.2; previous revision: 1.1
Notice the version change performed as Makefile gets updated.This is what can be used later to restore things to previous stage.
                         We just have to roll back to some older version number on that file.

                                   cvs -d ~/cvsRoot/ release -d NetLib/  (from the dir above Netlib)                            
                                   You have [0] altered files in this repository.
                                   Are you sure you want to release (and delete) directory `../NetLib/': y

                      This indicates the case where all the files have been comitted to the cvs and the file in the working dir are the same as those in the repository.If not than release
                       complains about altered files and your changes aren't lost...just because you forgot to remember what all files were changed.

Retrieval of files:
                                   cvs -d ~/cvsRoot/ co  -D "YYYY-MM-DD" NetLib
This shall restrore the NetLib to the level it was on  date  "YYYY-MM-DD". And thus we can restore things to sanity if changes go haywire.
                                  (set tag )cvs rtag milestoneI myproj
                                  (use tag)
cvs checkout -P -r milestoneI myproj
                                  (untag)  cvs  -d milestoneI myproj

       '-n ' option lets you know what shall happen without actually performing the action.
                                 cvs status Makefile: this shall compare the version of the file at the repository and the Makefile in the working directory .
                                   File: Makefile          Status: Needs Patch
                                   Working revision:    1.2     Tue Aug 17 22:20:14 2004
                                   Repository revision: 1.3     /home/attic/avinash/cvsRoot/NetLib/Makefile,v
                                   Sticky Tag:          (none)
                                   Sticky Date:         (none)
                                   Sticky Options:      (none)

                      As we can see here the working copy is older that the Recent copy at the server.So we need to update our copy with the new changes. The states possible are
                                 cvs update Makefile: this shall cause the updation of the files with the changes that were made by the other user.
U Makefile
                      The output indicates that the file got updated . As only a patch was needed for the file in consideration. But if the ' Status: Needs Mergewas returned then we need to
                      make some changes before update can be done.Running update gives error of the type
                                  cvs -d ~/cvsRoot/ update b.c
                                  RCS file: /home/attic/avinash/cvsRoot/NetLib/src/b.c,v
                                  retrieving revision
                                  retrieving revision 1.3
                                  Merging differences between and 1.3 into b.c
                                  rcsmerge: warning: conflicts during merge
                                  cvs update: conflicts found in b.c
                                  C b.c

                   The resulting file is of the type: ('vim b.c')
<<<<<<< b.c

                                >>>>>>> 1.3
                which indicates what has changed.To make the final version we decide what to select and them commit in the normal fashion indicating that the conflict has been solved.
                Note that while doing so the extra lines '<<<<<...." and ">>>>>....." should be deleted.

                Don't worry about forgetting to perform this upto-date check before you commit.In such a scenario commit returns with the following error:
                    cvs -d ~/cvsRoot/ commit -m "Failed Attempt" Makefile
                    cvs commit: Up-to-date check failed for `Makefile'
                    cvs [commit aborted]: correct above errors first!

             You can look at the other options using man or info on cvs.



Thanks  -- Avinash                                                                                                                                                                                                                                                         ...stride away