versiebeheer op bestanden met Subversion
description
Transcript of versiebeheer op bestanden met Subversion
LaQuSoLaboratory for Quality Software
versiebeheer op bestandenmet
Subversion
HG 5.9128 september 2009
Reinier Post
LaQuSoLaboratory for Quality Software
Subversion
is softwarevoor versiebeheer
op directory trees (mapstructuren?) met bestanden.
http://subversion.tigris.org/
LaQuSoLaboratory for Quality Software
versiebeheer op bestanden
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
LaQuSoLaboratory for Quality Software
version 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)
LaQuSoLaboratory for Quality Software
demo 0: find some exampleslocate .oud; locate .oldlocate /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?
LaQuSoLaboratory for Quality Software
demo 1: diff
locate /home/rp | grep -v '[~%v]$' | fgrep -v rpsoft | previsprefixdiffdiff –udiff –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
LaQuSoLaboratory for Quality Software
demo 2: patch
diff –u a a.modified > a.diffrm a.modifiedpatch < 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
LaQuSoLaboratory for Quality Software
RCS: 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
LaQuSoLaboratory for Quality Software
demo 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
LaQuSoLaboratory for Quality Software
the 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?
LaQuSoLaboratory for Quality Software
version 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 conflictsif multiple working copies are edited
LaQuSoLaboratory for Quality Software
limitations 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
LaQuSoLaboratory for Quality Software
demo 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
LaQuSoLaboratory for Quality Software
demo 4 (continued)
cd /tmpcvs –d /home/rp/cvs co scriptscd scriptsrightperl bin/*cvs diff
# on a different host:cd /tmpcvs –d :ext:[email protected]:/home/rp co scripts # via ssh!
LaQuSoLaboratory for Quality Software
demo 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
LaQuSoLaboratory for Quality Software
demo 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)
LaQuSoLaboratory for Quality Software
authentication 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)
LaQuSoLaboratory for Quality Software
demo 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.
LaQuSoLaboratory for Quality Software
the power of CVS
CVS allows to set up a single repositoryfor 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)
LaQuSoLaboratory for Quality Software
CVS: 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 conflictsif multiple working copies are edited
LaQuSoLaboratory for Quality Software
CVS 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
LaQuSoLaboratory for Quality Software
CVS 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.
LaQuSoLaboratory for Quality Software
advanced 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
LaQuSoLaboratory for Quality Software
CVS: 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)
LaQuSoLaboratory for Quality Software
CVS: 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
LaQuSoLaboratory for Quality Software
when 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
LaQuSoLaboratory for Quality Software
CVS 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 facilitiesetc. etc.See again SourceForge for a survey of other facilities
required to support a project.
LaQuSoLaboratory for Quality Software
alternatives 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?
LaQuSoLaboratory for Quality Software
CVS 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
LaQuSoLaboratory for Quality Software
where 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
LaQuSoLaboratory for Quality Software
CVS @ 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?)