36
Introductory Concurrent Version System (CVS) UCR Technical Seminar 10/23/03 Dan Berger dberger @ cs . ucr . edu

Introductory Concurrent Version System (CVS)

  • Upload
    adila

  • View
    51

  • Download
    0

Embed Size (px)

DESCRIPTION

Introductory Concurrent Version System (CVS). UCR Technical Seminar 10/23/03 Dan Berger [email protected]. edu. Adgenda. Introduction What is configuration management? Key concepts. CVS Workflow Copy-Modify-Merge Getting Started with CVS Creating a repository Importing assets - PowerPoint PPT Presentation

Citation preview

Page 1: Introductory Concurrent Version System (CVS)

Introductory Concurrent Version System (CVS)

UCR Technical Seminar10/23/03

Dan Berger [email protected]

Page 2: Introductory Concurrent Version System (CVS)

Adgenda

Introduction– What is configuration management?– Key concepts.

CVS Workflow– Copy-Modify-Merge

Getting Started with CVS– Creating a repository– Importing assets– Checking in & Checking Out

Using CVS– Managing Change

Page 3: Introductory Concurrent Version System (CVS)

Introduction: What is CM?

Record Keeping– What assets (source, binary) went into

producing some product?– What did this asset look like at some point

in the past?

Collaboration– Who's working on which assets?– Who worked on this asset last?– Who made a specific change to this asset

(and when?)

Page 4: Introductory Concurrent Version System (CVS)

Introduction: Key Concepts

Repository: The “master” copy of the assets.– Contains all revision history for all

assets.

Working Directory (aka sandbox): a developers private copy of the assets.– Contains a copy of a particular version of

assets.

Page 5: Introductory Concurrent Version System (CVS)

CVS Workflow

CVS allows multiple people to be working on the same set of assets at the same time. Copy-Modify-Merge means you take a copy of the assets, modify your local copy, and merge your changes back in to the master repository.

Page 6: Introductory Concurrent Version System (CVS)

CVS Workflow (cont.)

cvs checkout <project>– edit to your hearts content…

cvs update– resolve conflicts

cvs commit

Page 7: Introductory Concurrent Version System (CVS)

Getting Started w/ CVS

Creating a Repository (one time only)Importing AssetsChecking out a working copyViewing changesCommitting changesWorking with previous versions

Page 8: Introductory Concurrent Version System (CVS)

Creating a Repository

% export CVSROOT=~/CVSRoot

% cvs init

% ls –l ${CVSROOT}

drwx------ CVSROOT/

There are some magic files in ${CVSROOT}/CVSROOT – ignore them for now.

Page 9: Introductory Concurrent Version System (CVS)

Importing Assets

importing places a copy of an existing directory tree (rooted at `pwd`) into the repositorycvs import mod-path vendor release– mod-path is the directory under

$CVSROOT to import the files into– vendor and release are more complicated

but (for our purposes) less important. • I suggest vendor=`whoami`, release=“initial”.

Page 10: Introductory Concurrent Version System (CVS)

Importing Assets Example

% cvs import cvs-seminar/hello-world\ `whoami` initial \

–m “initial import”

N cvs-seminar/hello-world/hello.C

N cvs-seminar/hello-world/Makefile

No conflicts created by this import

Page 11: Introductory Concurrent Version System (CVS)

Importing Assets (Cont.)

Importing assets doesn’t touch the files in the current directory.That also means changes to the files in the working directory aren’t tracked.We need to get a copy from the repository first…

Page 12: Introductory Concurrent Version System (CVS)

Getting a Working Copy

% cvs checkout \

cvs-seminar/hello-world

cvs checkout: Updating cvs-seminar/hello-world

U cvs-seminar/hello-world/Makefile

U cvs-seminar/hello-world/hello.C

% ls –l cvs-seminar/

CVS/

% ls –l cvs-seminar/hello-world

CVS/

hello.C

Makefile

Page 13: Introductory Concurrent Version System (CVS)

Viewing Changes

Imagine we changed the files – fixing the typo in hello.C and adding a default target to the Makefile.Before we commit these changes, we’d like to see what we actually changed:cvs can show us which files have changed, and/or the specific changes to the files.

Page 14: Introductory Concurrent Version System (CVS)

cvs -n update

% cvs –n updatecvs update: Updating .M MakefileM hello.C? hello

the leading “M” indicates the file has been Modified. The “?” means the file isn’t being managed by CVS.

Page 15: Introductory Concurrent Version System (CVS)

cvs diff

% cvs diff hello.CIndex: hello.C=========================================RCS file: …retrieving version 1.1.1.1diff –r 1.1.1.1 hello.C11c11< cout << “Helllo, world!” << endl;---> cout << “Hello, world!” << endl;

Page 16: Introductory Concurrent Version System (CVS)

cvs status

cvs status will tell you the status of a file in your working copy.

% cvs status hello.C

===================================

File: hello.C Status: Up-to-date

Working revision: x.x

Repository revision: x.x

Page 17: Introductory Concurrent Version System (CVS)

Adding Files

CVS will essentially “ignore” new files, until you tell it they’re important and should be managed.

% cvs add README

cvs add: scheduling file ‘README’ for addition

cvs add: use ‘cvs commit’ to add this file permanently

Page 18: Introductory Concurrent Version System (CVS)

Deleting Files

first, remove the file from your working copy (with rm), then

