Version Control/Subversion
The design of Subversion is based on CVS:
Subversion was originally designed to be a better CVS, so it has most of CVS's features. Generally, Subversion's interface to a particular feature is similar to CVS's, except where there's a compelling reason to do otherwise.
Subversion has since expanded beyond its original goal of replacing CVS, but its history influenced its feature and interface choices; Subversion today should still feel very familiar to CVS users.
Subversion Walk Throughs : Windows XP
editWalk Through: Installing Subversion and Subversion Tools
edit- Download the msi svn-1.4.6-setup.exe
- Run the msi
Subversion is made up of several components. Here we'll check the installation of the three components:
- svn
- svnadmin
- svnlook
- Open a command prompt.
C:\>svn --version
svn, version 1.4.5 (r25188)
compiled Aug 22 2007, 20:49:04
Copyright (C) 2000-2006 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
C:\>svnadmin --version
svnadmin, version 1.4.5 (r25188)
compiled Aug 22 2007, 20:49:04
Copyright (C) 2000-2006 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository back-end (FS) modules are available:
* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.
C:\>svnlook --version
svnlook, version 1.4.5 (r25188)
compiled Aug 22 2007, 20:49:04
Copyright (C) 2000-2006 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository back-end (FS) modules are available:
* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.
C:\>
Walk Through: Setting Up a Repository
editThe svnadmin create command is used to create a repository. To make the distiniction clear between client or server in this example we will create two directories server and client. Administration of repositories in the examples is carried out in the server directory whilst client side work is carried out in the client directory.
svnadmin create repos
editThis section looks at creating a repository. In the day to day use of subversion this is a task you will only carry out infreqequently. For trying out new ideas it is useful to know how to set up a simple repository. To create a repository you need to use the svnadmin command.
C:\>svnadmin help create
create: usage: svnadmin create REPOS_PATH
Create a new, empty repository at REPOS_PATH.
Valid options:
--bdb-txn-nosync : disable fsync at transaction commit [Berkeley DB]
--bdb-log-keep : disable automatic log file removal [Berkeley DB]
--config-dir arg : read user configuration files from directory ARG
--fs-type arg : type of repository: 'fsfs' (default) or 'bdb'
--pre-1.4-compatible : use format compatible with Subversion versions
earlier than 1.4
Start by creating the server directory and change into this directory.
C:\WB>MD server
C:\WB>CD server
Create a repository in the repos directory.
C:\WB\server>svnadmin create repos
C:\WB\server>
We can now look at the standard directory structure for a repository.
C:\WB\server>DIR repos
Volume in drive C is MyCDrive
Volume Serial Number is 64A5-9C22
Directory of C:\WB\server\repos
09/01/2009 14:27 <DIR> .
09/01/2009 14:27 <DIR> ..
09/01/2009 14:27 <DIR> conf
09/01/2009 14:27 <DIR> dav
09/01/2009 14:27 <DIR> db
09/01/2009 14:27 2 format
09/01/2009 14:27 <DIR> hooks
09/01/2009 14:27 <DIR> locks
09/01/2009 14:27 234 README.txt
2 File(s) 236 bytes
7 Dir(s) 146,102,767,616 bytes free
C:\WB\server>
svnlook
editsvnlook is part of the subversion utilities. It provides a way of looking at a repository without changing anything about the repository.
C:\WB>svnlook youngest server\repos
0
C:\WB>
This shows that the repository is at revision 0, i.e. no commits have happened yet.
Adding Files to a Subversion Repository
editIf you have an existing file system that you want to add to version control there are several ways of doing this.
- Use svn import
- Create a versioned directory and then commit this.
svn import
editsvn import can be used to import an unversioned directory into subversion. The directory remains unversioned following the import. To work on a versioned copy of the directory it needs to be checked out from the repository.
C:\WB>svn help import
import: Commit an unversioned file or tree into the repository.
usage: import [PATH] URL
Recursively commit a copy of PATH to URL.
If PATH is omitted '.' is assumed.
Parent directories are created as necessary in the repository.
If PATH is a directory, the contents of the directory are added
directly under URL.
Valid options:
-q [--quiet] : print as little as possible
-N [--non-recursive] : operate on single directory only
--auto-props : enable automatic properties
--no-auto-props : disable automatic properties
-m [--message] arg : specify log message ARG
-F [--file] arg : read log message from file ARG
--force-log : force validity of log message source
--editor-cmd arg : use ARG as external editor
--encoding arg : treat value as being in charset encoding ARG
--no-ignore : disregard default and svn:ignore property ignores
--username arg : specify a username ARG
--password arg : specify a password ARG
--no-auth-cache : do not cache authentication tokens
--non-interactive : do no interactive prompting
--config-dir arg : read user configuration files from directory ARG
A standard way of setting a up a project in subversion is to use the following structure:
project
+--- branches
+--- tags
+--- trunk
We'll follow this structure here. First we create a temporary directory to import.
C:\WB>MKDIR temp
C:\WB>cd temp
C:\WB\temp>MKDIR branches tags trunk
C:\WB\temp>cd ..
We now import this structure into the repository. It is good practice to supply a message with each change to the repositiry using the -m option. In many repositories the need to supply a commit message is enforced by the server.
C:\WB>svn import temp file:///C:/WB/server/repos/ -m "Initial set up."
Adding temp\trunk
Adding temp\branches
Adding temp\tags
Committed revision 1.
C:\WB>
We won't be using svnlook much during these walk throughs but the following shows the use of the svnlook youngest command. This is a server side command.
C:\WB>svnlook youngest server\repos
1
C:\WB>
Now that we've imported the temp directory we delete it.
C:\WB>RMDIR /S temp
temp, Are you sure (Y/N)? y
C:\WB>
Client Side
editWorking with Windows
editWe will now check out the trunk from the repository and start working on this.
C:\WB\server>CD ..
C:\WB>MD client
C:\WB>CD client
C:\WB\client>
You can now check out the trunk from the repsitory into yur client working area.
C:\WB>svn co file:///C:/WB/server/repos/trunk client\trunk
Checked out revision 1.
C:\WB>
C:\WB>cd client
C:\WB\client>
C:\WB\client>DIR /A trunk
Volume in drive C is PROGRAMS
Volume Serial Number is 64A5-9C22
Directory of C:\WB\client\trunk
23/02/2009 10:12 <DIR> .
23/02/2009 10:12 <DIR> ..
23/02/2009 10:12 <DIR> .svn
0 File(s) 0 bytes
3 Dir(s) 145,724,104,704 bytes free
C:\WB\client>
It can be seen that there is a .svn directory in the trunk directory.
Next we move into the client trunk directory. Look at the status of the directory and then look at a more detailed status of the directory.
C:\WB\client>CD trunk
C:\WB\client\trunk>svn status
C:\WB\client\trunk>svn status -v
1 1 CozensJ .
You can find out where the directory is versioned using the svn info command.
C:\WB\client\trunk>svn info
Path: .
URL: file:///C:/WB/server/repos/trunk
Repository Root: file:///C:/WB/server/repos
Repository UUID: 81664a5f-b906-8c41-a38a-d61973a1aa89
Revision: 1
Node Kind: directory
Schedule: normal
Last Changed Author: CozensJ
Last Changed Rev: 1
Last Changed Date: 2009-02-23 09:46:43 +0000 (Mon, 23 Feb 2009)
We now continue with the menu example. Open Notepad and create the file "menu.txt".
C:\WB\client\trunk>notepad menu.txt
Checking the status now shows that the menu.txt is an unknown file to subversion.
C:\WB\client\trunk>svn status
? menu.txt
C:\WB\client\trunk>svn add menu.txt
A menu.txt
C:\WB\client\trunk>svn status
A menu.txt
C:\WB\client\trunk>svn staus -v
Unknown command: 'staus'
Type 'svn help' for usage.
C:\WB\client\trunk>svn status -v
1 1 CozensJ .
A 0 ? ? menu.txt
C:\WB\client\trunk>svn diff
Index: menu.txt
===================================================================
C:\WB\client\trunk>svn diff
Index: menu.txt
===================================================================
--- menu.txt (revision 0)
+++ menu.txt (revision 0)
@@ -0,0 +1,11 @@
+[Date]
+Monday 5th January 2009
+
+[Starters]
+Starter of the day.
+
+[Main]
+Dish of the day.
+
+[Desserts]
+Creme Brulee
C:\WB\client\trunk>
Walk Through: Setting Up Subversion and TortoiseSVN
editThis walk through will show you how to set up subversion as a set of command line applications and also how to set up the TortoiseSVN client.
Walk Through: Multiple Workers and Conflicts
editThis walk through will walk you through a single user and then two users using a repository. It will show you how and where different versions of files and directories change. It goes onto show you how conflicts occur and then how to resolve them.
Prerequisites
editYou will need the following installed to run this walk through:
svn - subversion client TortoiseSvn (Optional)
Overview
editThis walk through will go through the following steps:
- Create a new repository.
- Sam (User 1) gets a working copy and commits a few changes.
- Pat (User 2) gets a working copy.
- Sam makes a change and commits.
- Pat makes a change and commits.
- Pat makes a few changes and commits.
- Sam updates his out of date working copy.
- Sam and Pat make some changes and end up with Pat in conflict.
- Pat resolves her conflict.
During the walk through you can look at the changes both using the svn command line tool and using TortoiseSVN.
Walk Through: Subversion Administration
editThis walk through is mainly intended for subversion administrators. This walk through will show you how to create a local repository and access it using the file:// schema. The same method is used to create full blown repository but they are configured to be accessed using different schema such as svn:// and http:// etc.