Notes on using Subversion

Setting up the domain-specific repository

Each domain needs to set up a repository for domain-specific and private information. For Subversion, the following example shows how to set up a repository accessible via Apache. It would need to be filled in and placed in httpd.conf:


    DAV svn
    SVNPath /path/to/repo
    AuthzSVNAccessFile /path/to/svn-access-file
    Require valid-user
    AuthType Basic
    AuthName "Domain-specific and private information"
    AuthUserFile /path/to/svn-auth-file        

The following is an example svn-access-file:

[groups]
oscars_developers = chin, davidr
oscars_user = oscars

[esnet:/]
@oscars_developers = rw
@oscars_user = r

For ESnet, esnet is the name of the repository. It has the following file structure:

esnet
    domain
        branches
        tags
        trunk
            client
            server

The files in client and server are copied over from the oscars repository from conf/examples and filled in with domain-specific values.

The domain directory was inserted in the path to have a string that will appear in all paths, used in setting up the Subversion post-commit hook. Following is the post-commit hook used for ESnet (note that the svnnotify setup is actually all one line):

#!/bin/sh

REPOS="$1"
REV="$2"

/usr/local/bin/svnnotify -r $REV -C -d -H HTML::ColorDiff -p $REPOS \ 
    --subject-prefix OSCARS_ESnet_Commit: --to-regex-map 'dwrobertson@lbl.gov \
    chin@es.net'=\^domain --reply-to dwrobertson@lbl.gov \
    --svnlook=/usr/local/bin/svnlook > /tmp/xxx-svnlog 2>&1
echo $1 >> /tmp/xxx-svnlog
echo $2 >> /tmp/xxx-svnlog

Merging revisions from a branch into the trunk

You may want to merge all the changes on the branch or just the changes within a single directory. There does not seem to be a way to just merge a single file.

1. Make sure you have a clean copy of the trunk, or at least the directory in which your changes reside.

    % cd  or subdirectory
    % svn status

should show nothing. e.g no .

2. Check when the last revision to the trunk/directory was made:

   % svn info

returns trunkrevnumber as "Last Changed Rev".

3. The svn merge command we are using is

    % svn merge sourceURL1[@N] sourceURL2[@M] [WCPATH]

The source URLs are specified at revisions N and M. These are the two sources to be compared. The differences are merged into the WCPATH which is your trunk working directory and defaults to ".". The revisions default to HEAD if omitted. In our examples the M defaults to the HEAD.

3a. For example, to merge the entire branch:

    % svn merge https://oscars.es.net/repos/oscars/branches/java/@4691 \
                https://oscars.es.net/repos/oscars/branches/java/

3b. To merge just the files in the docs directory:

    % cd docs
    % svn merge https://oscars.es.net/repos/oscars/branches/java/docs/@4691 \
                https://oscars.es.net/repos/oscars/branches/java/docs/

4. For complicated merges, do a dry run, and save the resulting list. It may be long and you may need it to find conflicts.

    % svn merge --dry-run https://oscars.es.net/repos/oscars/branches/java/@4691 \
            https://oscars.es.net/repos/oscars/branches/java/ > ~/svn.list

5. To do the actual merge from the branch (in this case branches/java) to your working directory:

    % svn merge https://oscars.es.net/repos/oscars/branches/java/@4691 \
                https://oscars.es.net/repos/oscars/branches/java/

Note that no changes have been made to the repository yet.

6. Check for any conflicts, these will be marked by a 'C' before the filename. In this example, validator.js has a conflict that we will have to manually resolve:

    U    web/index.html
    C    web/js/validator.js

After resolving this conflict do:

    % svn resolved web/js/validator.js

Then, test with a deploy of the aar and war files on the server.

7. Commit the changes in the working copy of the trunk:

    % svn commit