% cvs delete filecvs remove: scheduling `FILE’ for removalcvs remove: use ‘cvs commit’ to remove \

this file permanently

% cvs commitRemoving FILE;…/FILE,v <-- FILEnew revision: delete; previous revision: 1.1done

Page 19: Introductory Concurrent Version System (CVS)

Removing Files (cont.)

CVS doesn’t actually remove the file, it places it into the Attic.– You can still retrieve any version of

the “deleted” file:% cvs up –r X.Y FILE

U FILE

Page 20: Introductory Concurrent Version System (CVS)

Renaming

One place where CVS makes life difficult*. Renaming files is non-trivial.Two methods: – one that preserves change history, but

requires file system access to the repository,

– and one that breaks change history but can be done completely through the client.

Page 21: Introductory Concurrent Version System (CVS)

Renaming: The Easy Way

% cp old-name new-name% rm old-name% cvs delete old-name% cvs add new-name% cvs commit

You can explain the rename in the log message, and point viewers to the old-name for complete revision history.

Page 22: Introductory Concurrent Version System (CVS)

Committing Changes

Once we’re happy with our changes, we need to commit them to the repository.We can commit all our changes, or changes to an individual file (often dangerous).

Page 23: Introductory Concurrent Version System (CVS)

Checking In Example

% cvs commit cvs commit: Examining .Checking in Makefile;…/Makefile,v <-- Makefilenew revision 1.2; previous revision 1.1RCS file: …/README,vdoneChecking in README:…/README,v <-- READMEinitial revision 1.1doneChecking in hello.C…/hello.C,v <-- hello.Cnew revision 1.2; previous revision 1.1done

Page 24: Introductory Concurrent Version System (CVS)

Working with Versions

the –r tag can be provided to CVS commands, and it will cause them to affect a specific version of the named asset.For example: % cvs diff –r 1.1 Makefile

You can also check out previous versions of files (cvs co –r x.x filename), and even commit to (branch from) previous versions of files.

Page 25: Introductory Concurrent Version System (CVS)

Diff and Patch

Not strictly CVS related, but terribly valuable tools.diff generates the differences between two (sets of) files.patch can apply that set of differences to another file

Page 26: Introductory Concurrent Version System (CVS)

Diff Example

Say I have two copies of my project:– unmodified-copy and modified-copy

% diff –Naurw unmodified-copy \ modified-copy

CVS will do this also, without having two versions checked out:

% cvs diff –auw –r other-version

Page 27: Introductory Concurrent Version System (CVS)

Patch Example

Once I have a unified diff (the –u to diff), I can apply the changes specified in the diff to another file:

% patch < diff-file

This also works with trees of files.Read the man page to patch for more options.

Page 28: Introductory Concurrent Version System (CVS)

CVS Version Numbers

Imported files have an initial version of 1.1.1.1 – there’s a reason, but for now just ignore it.“Normal” version numbers are w.x – cvs automatically increments x each time you commit changes to the file. It never automatically increments w.– If you branch a file, it’s version number

becomes w.x.y.z. We’re not going to talk about branches in this talk. (Advanced CVS, anyone?)

Page 29: Introductory Concurrent Version System (CVS)

CVS Magic Strings

Some strings have special meaning to CVS, and if they appear in your files, CVS will “evaluate” them during checkout.– $Id:$ is the most common/useful, it

gets evaluated to a string of the form:$Id: Makefile,v 1.2.1.3 2003/10/20 \ 23:08:20 dberger Exp $

Page 30: Introductory Concurrent Version System (CVS)

CVS and Binary Files

CVS assumes that files are text unless told otherwise. This can cause issues if a binary file (like a jpg, PDF, etc.) contains one of the magic strings mentioned above.This can be handled two ways: file-by-file, or by file extension:% cvsadmin –kb fileor adding the extension to cvswrappers (more later)

Page 31: Introductory Concurrent Version System (CVS)

${CVSROOT}/CVSROOT

CVSROOT/ contains control files – many of which are only interesting if you’re using CVS in a group.– CVSROOT is just another module – so you

can check it out/diff it/commit to it.– DON’T TOUCH THESE FILES DIRECTLY!

Remember “cvswrappers”? It lives here – it allows hooks to run when files go in or out of CVS. There’s a sample linked from the tech seminar page.

Page 32: Introductory Concurrent Version System (CVS)

Accessing CVS Remotely

Three methods, pserver, rsh, ext.pserver is a cvs-specific network protocol, it’s not encrypted and has to be setup by the remote admin – so we’re going to ignore it.rsh is just too horrible for words, which leaves ext:% export CVS_RSH=ssh

% export CVSROOT= \ :ext:user@host:/path/to/cvsroot

note that cvsroot is the directory containing CVSROOT/

Page 33: Introductory Concurrent Version System (CVS)

Remote CVS (cont.)

Note that if your CVS repository is NFS exported and always available directly (I.e. it’s in your home directory), you don’t need to use the ext method to reach it.

% export CVSROOT=/home/…/CVSRoot

Page 34: Introductory Concurrent Version System (CVS)

What We Didn’t Cover

cvs watchers and editorsanonymous cvsCVS and IDE’s (emacs/eclipse, etc)PermissionsTaggingBranchingMergingDetecting and Resolving Conflicts…

Page 35: Introductory Concurrent Version System (CVS)

Subversion

<skeptic> a “better” CVS </skeptic>You can’t set it up for yourself (it’s repository can’t live on an NFS share, like your home directory).The command line interface is very similar (intentionally).

Page 36: Introductory Concurrent Version System (CVS)

Where to Find More

CVS Home Page: http://www.cvshome.orgCVS Online Book: http://cvsbook.red-bean.comCVS GUI’s: http://www.wincvs.org– TortoiseCVS (Windows Explorer Extension):

http://www.tortoisecvs.org

Subversion Home Page: http://subversion.tigris.orgSubversion Online Book (draft): http://svnbook.red-bean.com