280 likes | 301 Views
Introduction to CVS: Concurrent Versions System. What is CVS?. A version control system: A change history for a file set Open-source CVS as a: local version control system Internet client/server version control system. What is CVS? …. CVS uses unreserved check-outs:
E N D
Introduction to CVS:Concurrent Versions System Peter Cappello
What is CVS? • A version control system: • A change history for a file set • Open-source • CVS as a: • local version control system • Internet client/server version control system
What is CVS? … • CVS uses unreserved check-outs: • Check out ! exclusive write permission. • Many developers can concurrently: • check out a file • modify it • check it back in. • CVS automatically merges changes. • CVS can't safely resolve the changes developer merges them manually. • Exclusive lines modified safe to merge. • Do you agree?
What is CVS for? • It maintains a source tree’s change history. • It stamps each change with: • the time it was made • the changer’s user name. • [The purpose of the change.]
What is CVS for? … • CVS helps answer questions like: • Who made a given change? • When did they make it? • Why did they make it? • What other changes did they make at the same time?
Essential CVS CommandsSetting Your Repository • A project’s source is in a directory called a repository. • Before using cvs, set the cvs environment variable: CVSROOT CSH: setenv CVSROOT /cs/faculty/cappello/cvs BASH: CVSROOT=/cs/faculty/cappello/cvs\ Export CVSROOT
Creating a Repository • To create a cvs repository in /cs/guest/cs/cvs: cvs –d /cs/guest/cx/cvs init • Absolute path name must be used. • The command is idempotent: • executing it with an existing cvs repository as a target, will do no harm.
Starting a Project with CVS • If you have a directory with your project: • cd to that directory; • Execute the command cvs import –m “Imported sources” <projectname> <vendorname> <releasename> • You will get a “tar”-like response. • After verifying that all went well, delete the original directory.
Check Out a Working Directory • Check out the source tree called <projectname> from your repository • Execute cvs checkout <projectname> • This, in effect, is a “mkdir<projectname>” where <projectname> has • the contents of the <projectname> project • a CVS directory, used by cvs.
Change Files of Working Directory • Edit, compile, & test files within the working directory in your usual way.
Merging Your Changes • A developer works in his own directory. • When your changes are tested: • Synchronize your source with other members. cvs update • This merges changes made by others since your working directory was: • checked out • updated • cvs update lists changed files: U <filename> • Test the system with these new versions, if any.
Merging Your Changes …Committing Your Changes • Execute the command cvs commit <file1> • CVS launches an editor, using: • $CVSEDITOR, if that environment variable is set, • $EDITOR, if above is not set • vi, if neither of the above are set. • Committing w/o launching an editor cvs commit –m “message here” <file1>
Examining Changes • A file’s log entries indicate what changes have occurred: cvs log <filename> • This command’s output appears on the next slide.
RCS file: /cs/faculty/cappello/cvs/cx/html/home.html,v Working file: home.html head: 1.2 branch: locks: strict access list: symbolic names: releaseTag: 1.1.1.1 vendorTag: 1.1.1 keyword substitution: kv total revisions: 3; selected revisions: 3 description: ---------------------------- revision 1.2 date: 2001/02/13 12:23:08; author: cappello; state: Exp; lines: +2 -0 Test2 of commit command ---------------------------- revision 1.1 date: 2001/02/13 09:41:29; author: cappello; state: Exp; branches: 1.1.1; Initial revision ---------------------------- revision 1.1.1.1 date: 2001/02/13 09:41:29; author: cappello; state: Exp; lines: +0 -0 Imported sources =============================================================================
CVS Log Command • cvs log also can select entries by: • date range • revision number
Examining changes … • To examine actual file changes cvs diff –c –r 1.1 –r 1.2 home.html • The –c option requests the output be in human readable format. • Here is the output …
Index: home.html =================================================================== RCS file: /cs/faculty/cappello/cvs/cx/html/home.html,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** home.html 2001/02/13 09:41:29 1.1 --- home.html 2001/02/13 12:23:08 1.2 *************** *** 1,2 **** --- 1,4 ---- <html> + <head> + </head> </html>
The cvs diff Command • Changed lines are prefixed with ! • Inserted lines are prefixed with + • Deleted lines are prefixed with -
Adding Files • After creating a file, execute cvs add <filename> • Example cvs add control.html • Output cvs add: scheduling file `control.html’ for addition cvs add: use ‘cvs commit’ to add this file permanently
Execute cvs update • Output A control.html • Execute the commit (enter message) cvs commit control.html • Output RCS file: /cs/faculty/cappello/cvs/cx/html/control.html,v done Checking in control.html /cs/faculty/cappello/cvs/cx/html/control.html,v control.html Initial revision: 1.1 done
Removing Files • Delete the file; • Execute cvs rm <filename> • The next cvs commit removes the file from the project.
Good Log Entries • A Good log entry does not describe the change. • It gives the rationale for the change.
Handling Conflicts • If a team member modified lines of a file that you have changed, cvs update detects the conflict. C control.html a conflict was detected • Launch the editor • CVS marks the conflicting text <<<<<<<<< … conflicting text goes here ========= … conflicting text goes here >>>>>>>>> 1.2
Cleaning Up • When done with a project (for now) cvs release -d <projectname> • This removes the working directory. • Modified files are noted (M), in case you forgot to commit them • You have a chance to abort the release.
Installing the jCVS Client • Download: http://www.trustice.com/java/jcvs/ • Unzip • View README.html (in Docs) • Client is jcvsii.jar in Jar folder • CVS online manual http://www.cvshome.org/docs/manual/cvs.html
Main Window
Project Window