Académique Documents
Professionnel Documents
Culture Documents
Subversion Architecture
On a local filesystem
Typically used for a single developer Accessed via direct file read/write access Requires that users have local accounts Uses filesystem and user/group security Accessed via a HTTP or HTTPS connection Does not require that users have accounts on the server Use Apache style authentication
On a remote system
Browse repository with Internet Explorer or Netscape With mod_deflate, compression can be used between client and server
Data integrity Atomic writes Recoverability Hot backups
CVS
Argument position matters % cvs d /export/home1/cvs update d Argument position does not matter % svn log r 123 foo.c % svn log foo.c r 123
SVN
Revision numbers are applied to an object to identify a unique version of that object Example files
% ls bar.c foo.c
CVS
Revision numbers are per file A revision number from one file does not necessarily have any meaning to another file with the same revision number A commit only updates the revision numbers of files that were modified bar.c may be at revision 1.2 and foo.c at 1.10 Updates to bar.c will not change foo.cs revision number
Subversion
Revision numbers are global across the whole repository Identify how the entire repository looks at that instant in time A commit creates a snapshot of the entire tree in the repository at that revision number Allows users to say, Hey so-and-so, go get revision 1432 of XYZ and try to compile it. Before an update, both bar.c and foo.c are at revision 25 Modify bar.c and commit Then update the working copy Now bar.c and foo.c are at revision 26, except that foo.c in revision 25 and 26 are identical No additional space in repository required, i.e. a cheap copy or a symbolic link is made
Edit search.c
% vi search.c
% svn info . Path: . Url: file:////tmp/repos/demo Revision: 4 Node Kind: directory Schedule: normal Last Changed Author: blair Last Changed Rev: 4 Last Changed Date: 2002-08-08 12:20:18 -0700 (Thu, 08 Aug 2002)
Update all files and directories to the most current version % svn update Go to a particular older revision for all files and directories % svn update r 1345 I want an even older version of svn-doc.el % svn update r 999 svn-doc.el U `foo'
Update output
A `foo'
D `foo'
R `foo'
G `foo'
C `foo'
Make changes
Add new files and directories % xemacs blair_super_algorithm.c % mkdir data-files % touch data-files/file1 % svn add blair_super_algorithm.c data-files # data-files/file1 not added unless R passed to svn add Delete files % svn rm foo what_do_they_know.c Rename file % svn mv README.txt README_OLD.txt # This is identical to % svn cp README.txt README_OLD.txt; svn rm README.txt Copy files and directories % svn cp test_datafiles test_datafiles_new # If test_datafiles is a directory, then test_datafiles_new # is an exact copy of test_datafiles
% svn status -v M 44 _ 44 M 44 _ 44 _ 44 D 44 _ 44 A 0 _ 44
First column the same Second column, working revision Third column, last changed revision Fourth column, who changed it
23 30 20 18 35 19 21 ? 36 joe frank frank joe mary frank mary ? joe ./README ./INSTALL ./bar.c ./stuff ./stuff/trout.c ./stuff/fish.c ./stuff/things ./stuff/things/bloo.h ./stuff/things/gloo.c
Asterisks show if the file would be updated if svn update were run Requires network access to the repository
23 20 35 19 ? joe frank mary frank ? ./README ./bar.c ./stuff/trout.c ./stuff/fish.c ./stuff/things/bloo.h
% svn status -u -v M * 44 M 44 _ * 44 D 44 A 0
Even shows modifications in properties Show all differences in files and directories in local working copy % svn diff Diff between revision 3 of foo.c in repository and local working foo.c % svn diff r 3 foo.c Diff between revisions 2 and 3 of foo.c in the repository without even touching local foo.c % svn diff r 2:3 foo.c
Generate a log message containing the files and directories that have been modified
% svn status | cut -d/ -f2- > ../message % vi ../message % svn commit F ../message
Conflict Resolution
Look for the C when you run svn update Better than CVS
Solutions to resolve
Conflict markers are placed into the file, to visibly demonstrate the overlapping areas. This matches CVS' behavior. Three fulltext files starting with `tmp' are created; these files are the original three files that could not be merged together. This is better than CVS, because it allows users to directly examine all three files, and even use 3rd-party merge tools (as an alternative to conflict markers.) Another improvement over CVS conflict handling: Subversion will not allow you to "accidentally" commit conflict markers, as so often happens in CVS. Unlike CVS, Subversion remembers that a file remains in conflict, and requires definite action from the user to undo this state before it will allow the item to be committed again.
Hand-merge the conflicted text Copy one of the tmpfiles on top of your working file Run svn revert to toss all of your changes Run svn resolve This deletes the tmp files
Once resolved, you need to tell SVN that the conflict has been resolve
% svn log -----------------------------------------------------------------------rev 3: fitz | Mon, 15 Jul 2002 18:03:46 -0500 | 1 line Added include lines and corrected # of cheese slices. -----------------------------------------------------------------------rev 2: someguy | Mon, 15 Jul 2002 17:47:57 -0500 | 1 line Added main() methods. -----------------------------------------------------------------------rev 1: fitz | Mon, 15 Jul 2002 17:40:08 -0500 | 2 lines Initial import -----------------------------------------------------------------------% svn log -r ... # shows % svn log -r ... # shows % svn log -r ... 5:19 logs 5 through 19 in chronological order 19:5 logs 5 through 19 in reverse order 8
Each files and directory has associated with it a hash, otherwise known as a associative array, of properties Store any information in the hash Subversion uses hash key names prefixed with svn: for its own use In these examples, svn:XXX is a hash key name, it is not a hash key and value pair Listing properties
% svn proplist README.txt Properties on README.txt': svn:eol-style
For complicated values, such as the list of files and subdirectories to ignore which contain a list across multiple lines, load the values into an editor:
% svn propedit svn:ignore . Set new value for property `svn:ignore' on `.'
svn:executable
For files only, sets the executable bit Useful for scripts and programs The executable bit is set when the property is applied to the file, not when the commit is performed The executable bit is removed when this property is removed from the file The property value does not matter, any value will do
SVN assumes a text file if svn:mime-type is not set or is set and matches text/*, otherwise it is a binary file If a file is a text file, SVN can use diff and patch to update changes from the repository Useful for setting the MIME type of a file for web browsing
svn:mime-type
svn:ignore
svn:keywords
For directories only Tells SVN which files and subdirectories to ignore Equivalent to CVSs .cvsignore file Keyword substitution in files The only available keyword substitutions are LastChangedDate, LastChangedRevision, LastChangedBy and HeadURL Only the keywords listed in the svn:keywords property value are replaced in the file $LastChangedDate: 2002-07-22 21:42:37 -0700 (Mon, 22 Jul 2002) $ $LastChangedRevision: 144 $ $LastChangedBy: joe $ $HeadURL: http://svn.collab.net/repos/trunk/README $
svn:eol-style
Native
Convert all CR, CRLF and LFs to the systems native eol
CR
Convert all CRLF and LFs to CRs
CRLF
Convert all CR and LFs to CRLFs
LF
Convert all CR and CRLFs to LFs
Vendor releases all go in /vendor/PRODUCTNAME, i.e. /vendor/super-orca2 These are unmodified releases The current vendor release is in /vendor/PRODUCTNAME/current Older releases are in /vendor/PRODUCTNAME/VERSION The main OrcaWare trunk is in /orcaware/trunk/PRODUCTNAME, i.e. /orcaware/trunk/super-orca2 Tagged releases of the trunk are in /orcaware/tags/PRODUCTNAME/VERSION Each developer gets their own branch in /orcaware/branches/USERNAME-PRODUCTNAME-DESCRIPTION
Work progresses in the branch Time to merge work into trunk But first, merge trunk changes to branch
% # % # svn merge r 123:HEAD https://svn.orcaware.com/orcaware/trunk/super-orca2 . Test new code. svn commit F message_file1 Revision 256.
Subversion home
http://svn.subversion.com/
http://subversion.tigris.org/files/documents/15/576/svnhandbook.html
Subversion handbook
http://subversion.tigris.org/files/documents/15/177/foo.ps
http://subversion.tigris.org/servlets/ProjectDocumentList
http://subversion.tigris.org/project_status.html
http://subversion.tigris.org/servlets/ProjectDocumentList
Thanks To