department of mathematics and computer sciencedepartment of mathematics and computer science...

31
/ department of mathematics and computer science technische universiteit eindhoven TU/e version control on files with CVS demo / discussion hour HG 6.29 Nov 19, 2003 Reinier Post

Post on 20-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

/ department of mathematics and computer science

technische universiteit eindhovenTU/eversion control on files

with

CVS

demo / discussion hour

HG 6.29

Nov 19, 2003

Reinier Post

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS – Concurrent Versions System

CVS is software for version control

on directory trees with files.

http://www.cvshome.org/

/ department of mathematics and computer science

technische universiteit eindhovenTU/eversion control on files

Multiple versions of a file: for example

• a document you’re editing + a backup copy

• your document at home + a copy at work

• your version of a document + Harry’s version

• a copy of a webpage + the version you modified

with your suggestions

/ department of mathematics and computer science

technische universiteit eindhovenTU/eversion control on whole directory trees

Multiple versions of directory trees full of files:

• a website

• a LaTeX document (single author or co-authored)

• the source code of a computer program

• a user software profile (config files, startup

scripts, utilities)

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 0: find some examples

locate .oud; locate .old

locate /home | grep -v '[~%v]$' | ~rp/bin/previsprefix

most files are completely redundant - not worth saving!

• local copies of available files copied from elsewhere

• files generated by programs from other files

• temporary backup copies

different versions of the same file: only partially redundant

=> version control problem: what to save, when, and where?

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 1: diff

locate /home/rp | grep -v '[~%v]$' | fgrep -v rpsoft | previsprefix

diff

diff –u

diff –r

diff

• is a standard Unix tool (since the 70s)

• only useful on plain text files, including structured plaintext

(source code, XML , etc.) if formatted uniformly

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 2: patch

diff –u a a.modified > a.diff

rm a.modified

patch < a.diff # turns a into a.modified !

patch

• is a standard Unix tool (since the late 80s)

• only applicable when you can work with diffs

• allows “merging” different changes into single result

/ department of mathematics and computer science

technische universiteit eindhovenTU/eRCS: version control on a file

• let user explicitly commit versions of a file

• remember all versions the user doesn’t remove

• be “clever”: save the diffs!

• every version has a number

• every version has an (optional) log message

• RCS can record info about the version in the file

• written in 1985, soon very popular

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 3: RCS

locate /home/rp | grep RCS # on win.tue.nl Solaris/Linux

# examine a ,v file, you’ll see they are diffs

main RCS commands:

• ci file # check current version of file in to file,v

• co file # check latest version of file out from file,v

• rcsdiff file # diff file with latest version in file,v

/ department of mathematics and computer science

technische universiteit eindhovenTU/ethe power of RCS

On a file in RCS you can ask questions like:

• is this copy the latest “good” version?

• to which “good” version (created when) does this

copy correspond, if any?

• what are the diffs between June 1st and today?

• is the copy I mailed to Harry older or newer

than the copy on the website?

/ department of mathematics and computer science

technische universiteit eindhovenTU/eversion control with RCS: properties

• working copy vs. repository

• the repository (file,v) holds versions of the

working copy, but is not a working copy itself

• no automatic “tracking” of changes in working

copies; the user is trusted to check versions in

and out as appropriate

• this can lead to conflicts

if multiple working copies are edited

/ department of mathematics and computer science

technische universiteit eindhovenTU/elimitations of RCS; CVS

• only works on single files

• single host: ci / co work on “local” file system

=> CVS (written in 1986 on top of RCS) =>

• RCS on a whole directory tree of files at once

• many extra features

• repositories can be remote (client/server)

• nice GUI clients and repository browsers available

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 4: CVS for private use

cd ~/bin; cvs log

main CVS commands:

• cvs ci file # check current version of file in to $CVSROOT

• cvs co file # check latest version of file out from $CVSROOT

cvs up file # id., if a copy is already available

• cvs add file # put a file under version control in $CVSROOT

• cvs diff file # compare current copy of file with latest in $CVSROOT

file can be a whole directory tree, $CVSROOT can be remote

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 4 (continued)

cd /tmp

cvs –d /home/rp/cvs co scripts

cd scripts

