CVS: Concurrent Version System Lecturer: Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 “UNIX for Programmers and Users” Third.
Post on 21-Jan-2016
215 Views
Preview:
Transcript
CVS: Concurrent Version System
Lecturer: Prof. Andrzej (AJ) BieszczadEmail: 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
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 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
CVS: Concurrent Version System
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
CVS: Concurrent Version System
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
1.1 1.2 1.3
1.2.1.1 1.2.1.2 1.2.1.3
1.2.1.1
1.4
1.4.1.1
1.5 1.6
1.2.1.2
merge
main trunk
branch
branch
1.2.1.1.1.1 1.2.1.1.1.2
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 5
Getting Startedcvs [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)
• Commandsinitimportcheckoutupdatecommitaddremovestatusdifflogtag…
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 6
Getting StartedCreating 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
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 7
Getting StartedRemote 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>$ _
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 8
Setting up a Project in CVSImporting 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 startPassword: <blah blah blah>N reverse/reverse.cN reverse/reverse.hN reverse/reversefirst.c$ mkdir ../reverse$ cd ../reverse$ cvs checkout reverse ---> now we have a copy in a working directory$ _
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 9
The CVS Root Directory$ ls $CVSROOTCVSROOT reverse$ ls $CVSROOT/reverse/Attic reverse.c,v reverse.h,v reversefirst.c,v$ cat $CVSROOT/reverse.h,vhead 1.1;branch 1.1.1;access ;symbols start:1.1.1.1 userID:1.1.1;locks ; strict;comment @ * @;…
DO NOT TOUCH!!!
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 10
The Project CVS DirectoryContains information on:
–where the server is–version of checked out files–locally removed/added files
$ ls CVSEntries 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$ _
CVS: Concurrent Version System
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.txtcvs add: scheduling file `descr.txt' for additioncvs add: use 'cvs commit' to add this file permanently$ _
The file is not in the repository yet!
CVS: Concurrent Version System
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 commitcvs commit: Examining ."/tmp/cvsa18990" 8 lines, 291 characters
• vi session opens
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 13
Documenting ChangesAdded initial description ---> you have to add the commentaryCVS: ----------------------------------------------------------------------CVS: Enter Log. Lines beginning with `CVS:' are removed automaticallyCVS:CVS: Committing in .CVS:CVS: Added Files:CVS: descr.txtCVS: ----------------------------------------------------------------------~~~~~~~~~~~ "/tmp/cvsa18990" 9 lines, 317 charactersZZ ---> save file and quit vi (a nice shortcut)
---> upper case “ZZ”!
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 14
File Revisions$RCS file: /home/usersNN/userID/cvs/reverse/descr.txt,vdoneChecking in descr.txt;/home/usersNN/userID/cvs/reverse/descr.txt,v <-- descr.txtinitial revision: 1.1done$ ls $CVSROOT/reverseAttic reverse.c,v reversefirst.c,vdescr.txt,v reverse.h,v$ cat $CVSROOT/reverse/descr.txt,v<next slide>
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 15
File Revisionshead 1.1;access;symbols;locks; strict;comment @# @;
1.1date 2004.11.19.19.18.56; author userID; state Exp;branches;next ;
desc@@
1.1log@Added initial description@text@This is a description - line 1.@
CVS: Concurrent Version System
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)
$ _
CVS: Concurrent Version System
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.txtcvs diff -r1.1 -r1.2 descr.txtIndex: descr.txt=============================================================RCS file: /home/users13/andrzej/cvs/reverse/descr.txt,vretrieving revision 1.1retrieving revision 1.2diff -r1.1 -r1.21a2> Line 2 has been added.$ _
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 18
Removing Files from RepositoryRemove files: remove (cvs remove <filename>)
$ cvs remove descr.txtcvs remove: file `descr.txt' still in working directorycvs remove: 1 file exists; remove it first$ rm descr.txt $ cvs remove descr.txtcvs remove: scheduling `descr.txt' for removalcvs 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>
CVS: Concurrent Version System
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,vWorking file: descr.txthead: 1.4branch:locks: strictaccess list:symbolic names:keyword substitution: kvtotal revisions: 4; selected revisions: 4description:----------------------------revision 1.4date: 2004/11/19 21:29:35; author: userID; state: Exp; lines: +0 -1re-added the file----------------------------revision 1.3date: 2004/11/19 21:23:19; author: userID; state: dead; lines: +0 -0File deleted.----------------------------revision 1.2date: 2004/11/19 21:15:16; author: userID; state: Exp; lines: +1 -0Line 2 added to the file.----------------------------revision 1.1date: 2004/11/19 21:01:41; author: userID; state: Exp;Added initial description====================================================================$ _
CVS: Concurrent Version System
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
1.1 1.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
CVS: Concurrent Version System
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
CVS: Concurrent Version System
Prof. Andrzej (AJ) Bieszczad Email: andrzej@csun.edu Phone: 818-677-4954 22
Conflict Resolution$ cvs update ---> in the original working directorycvs updatecvs update: Updating .RCS file: /home/usersNN/userID/cvs/reverse/descr.txt,vretrieving revision 1.2retrieving revision 1.3Merging differences between 1.2 and 1.3 into descr.txtrcsmerge: warning: conflicts during mergecvs update: conflicts found in descr.txtC descr.txt$ cat descr.txt ---> the merged file may include conflictsThis 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>
CVS: Concurrent Version System
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
1.1 1.2 1.3
1.3.1.1 1.3.1.2
1.4 1.5 1.6
file1
1.1 1.2 1.3
1.2.1.1 1.2.1.2 1.2.1.3
1.4 1.5
file2beta-1
rel-2
rel-1
rel-1
beta-1
rel-2
CVS: Concurrent Version System
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.1 1.2 1.3
1.2.1.1 1.2.1.2 1.2.1.3
1.2.2.1
1.4
1.5.1.2
1.5
1.2.2.2
1.2.2.1.1.1 1.2.2.1.1.2
release-1
research
MAIN
1.5.1.1release-2
maintenance branch
maintenance branch
main development trunk
rel-1
research branchexperimental branch
experimental
CVS: Concurrent Version System
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,vretrieving revision 1.2.1.3retrieving revision 1.5.1.2diff -r1.2.1.3 -r1.5.1.23c3< 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
CVS: Concurrent Version System
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
CVS: Concurrent Version System
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
top related