1 / 27

CVS: Concurrent Version System

CVS: Concurrent Version System. Lecturer: Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954. “UNIX for Programmers and Users” Third Edition, Prentice-Hall, GRAHAM GLASS, KING ABLES Slides partially adapted from Kumoh National University of Technology (Korea) and NYU.

zandra
Download Presentation

CVS: Concurrent Version System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CVS: Concurrent Version System Lecturer: Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 “UNIX for Programmers and Users” Third Edition, Prentice-Hall, GRAHAM GLASS, KING ABLES Slides partially adapted from Kumoh National University of Technology (Korea) and NYU

  2. UNIX Version Control Systems • Keep versions of source code • on a per file basis; grouping by tagging • Any version is accessible • Allow for parallel development • Support multiple software releases • SCCS: UNIX Source Code Control System • Rochkind, Bell Labs, 1972. • RCS: Revision Control System • Tichy, Purdue, 1980s. • CVS: Concurrent Versions System • Berliner, 1989. • Subversion (SVN) • a compelling replacement for CVS • Jostein Chr. Andersen, 2003 Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  3. CVS Major Features • Client/Server model • Distributed software development • No exclusive locks (like SCCS/RCS) • No waiting around for other developers • No hurrying to make changes while others wait • Avoid the “lost update” problem • file locked; get the file, edit • when file unlocked, checkout again, overwrite with your version and check in • have you destroyed some edits made between the time you grabbed the file first time and the second time? • All revisions of a file in the project are in the repository (using RCS) • Work is done on the checkout (working copy) • Top-level directories are modules; checkout operates on modules • Different ways to connect Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  4. CVS Revision Control • The history of each file is tracked with an incrementing revision number • For each revision there is a log entry • RCS version numbering is used; CVS user does not have to use these numbers directly (through tagging and branching - more later) • Revision numbers have the format 1.25 if they’re on the main trunk, branches have something like 1.33.2.16 branch 1.2.1.1 1.2.1.2 1.2.1.3 merge 1.1 1.2 1.3 1.4 1.5 1.6 main trunk 1.2.1.1 1.2.1.2 1.4.1.1 branch 1.2.1.1.1.1 1.2.1.1.1.2 Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  5. Getting Started cvs [basic-options] <command> [cmd-options] [files] • Basic options: -d <cvsroot> Specifies CVSROOT - repository location -H Help on command -n Dry run (just try the command) • Commands init import checkout update commit add remove status diff log tag … Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  6. Getting Started Creating a repository $ cd $HOME $ mkdir cvs $ chmod 700 cvs $ cvs -d /home/userNN/userID init Environment variable: CVSROOT • Location of Repository • Can take different forms: • Local file system: /usr/usersNN/userID/cvs • Remote Shell: user@server:/usr/usersNN/userID/cvs • Client/Server: :pserver:user@server:/usr/usersNN/userID/cvs • We will play with the local repository $ export CVSROOT=/home/usersNN/userID $ cvs init Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  7. Getting Started Remote access via SSH: $ export CVS_RSH=/usr/bin/ssh $ cvs -d :ext:userID@csun1.csun.edu:/home/usersNN/userID/cvs <command> $ _ or $ export CVS_RSH=/usr/bin/ssh $ export CVSROOT=:ext:userID@csun1.csun.edu:/home/usersNN/userID/cvs $ cvs <command> $ _ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  8. Setting up a Project in CVS Importing source • generates a new CVS module (project) • cd into source directory • to import all project files: cvs –d<cvsroot> import <new-module> <vendor-branch> <release-tag> cvs –d<cvsroot> checkout <module-name> $ cd comp421/reverse-initial $ cvs import -m “Initial deposition of sources” reverse userID start Password: <blah blah blah> N reverse/reverse.c N reverse/reverse.h N reverse/reversefirst.c $ mkdir ../reverse $ cd ../reverse $ cvs checkout reverse ---> now we have a copy in a working directory $ _ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  9. The CVS Root Directory $ ls $CVSROOT CVSROOT reverse $ ls $CVSROOT/reverse/ Attic reverse.c,v reverse.h,v reversefirst.c,v $ cat $CVSROOT/reverse.h,v head 1.1; branch 1.1.1; access ; symbols start:1.1.1.1 userID:1.1.1; locks ; strict; comment @ * @; … DO NOT TOUCH!!! Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  10. The Project CVS Directory Contains information on: • where the server is • version of checked out files • locally removed/added files $ ls CVS Entries Repository Root $ cat -n CVS/Entries 1 /reverse.c/1.1.1.1/Fri Nov 19 18:50:05 2004// 2 /reverse.h/1.1.1.1/Fri Nov 19 18:50:05 2004// 3 /reversefirst.c/1.1.1.1/Fri Nov 19 18:50:05 2004// 4 /descr.txt/1.1/Fri Nov 19 19:17:04 2004// 5 D $ cat -n CVS/Repository 1 reverse $ cat -n 1 CVS/Root /home/usersNN/userID/cvs $ _ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  11. Adding Individual files • Add files: add (cvs add <filename>) $ vi descr.txt … <enter “This is a description - line 1” in vi> … $ cvs add descr.txt cvs add: scheduling file `descr.txt' for addition cvs add: use 'cvs commit' to add this file permanently $ _ The file is not in the repository yet! Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  12. Committing Changes • Put changed (or newly added) version into repository: commit • Fails if repository has newer version (need update first) $ cvs commit cvs commit: Examining . "/tmp/cvsa18990" 8 lines, 291 characters • vi session opens Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  13. Documenting Changes Added initial description ---> you have to add the commentary CVS: ---------------------------------------------------------------------- CVS: Enter Log. Lines beginning with `CVS:' are removed automatically CVS: CVS: Committing in . CVS: CVS: Added Files: CVS: descr.txt CVS: ---------------------------------------------------------------------- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "/tmp/cvsa18990" 9 lines, 317 characters ZZ ---> save file and quit vi (a nice shortcut) ---> upper case “ZZ”! Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  14. File Revisions $RCS file: /home/usersNN/userID/cvs/reverse/descr.txt,v done Checking in descr.txt; /home/usersNN/userID/cvs/reverse/descr.txt,v <-- descr.txt initial revision: 1.1 done $ ls $CVSROOT/reverse Attic reverse.c,v reversefirst.c,v descr.txt,v reverse.h,v $ cat $CVSROOT/reverse/descr.txt,v <next slide> Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  15. File Revisions head 1.1; access; symbols; locks; strict; comment @# @; 1.1 date 2004.11.19.19.18.56; author userID; state Exp; branches; next ; desc @@ 1.1 log @Added initial description @ text @This is a description - line 1. @ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  16. Obtaining Status Information $ cvs status descr.txt ============================================================= File: descr.txt Status: Up-to-date Working revision: 1.1 Fri Nov 19 20:56:13 2004 Repository revision: 1.1 /home/usersNN/userID/cvs/reverse/descr.txt,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) $ _ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  17. Comparing Versions $ vi descr.txt <add line 2: “Line 2 has been added”> $ cvs commit descr.txt <add the description as requested> $ cat $CVSROOT/reverse/descr.txt,v <examine the record> $ cvs diff –r1.1 –r1.2 descr.txt cvs diff -r1.1 -r1.2 descr.txt Index: descr.txt ============================================================= RCS file: /home/users13/andrzej/cvs/reverse/descr.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -r1.1 -r1.2 1a2 > Line 2 has been added. $ _ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  18. Removing Files from Repository Remove files: remove (cvs remove <filename>) $ cvs remove descr.txt cvs remove: file `descr.txt' still in working directory cvs remove: 1 file exists; remove it first $ rm descr.txt $ cvs remove descr.txt cvs remove: scheduling `descr.txt' for removal cvs remove: use 'cvs commit' to remove this file permanently $ cvs commit descr.txt <provide commentary as requested> $ _ Things do not disappear from CVS! $ cvs add descr.txt cvs add: re-adding file `descr.txt' (in place of dead revision 1.3) cvs add: use 'cvs commit' to add this file permanently $ cvs commit descr.txt <provide the commentary> Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  19. Accessing File Change Log $ cvs log descr.txt RCS file: /home/usersNN/userID/cvs/reverse/descr.txt,v Working file: descr.txt head: 1.4 branch: locks: strict access list: symbolic names: keyword substitution: kv total revisions: 4; selected revisions: 4 description: ---------------------------- revision 1.4 date: 2004/11/19 21:29:35; author: userID; state: Exp; lines: +0 -1 re-added the file ---------------------------- revision 1.3 date: 2004/11/19 21:23:19; author: userID; state: dead; lines: +0 -0 File deleted. ---------------------------- revision 1.2 date: 2004/11/19 21:15:16; author: userID; state: Exp; lines: +1 -0 Line 2 added to the file. ---------------------------- revision 1.1 date: 2004/11/19 21:01:41; author: userID; state: Exp; Added initial description ==================================================================== $ _ Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  20. Managing files • Get latest version from repository: update • if out of sync, merges changes • Possible conflicts! • one developer changes a line to something • another developer changes the same line to something else and commits the change • when the first developer wants to update - conflict • Conflict resolution is manual • developers have to meet and resolve the issue Line 5: int I = 55; local ver1 local ver2 update (merge) 1.1 1.2 1.3 Line 5: int I = 20; another developer changes the main trunk Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  21. Change Conflicts $ vi descr.txt <add line 3: “This is my line 3”> $ cvs checkout -d anotherReverse reverse ---> “another developer” $ cd anotherReverse $ vi descr.txt <add line 3: “This is another developer’s change to line 3”> $ cvs commit <provide the commentary as requested> $ cd ..---> back to the first developer’s workspace Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  22. Conflict Resolution $ cvs update ---> in the original working directory cvs update cvs update: Updating . RCS file: /home/usersNN/userID/cvs/reverse/descr.txt,v retrieving revision 1.2 retrieving revision 1.3 Merging differences between 1.2 and 1.3 into descr.txt rcsmerge: warning: conflicts during merge cvs update: conflicts found in descr.txt C descr.txt $ cat descr.txt---> the merged file may include conflicts This is a description - line 1. This is my line 2 <<<<<<< descr.txt ---> conflict! This is my line 3 ======= This is another developer’s change to line 3 >>>>>>> 1.3 ---> end of conflict $ vi descr.txt <fix the conflict with the other developer> Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  23. Tags • A tag is a symbolic name for a specific revision • Tagging all files in one directory or module marks the current stage • Can be used as a synonym for a revision in CVS commands cvs tag <tagname> applies the tag to current revision of each file $ cvs tag rel-1 beta-1 rel-2 file1 1.3.1.1 1.3.1.2 rel-1 1.1 1.2 1.3 1.4 1.5 1.6 beta-1 file2 1.2.1.1 1.2.1.2 1.2.1.3 1.1 1.2 1.3 1.4 1.5 rel-2 rel-1 Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  24. Branches • A branch is a sticky tag. It is a symbolic name which always sticks to the HEAD of the branch in question (MAIN is a special branch reserved for the main trunk) <edit descr.txt, add a line, save and commit> To start a branch: $ cvs rtag –b –r rel-1 release-1---> off a tag $ cvs tag –b release-2---> off current copy 1.2.1.1 1.2.1.2 1.2.1.3 maintenance branch release-1 1.1 1.2 1.3 1.4 1.5 main development trunk MAIN rel-1 1.2.2.1 1.2.2.2 1.5.1.1 1.5.1.2 research release-2 research branch maintenance branch experimental branch 1.2.2.1.1.1 1.2.2.1.1.2 experimental Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  25. Finding Differences between Tagged Versions $ cvs diff -r release1 -r release-2 descr.txt Index: descr.txt ============================================================= RCS file: /home/usersNN/userID/cvs/reverse/descr.txt,v retrieving revision 1.2.1.3 retrieving revision 1.5.1.2 diff -r1.2.1.3 -r1.5.1.2 3c3 < This is another developer’s change to line 3 --- > This is my line 3 $ _ • You can also use cvs -n that only tries what the processing would be like Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  26. Keyword Substitution • Source files can contain keywords • Keywords are filled on checkout/update • Some useful keywords: • $Id$ • $Revision$ • $Date$ • For example, $Id$ expands to something like: $Id: prog.c, v 1.10 2004/10/14 14:32:21 userID Exp$ • Can be used in program source Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

  27. Subversion: New Open Source Standard • Most current CVS features. • Directories, renames, and file meta-data are versioned • Commits are truly atomic. • Apache network server option, with WebDAV/DeltaV protocol. • Standalone server option. • Branching and tagging are cheap (constant time) operations • Natively client/server, layered library design • Client/server protocol sends diffs in both directions • Costs are proportional to change size, not data size • Choice of database or plain-file repository implementations • Versioning of symbolic links • Efficient handling of binary files • Parseable output • Localized messages Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954

More Related