rightperl bin/*

cvs diff

# on a different host:

cd /tmp

cvs –d :ext:[email protected]:/home/rp co scripts # via ssh!

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 5: the Tortoise CVS client

a (free) GUI CVS client for Windows

easier to use than the command line,

but everything works the same way:

• right-click to get the initial menu, select CVS Checkout ...

• select the repository and communication method,

• inside the resulting directory you can CVS update and check in

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 6: CVS for collaboration

co-authoring papers:

• one author hosts the CVS repository

• gives other author(s) read/write access to it

software development projects:

(demo) petriweb.org:

• website, software & docs in CVS

• checked out automatically (using a CVSROOT/ feature)

/ department of mathematics and computer science

technische universiteit eindhovenTU/eauthentication for remote CVS servers

• with the :pserver: protocol:

- the CVS server runs as one OS user

- user accounts are managed in the CVS server

- good for read-only access; too insecure for read-write access

• with :ext: (ssh):

- with one CVS server user, slightly better than pserver

- with arbitrary repositories for arbitrary groups of people,

it requires a lot of account administration

(SourceForge: every user can get a Unix account by registering)

/ department of mathematics and computer science

technische universiteit eindhovenTU/edemo 7: public CVS

SourceForge ( http://sf.net/ ): over 70,000 CVS repositories

(pick one for a demo); mostly software development.

Most of the world’s CVS repositories are elsewhere.

/ department of mathematics and computer science

technische universiteit eindhovenTU/ethe power of CVS

CVS allows to set up a single repository

for all files in a project, with full version control.

• you always know where your “good” versions are

and how they are related

• multi-user

• Internet wide

• (largely) platform independent

(on MS Windows you can feel the Unix legacy)

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS: properties

• working copy vs. repository

• the repository holds versions of the working copy,

but is not a working copy itself

• no automatic “tracking” of changes; every user

must check in and check out regularly;

this can lead to conflicts

if multiple working copies are edited

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS administrative files

In the working copy:

• every directory has a subdirectory CVS/

with files used by CVS

• the file .cvsignore can be used to tell CVS to ignore files

in the working copy that must not be in the repository

In the repository:

• the CVSROOT/ directory contains many files with interesting

configurable settings

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS caveats

• cvs add only prepares to add files, you need to confirm with cvs

ci, and on a directory follow that again with cvs up

• files can be explicitly marked as binary (see the manual)

• cvs can cope with the difference between Unix and Windows, but

if files seem corrupted, check the CVS client settings

• If you have many conflicts (a working copy has been edited

while a new repository version was added from another source)

you need to talk to people, not to CVS.

/ department of mathematics and computer science

technische universiteit eindhovenTU/eadvanced CVS commands

creating a repository: cvs init, cvs import

branching:

• cvs tag file # label current version of file in $CVSROOT

• cvs rtag # label current versions in $CVSROOT

this can be used to create branches, forks of the code

• cvs merge args # join two branches together (equiv. of patch)

• cvs edit, cvs editors, cvs watch, etc.:

for change notification

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS: strong points

• entirely free: no cost, no licensing

• everybody and their dog uses it: high reliability, good

support via Google

• simple: config files are plaintext, the protocol is simple,

source code is free, so it’s very transparent

• extensible: it’s easy to wrap stuff around CVS

at client side and server side (e.g. automatic checkout for

petriweb.org: CVSROOT/loginfo calls this script)

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS: weak points

• overly simple: it works on whole directory trees, but

- adding/removing files and dirs is confusing

- renaming files isn’t supported (except remove + add)

- committing multiple files isn’t atomic

- no support for hardlinks / symlinks / shortcuts

- tagging/branching whole trees is hard to do

• the use of diffs:

- performance on binary files is terrible

- performance decreases with the number of commits

/ department of mathematics and computer science

technische universiteit eindhovenTU/ewhen to use CVS

CVS is good when

• you have a collection of (mostly) text files

• you change them or plan to change them regularly (at

least your copies of them)

• you and/or others access them from various locations

• you want to explicitly record and recall “good”

versions of the files

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS only offers version control!

It does not offer:

• a website for your project

• a meeting place / q&a facility for users/authors

• problem report / task scheduling facilities

etc. etc.

See again SourceForge for a survey of other facilities

required to support a project.

/ department of mathematics and computer science

technische universiteit eindhovenTU/ealternatives to CVS

• no version control:

only if you’re sure you’ll only ever need the latest version

• SCCS (standard on Sun Solaris): not popular enough

• Subversion and others want to be CVS-like systems that fix

its worst problems. I haven’t tried them.

• Microsoft Visual SourceSafe. I haven’t tried it.

• more?

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS vs. filesystem backups/copies

a filesystem copy / backup to another disk or tape:

• saves everything indiscriminately

• may or may not save it in a useable state

• has limited memory for older versions

a CVS repository:

• makes the user decide when to save what

• expects selective use (not too many files or saves)

• keeps perfect memory of everything ever saved

/ department of mathematics and computer science

technische universiteit eindhovenTU/ewhere to go next

To learn how to use CVS:

• you don’t need to know much more than this

• good manuals are on the Web

• it takes a few hours to get used to

/ department of mathematics and computer science

technische universiteit eindhovenTU/eCVS @ W&I

Is there any need for a departmental CVS server

• for 1-user projects? (I don’t think so)

• for collaborations within the dept.? (?)

• for collaborations with others?

(useful, but I don’t see how to set it up)

• as a public server for material? (?)

• ?

Other kinds of CVS support? (Training?)