Sophia Antipolis Introduction to version control David Rey – DREAM – 15 dec. 2004
Sophia Antipolis Overview l Collaborative work and version control l Main CVS user commands l Advanced use of CVS l CVS server at INRIA Sophia Antipolis
Sophia Antipolis Overview l Collaborative work and version control l Main CVS user commands l Advanced use of CVS l CVS server at INRIA Sophia Antipolis
Sophia Antipolis Collaborative work and version control: examples l Development Source files: C, C++, java, Fortran, Tcl, Python, shell scripts, … Build/config files: Makefile, ant, … l Text documents/articles/bibliographies Plain text Latex/bibtex l Web pages Html Php, javascripts, … l XML documents l... ASCII documents
Sophia Antipolis A software development process at INRIA l INRIA recommandations about software development: l In particular, concerning version control:
Sophia Antipolis Version control main ideas l Distributed documents/collaborative work Automatic merging Alarms on conflicts Ease the communication between users (log messages, s, …) l Version control: incremental versions All previous versions available Minimal necessary disk space (incremental) History of changes/logs
Sophia Antipolis Version control software l CVS: l Arch: l Subversion: l Forges that use version control software: ( GForge : Savannah : savannah.gnu.orgsavannah.gnu.org LibreSource : libresource.inria.frlibresource.inria.fr Visual Source Safe (pour Windows) : msdn.microsoft.com/vstudio/previous/ssafemsdn.microsoft.com/vstudio/previous/ssafe
Sophia Antipolis CVS: Concurrent Version System l Widely used on a lot of different platforms (Linux, Windows, …) l Open source license l For local and/or distant usage l Recommended for INRIA software developments l Several clients possible Command line GUI: tkCVS, jCVS, WebCvs, Jalindi igloo, WinCVS, TortoiseCVS
Sophia Antipolis What CVS is for ? l Several users work together at the same time on the same files (concurrency) l Version control Tags Version comparisons Multiple lines of development in the same base Branching Support for binary files Event control (e.g. notification)
Sophia Antipolis What CVS is not for ? l Backup l Bug tracking l Source documentation l Dependencies l …
Sophia Antipolis Overview l Collaborative work and version control l Main CVS user commands l Advanced use of CVS l CVS server at INRIA Sophia Antipolis
Sophia Antipolis CVS: client/server architecture 2 possibilities: Shared directory CVS server CVS Clients Local Client/Server CVS Clients
Sophia Antipolis CVS hierarchy l Repository root or “CVSROOT” Looks like “cvs-sop.inria.fr:/CVS/SmartTools” set the CVSROOT environment variable on UNIX systems configure an item in the setup menus of a GUI client Use the command line: cvs –d CVSROOT l Modules For example SmartTools uses 3 modules: SmartTools, SmartToolsAddons, Documents l Directories Each module contains an arbitrary hierarchy of directories l Files (incremental diff versions of)
Sophia Antipolis CVS hierarchy : an example cvs-sop.inria.fr:/CVS/SmartTools REPOSITORY (CVSROOT) SmartToolsAddons SmartTools Documents ant demo doc src eg.exe web latex MODULES FOLDERS AND FILES
Sophia Antipolis CVS help cvs --help-commands (list available commands) cvs --help-options (list general options) cvs -H import (specific help for a command and its specific options, e.g. “import”) CVS general options + specific command options are different : cvs [general options] [specific options]
Sophia Antipolis CVS --help-commands
Sophia Antipolis CVS --help-options
Sophia Antipolis CVS -H import
Sophia Antipolis Import l Used to synchronize a local tree as a whole with the server l Most often used to initialize the server tree l Can also be used after this initial step at any time (to avoid one-by-one files addition) l cd local_directory l cvs import –m “message” directory_on_base branch_name version_name
Sophia Antipolis Checkout and update l cvs -d cvsroot checkout module_name l cvs update –d directories/files U: updated P: the version on the server is newer and the local copy has been updated M: modified (or merged), the local file is different from the server file and merge was done in the local copy ?: unknown, this file is present locally and not in the CVS base A: added, this file is present locally and has been added (before commit) R: removed, this file is not present locally and has been removed (before commit) C: conflict, the local file has been marked with conflict markers which identify the different conflict locations
Sophia Antipolis Checkout: example
Sophia Antipolis Update: example
Sophia Antipolis Commit l cvs commit -m “my message” directories/files l Always use explicit messages !!! l List of forbidden messages: “my message” “” ? “modification of file toto.tex” which modification ? “bug fixed” which bug ? …
Sophia Antipolis checkout Ideal Development (1/4) base Developer A Developer B
Sophia Antipolis development Ideal Development (2/4) base Developer A Developer B
Sophia Antipolis checkin Ideal Development (3/4) base Developer A Developer n
Sophia Antipolis update Ideal Development (4/4) base Developer A Developer B
Sophia Antipolis checkin Real Development (1/5) base Developer A Developer B
Sophia Antipolis checkin X Real Development (2/5) base Developer A Developer B
Sophia Antipolis Real Development (3/5) base Developer A Developer B update conflict
Sophia Antipolis Real Development (4/5) base Developer A Developer B Conflict Resolution
Sophia Antipolis Real Development (5/5) base Developer A Developer B checkin
Sophia Antipolis Conflicts l Do not panic! Many problems are easy to fix Generally, it does not require a lot of interaction l If necessary, discuss with people to find a compromise Meetings Phone … l Usually can be avoided with regular updates
Sophia Antipolis Status, log, diff, annotate l cvs status filename Gives information about local file with comparison to base file l cvs log filename Show all the previous versions number, comitter, date and number of lines modified l cvs diff filename Show lines where there are differences between local and base file l cvs annotate filename Gives information line by line: version of introduction, who, when
Sophia Antipolis Status examples
Sophia Antipolis Log examples
Sophia Antipolis Diff examples
Sophia Antipolis Annotate examples
Sophia Antipolis Tagging l Tag = string marker which is applied to the status of a part of the CVS hierarchy l Often used to mark a given version of the cvs repository with a string which refers to a version of the software released l Easily get back specific versions of the software Use/distribute a given released version Reproduce bugs for a given release version l Only files are tagged l cvs tag –r 1.2 tagname files cvs rtag tagname files (latest version in the base is tagged)
Sophia Antipolis Add, delete, and move files l cvs add filenames l Produces a message that explains that a commit is necessary l cvs commit -m “addition of files bla…” directories/files Files have to be locally deleted: rm filenames Produces a message that explains that a commit is necessary l cvs remove filenames l cvs commit -m “removed files bla…” directories/files l Trace of deleted files in Attic directories on the CVS base l Move = add + delete, with an explicit message to keep a trace of the old names
Sophia Antipolis Add, delete, and move folders l As simple as files for addition; do not need a commit command to take effect l Not possible to delete and/or move folders! Except with “hard” intervention, cf. advanced use of CVS section
Sophia Antipolis Summary of the main commands cvs [cvs-options] command [cmd-options] [directories/files] cvs importimport files from a local directory to the cvs base cvs checkoutcopy on a local disk a given version of the cvs base cvs commitapply the modifications of the local copy to the cvs base cvs updateupgrade the local copy with a version of the cvs base cvs addadd a file to the cvs base cvs removeremove a file from the cvs base cvs statusshow the status of a local file wrt the cvs base cvs logshow the different previous commit stages cvs diffshow lines in local and server files that differ cvs annotateshow information line by line of a version in the cvs base cvs tag (or rtag)put a tag to identify a given version of the cvs base
Sophia Antipolis Overview l Collaborative work and version control l Main CVS user commands l Advanced use of CVS l CVS server at INRIA Sophia Antipolis
Sophia Antipolis CVS Administration l Modules administration l Usage definition Events control ( s, …) Watch/edit
Sophia Antipolis CVS base configuration l CVSROOT Module (exists by default) cvs checkout CVSROOT l Configuration files modules, modules definitions cvswrapper binary files control cvsignore list which files CVS has to ignore (*.o, …) commitinfo, editinfo, loginfo, notify, rcsinfo, taginfo make it possible to configure actions with respect to specific CVS operations
Sophia Antipolis Binary files in CVS base l No real version control (diffs don’t work) l Binaries are corrupted if treated as ASCII files Can be done with command line: cvs add –kb filename l Can be forced for known extensions Configuration file: cvswrapper
Sophia Antipolis Configuration file for binary extensions: examples
Sophia Antipolis Recursion with CVS l Check each command to see if it is recursive or not Add is not recursive, update is recursive, … l Read the cvs manual (note we are in the « advanced section » of the expose)
Sophia Antipolis Windows users l Several CVS clients: webCVS, winCVS, … l Possible use of CVS with ssh under Windows via putty (Windows ssh client) contact me l Problems with line ending … always edit files on the platform where the checkout has been done!
Sophia Antipolis Branching l Branching is easy… merging is not! l When ? Before a release (“freeze” the code in a branch) For parallel development that will not be integrated directly For someone developing during a training period For some “research code” For a specific application (e.g. dedicated to a given client)
Sophia Antipolis Direct manipulations on the server l To restructure a repository (e.g. move or delete folders) l To check for possible problems l For instance, administrators of a CVS repository at Sophia can connect to the server via ssh: ssh cvs-sop.inria.fr cd /CVS/SmartTools
Sophia Antipolis Overview l Collaborative work and version control l Main CVS user commands l Advanced use of CVS l CVS server at INRIA Sophia Antipolis
Sophia Antipolis Admistrated by the semir l Semir page about the INRIA cvs server: l Hotline SEMIR to open a new repository: “Logiciels/Outils” then “Agenda, CVS, FTP, MYSQL” Chose “CVS” and “Creation” …
Sophia Antipolis ssh access l Good level of security for the authentication l l In actual using, only few differences: cvs -d checkout web
Sophia Antipolis Administrative tasks l Standard CVS administration (cf. “CVSROOT” Module) l “Admin” module automatically in the repository when created by the SEMIR 3 files: group-def, modules-def, passwd-def l group-def: define and describe groups of users l modules-def: define access rights for each module wrt groups (ssh, anonymous) l passwd-def: define and describe accounts (username, crypted password and ) for non INRIA users
Sophia Antipolis References and links l CVS: l GUI: l INRIA server: l CVS Configuration et mise en œuvre. Frédéric Lepied. O’Reilly Eds. (available at the documentation centre of INRIA Sophia: ref. O356 )
Sophia Antipolis Closing remarks & Questions l Use version control systems from the start When working alone or in a group For development projects or scientific papers When tag released versions l Handy FAQ’s on the CVS home site Next seminar is next year! January 13th on Refactoring