Presentation is loading. Please wait.

Presentation is loading. Please wait.

CVS: Concurrent Version System Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: 818-677-4954 “UNIX for Programmers and Users” Third.

Similar presentations


Presentation on theme: "CVS: Concurrent Version System Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: 818-677-4954 “UNIX for Programmers and Users” Third."— 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 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49542 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

3 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49543 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 sec ond 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

4 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49544 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 1.11.21.3 1.2.1.11.2.1.21.2.1.3 1.2.1.1 1.4 1.4.1.1 1.51.6 1.2.1.2 merge main trunk branch 1.2.1.1.1.11.2.1.1.1.2

5 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49545 Getting Started cvs [basic-options] [cmd-options] [files] Basic options: -d 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 …

6 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49546 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

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

8 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49548 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 import cvs –d checkout $ cd comp421/reverse-initial $ cvs import -m “Initial deposition of sources” reverse userID start Password: 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 $ _

9 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-49549 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!!!

10 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495410 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 $ _

11 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495411 Adding Individual files Add files: add (cvs add ) $ vi descr.txt … … $ 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!

12 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495412 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

13 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495413 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”!

14 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495414 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

15 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495415 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. @

16 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495416 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) $ _

17 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495417 Comparing Versions $ vi descr.txt $ cvs commit descr.txt $ cat $CVSROOT/reverse/descr.txt,v $ 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. $ _

18 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495418 Removing Files from Repository Remove files: remove (cvs remove ) $ 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 $ _ 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

19 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495419 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 ==================================================================== $ _

20 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495420 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 1.11.2 local ver2 1.3 update (merge) another developer changes the main trunk Line 5: int I = 20; Line 5: int I = 55; local ver1

21 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495421 Change Conflicts $ vi descr.txt $ cvs checkout -d anotherReverse reverse---> “another developer” $ cd anotherReverse $ vi descr.txt $ cvs commit $ cd..---> back to the first developer’s workspace

22 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495422 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 conflict! This is my line 3 ======= This is another developer’s change to line 3 >>>>>>> 1.3---> end of conflict $ vi descr.txt

23 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495423 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 applies the tag to current revision of each file $ cvs tag rel-1 1.11.21.3 1.3.1.11.3.1.2 1.41.51.6 file1 1.11.21.3 1.2.1.11.2.1.21.2.1.3 1.41.5 file2 beta-1 rel-2 rel-1 beta-1 rel-2

24 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495424 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) To start a branch: $ cvs rtag –b –r rel-1 release-1---> off a tag $ cvs tag –b release-2---> off current copy 1.11.21.3 1.2.1.11.2.1.21.2.1.3 1.2.2.1 1.4 1.5.1.2 1.5 1.2.2.2 1.2.2.1.1.11.2.2.1.1.2 release-1 research MAIN 1.5.1.1 release-2 maintenance branch main development trunk rel-1 research branch experimental branch experimental

25 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495425 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

26 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495426 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

27 CVS: Concurrent Version System Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-495427 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


Download ppt "CVS: Concurrent Version System Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: 818-677-4954 “UNIX for Programmers and Users” Third."

Similar presentations


Ads by Google