Wednesday, July 14, 2004

HOW-TO: Subversion on Windows

Spent a week trying out Subversion, as a replacement for Starteam which (in our old version) doesn't support branching.

Summary: Subversion works well on Windows. TortoiseSVN is OK but the integration within File Explorer is a bit disconcerting since it lets you check-in to any trunk or branch. I would prefer a 'Set current svn URL' feature.

Setting up the subversion server
I used svnserve (their daemon) instead of Apache, because (a) our needs are simple, and (b) svnserve is a bit faster.

1. Downloaded svn1.0.5-setup.exe from Download firedaemon (the Lite version which is free). Have it run c:\program files\subversion\bin\svnserve.exe -d -r c:\svn. This runs svnserve as a service so it gets loaded automatically at boot time and no one can close it by mistake.

2. download Tortoise SVN?-1.0.6-UNICODE_svn-1.0.4.msi. We use ASP.NET and there's a problem with tsvn's use of ".svn" directory names. The modified version
of tsvn that we downloaded uses "_svn".

3. Create a directory to keep your repositories (c:\svn\products). We chose one big repository for all our product source code (2 products, 3 versions of each) because this
makes porting changes between versions straightforward.

* create c:\svn\products
* svnadmin create \svn\products
* edit the .conf files in products\conf for authentication
see 3.2.4 in Tortoise SVN? manual

basically change the conf/svnserve.conf file to have

anon-access = none
auth-access = write
password-db = password.conf

This requires people to type a login. You need to create the password.conf file in the same dir.

No need to restart svnserve.exe when you change this file.


* create c:\layout and under it create sub-directories for both products vbvoice and vbsalt.
vbvoice \ trunk
\ branches
\ tags
vbsalt \ trunk
\ branches
\ tags
* copy a full set of files from s: to vbvoice\trunk.
* tsvn right-click on c:\layout and do Import to '''svn://localhost/svn/products'''
* now you can

Additional projects such as Installs or Builds should be their own repository created with svnadmin create. Each repository should get its own dir under c:\svn. These should be checked-out if possible to somewhere else than S: on dev machines to avoid mixups. But multiple repos in S: works (see SubversionTips)

Ignoring Files & Directories
Directories: tsvn Add To Ignore List . This add svn:ignore property in the parent directory. For directories at the root of S:, you can't see the TSVN property dialog, so view the unmapped dir that you SUBST'd, eg. D:\source52. You can clear the ignore on this dialog.

Registry has a system-wide global-ignore list of extensions and files to ignore. HKEY_CURRENT_USER\Software\\Subversion\Config\miscellany But this is set via the TSN Settings dialog box.

There is also a config file and auth logins saved at C:\Documents and Settings\Ian Rae?\Application Data\Subversion

Development Machine setup
* install svn + tsvn
* create a directory structure like c:\layout above but call it d:\source. Do it on the drive where you keep your data files (such as d:)
* map S: to d:\source\trunk
* view S: in file explorer
* tsvn right-click and do check-out from '''svn://raidbuild/products/vbvoice/trunk'''

Files To Check In
tsvn Commit+cancel is fastest (doesn't contact repos). tsvn Check for Updates is good but chokes on "in-use" files. icon overlays helpful but may be slow.

Files To Check Out
tsvn Check for Updates. Remote status will be 'modified' or 'added' for all files to check out.

Files Not In Project
tsvn Add (use Add To Ignore list on directories, such as IntermediateFiles that you don't want to add to the project).
or tsvn Commit+cancel and check the 'show unversioned files'. However the checkbox is sticky and it may show all sorts of other files unless you configure the ignore lists.

Files In Project
just look in File Explorer (icon). Or use Repo-browser.
Update (getting latest code from repository to your source tree
Commit first then Update. Resolve conflicts

create file & dir
tsvn Add and later Commit

create branch, merge branch
tsvn Branch/Tag... and type '''svn://svn/products/vbvoice/branches/rel5.2'''
now remap S: to a new branch dir, such as d:/source/products/vbvoice/branches/rel5.2
tsvn right-click on S:\ and Checkout the rel5.2 branch.
''svn remembers what trunk or branch your files are at, so you can always do Commit/cancel to see, either on S: or the actual directory'' S: has the branch code, make your changes, commit...

merge branch
Once you final branch changes haved been checked-in, do the following:
1. write down the revision # of your final branch commit. (or just do Update which shows you the current branch revision number)
2. Subst S: back to the trunk version
3. Do TSVN right-click '''Merge''' and enter the branch URL and it's creation revision (usually labelled "copy" or the reversion after the last merged revision (see SubversionSampleBranchAndMerge)). If its not the first time you've merged from this branch then you need to enter the revision ''before'' the first new revision that hasn't yet been merged. For example, if you have branch revisions as shown below, then you need to enter "10" in the Merge dialog box since you merging ''everything changed since revision 10''.
14 my latest fixes
10 last weeks fixes

4. resolve any conflicts (the Merge log window will say "conflict" for each conflicted file). tsvn Edit Conflicts. then tsvn Resolved to clean up tmp files.
5. '''Commit''' the changes done by '''Merge'''. BE SURE to include branch revision numbers (from steps 1 and 3 above) in the Commit log message. eg. "merged bran2 r11-14 agentx changes".