Subversion

From Wiki
Revision as of 18:41, 4 February 2011 by Scott (talk | contribs) (Setting up a svnserve Server)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

References

http://subversion.tigris.org/

http://svnbook.red-bean.com/

Also this book on Safari: Subversion Version Control: Using The Subversion Version Control System in Development Projects By William Nagel

Setting up Subversion

Create a repository:

svnadmin create /data/svn
or
svnadmin create --fs-type fsfs /path/to/repository

Import a directory to the repository:

cd /usr/local/pkg
svn import --message "Initial import" analyze file:///data/svn/analyze

Setting up an svnserve Server

  • Create a svn system user
useradd -r -c "subversion privilege-separation user" svn
  • Create a repository directory and give to to the svn user:
mkdir /u1/svn
chmod 700 /u1/svn
svnadmin create /u1/svn/erp
chown -R svn.svn /u1/svn
  • Set up repository access control. In repository/conf/svnserve.conf:
[general]
anon-access = none
password-db = passwd
realm = ERP
  • Create user/password pairs in repository/passwd:
[users]
barney = pw4BfranK
  • Hide passwd file from others:
chmod go-r passwd
  • Add these lines to /etc/services:
svn             3690/tcp                        # Subversion
svn             3690/udp                        # Subversion
  • Create file /etc/xinetd.d/svn:
# default: on
# Subversion server

service svn
{
        socket_type     = stream
        protocol        = tcp
        user            = svn
        wait            = no
        disable         = no
        server          = /usr/local/bin/svnserve
        server_args     = -i -r /u1/svn
        port            = 3690
}
  • Restart xinetd:
/etc/init.d/xinetd restart
  • Verify that svn is listening:
netstat -anp | grep LISTEN | grep 3690
  • Make sure that users can get to port 3690 through the firewall.

Administration

Show pending transactions for the erp repository which happens to be in the current directory:

svnadmin lstxns erp

Find out more about a particular transaction:

svnlook info erp --transaction 8-1

Using the svn command

Check out a project:

svn checkout file:///data/svn/analyze

(This creates a local copy of the analyze directory)

Check out a project and give the local copy a different name:

svn checkout file:///data/svn/analyze local_analyze

Check out part of a project:

svn checkout file:///data/svn/analyze/src/pfile_header

Add a file or directory to the project:

svn add pfileheader

Remove a file or directory from the project:

svn delete pfileheader

Check status of the project:

svn status

See logs for a file

svn log pfile_header.c

Update the local project from the repository:

svn update

Commit changes:

svn commit --message "made a change"

If you made changes to a file or directory but want to abandon them:

svn revert pfile_header.c

To revert to an earlier revision:

svn revert --revision 34 pfile_header.c

To copy/move a file:

svn copy pfile_header.c pfile_header.c.orig
svn move release_notes.txt change_log.txt

To undelete a file from an earlier revision:

svn copy --revision 34 pfile_header.c pfile_header.c.orig

To get detailed info about a file:

svn info pfile_header.c

See changes between current copy and repository copy of a file:

svn diff pfile_header.c

See changes between two specific revisions of a file:

svn diff --revision 3:4 pfile_header.c

See who is responsible for each line of a text file:

svn blame pfile_header.c

See what's in a particular directory of the repository without checking it out:

svn list file:///data/svn/analyze/src/pfile_header

Read a particular file from the repository without checking it out:

svn cat file:///data/svn/analyze/src/pfile_header/pfile_header.c | more


Troubleshooting

svn list file:///u1/svn/mri
svn: Unable to open an ra_local session to URL
svn: Unable to open repository 'file:///u1/svn/mri'
svn: Can't open file '/u1/svn/mri/format': Permission denied

This doesn't seem to work from the svn server, but it does work from a remote machine.