an intro to concurrent versions system (cvs) ece 417/617: elements of software engineering stan...

18
An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Upload: jacob-joseph

Post on 02-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

An Intro to Concurrent Versions System (CVS)

ECE 417/617:Elements of Software Engineering

Stan BirchfieldClemson University

Page 2: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

What is CVS?• CVS

– is a version (or revision) control system– maintains entire history of source file

(for each change: who, when, and why)– is open-source and free (unlike SourceSafe)

• What does it do?– stores entire history of each file efficiently– allows multiple people to work simultaneously– enables retrieval of old systems– helps to manage different versions, releases– works well over WAN (server/client)– works for any ASCII file, and limited support for binary

• What is it not?– a build system– a substitute for management or communication

Page 3: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Why CVS?

• Problem: how to coordinate source file changes from multiple developers?– Solution #1: Manual merging and

coordination– Solution #2: lock-modify-unlock (RCS,

SCCS)– Solution #3: concurrent development (CVS)

Page 4: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

How CVS manages changes

• Scenarios:– People work on different files trivial– People work on different parts of the same

file CVS essentially runs ‘diff’– People work on the same part of the same

file CVS alerts user, requires manual merging of changes

Page 5: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

CVS model

Server (Unix/Linux) Local machine (any O/S)

Respository: central, official copy, as well as entire history

Local copy: used for editing

add, remove, commit, tag

checkout, update, diff

Note: checkout is a one-time operation

Page 6: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

CVS directory structure

/pub/cvsprojects/ece417 | +--CVSROOT (admin. files) +--3dmm | +-- data | +-- main.cpp,v | +-- database.cpp,v | +-- ui | +-- MainFrame.cpp,v | +-- SettingsDlg.cpp,v | +--klt-ui +--bibtex-manager ...

C:/user/me/mycode | +--CVS (admin. files) | +--data +-- CVS (admin. files) +-- main.cpp +-- database.cpp +--ui +-- CVS (admin. files) +-- MainFrame.cpp +-- SettingsDlg.cpp

Repository on server Copy on local machine

Note: All information stored on a per-file basis

Page 7: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Pserver authentication

• Each CVS command needs to authenticate you• Instead of a password for each command, first login• Steps:

– cvs login (server checks its passwd file; if no passwd, then falls back to Unix system authentication)

– now your password is stored locally in ~/.cvspass– local password is automatically used in the future as long as

it’s there– CVS_PASSFILE can be used to change location of .cvspass

• Note: pserver authentication provides minimal security; do NOT use an important password

Page 8: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

CVS commands

• Syntax:cvs [goptions] command [coptions] [arguments]

• Example:cvs -d :pserver:[email protected]:/pub/cvsprojects/ece417 login

• Common commands:– cvs checkout modules ; create private copy– cvs update ; incorporate others’ changes into

private copy– cvs add file ; add private file to repository– cvs remove file ; remove file from repository– cvs commit file ; publish changes to others

• Customizing:– .cvsrc file contains default options, both global and command-

specific

Page 9: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Create / checkout module

• To put a directory under CVS control,cvs import –m “New file” foo me start

– All files in current directory are stored in foo subdirectory of repository

– -m “New file” specifies the log comment– foo is directory name in repository– me is vendor tag (can be anything)– start is start tag (can be anything)

• To checkout a directory,cvs checkout foo

– All files in foo subdirectory of repository are copied to current directory

Page 10: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Changing files

• To add a file to the repository,cvs add file ; takes effect at the next commit

• To remove a file from the repository,cvs remove file ; takes effect at the next commit

• To commit changes you’ve made to a file,cvs commit files

• To tag a file revision,cvs tag –c MyProject-v1.0.0.0 files(-c warns and aborts if source files are not up-to-date)

Page 11: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Bringing files up to date

• To bring local files up to date,cvs update

– All files in current directory are updated using repository– For each file, prints one-letter code:

• U (update): your file has been updated with someone’s changes• M (merge): same, but you had made changes to the file, too• C (conflict): same, but CVS could not merge the changes• ? (unknown): file is not under CVS control

• Note: You cannot commit a file unless it’s up-to-date

Page 12: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Other useful commands

• To get information about a file,cvs status file

• To examine a file’s log,cvs log file

• To see who made what change,cvs annotate file

Page 13: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Conflicts

• If two people modify the same part of a file, there is a conflict

• CVS retains both sets of changes in the file, separated by <<<< (changes1) ==== (changes2) >>>>

• Example:

main() { <<<<<<< hello.c puts("Hello, World!"); ======= printf("Hello World"); >>>>>>> 1.2 }

Page 14: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Setting up server

• Create a CVS repository if there is not already one • Add this to /etc/services:

cvs 2401/tcp # remote cvs server • Add this to /etc/inetd.conf:

cvs stream tcp nowait root /path/to/cvs cvs pserver• Restart inetd• To encrypt password for CVSHOME/passwd file,

– /usr/local/bin/perl -e 'print crypt("MyPassword","St") . "\n";‘

– copy and paste into passwd file as name:epswd• To use RSH instead,

use :ext instead of :pserver for CVSROOT. Might want to add set CVS_RSH to ssh which makes CVS use SSH and encryption for remote access.

• Initialize CVS repository,cvs –d /usr/local/cvsrep init ; sets up CVSROOT directory

Page 15: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Versions and revisions• Each file has a unique revision number

– Even number of dot-separated integers (start with 1.1)– Successive revisions increment the rightmost number

• Each branch has a unique branch number– Number appended to revision number– Correspond to user versions

Page 16: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Suggested CVS policies

• Each file has an owner• You may

– completely modify your own file (but don’t change class interface)

– make minor/obvious bug fixes to others’ files, but only if 100% confident (also notify them, just in case)

– ask for permission before making bigger changes, or request the change from the developer

• Alternative: You are never allowed to modify anyone else’s file– Good: no chance of conflict– Bad: extra overhead, not taking advantage of the “C” in CVS

(might as well be using lock-modify-unlock)

Page 17: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Other suggestions

• Make sure system clock reflects real time• Frequently update

(stay in sync with repository)• Frequently commit changes

(once compiled, completed, tested, reviewed)• Do NOT share code except via repository

(e.g., emails)• Build early, build often (BEBO)• Tag early, tag often• Save executables associated with tagged builds

Page 18: An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University

Obtaining CVS

• CvsGui (WinCVS/MacCvs,gCvs): http://www.wincvs.orgDownload and install; this is a GUI front-end and also includes CVSCVS: http://www.cvshome.orgIf you just want the command-line version; documentation is here, too