Difference between revisions of "Svn notes"
(→Creating a basic SVN repository) |
(→Integration with TRAC) |
||
(One intermediate revision by the same user not shown) | |||
Line 16: | Line 16: | ||
== Server preliminaries == |
== Server preliminaries == |
||
It might be a good idea to create a "subversion" group and add www-data as a user to it. |
It might be a good idea to create a "subversion" group and add yourself (the svn client user) and www-data as a user to it. |
||
sudo addgroup subversion |
sudo addgroup subversion |
||
Line 105: | Line 105: | ||
MSG=$(svnlook log -r $REV /var/svn/myproj) |
MSG=$(svnlook log -r $REV /var/svn/myproj) |
||
/usr/bin/python /usr/local/bin/trac-post-commit-hook -p "$TRAC_ENV" -r "$REV" -m $MSG |
/usr/bin/python /usr/local/bin/trac-post-commit-hook -p "$TRAC_ENV" -r "$REV" -m $MSG |
||
== Remove all .svn directories == |
|||
Like this: |
|||
rm -rf `find . -type d -name .svn` |
Latest revision as of 22:55, 18 August 2011
A good start for basic subversion info is at https://help.ubuntu.com/community/Subversion
You may also want to read how to add a group or user to a group.
SVN client (GUIs)
Here is the list of my favorite clients for SVN
- Rapidsvn for version control and meld for comparing files
sudo apt-get install rapidsvn meld
- RabbitVCS - inspired by TortoiseSvn, but for Linux. However, if you have large or several repositories checked out in a directory that you are trying to open in nautilus, the latter may hang for a long time while the Rabbit goes through all the subdirectories.
- For windows use TortoiseSVN. There is a nice FAQ for TortioseSVN with ssh.
Server preliminaries
It might be a good idea to create a "subversion" group and add yourself (the svn client user) and www-data as a user to it.
sudo addgroup subversion sudo usermod -a -G subversion www-data
Creating a basic SVN repository
Decide where your repository will be. Private could be under your home, public probably be somewhere else, e.g. at /var/lib/svn/ourproject/. This example creates a repository in /home/svn/myproject/.
sudo mkdir /home/svn cd /home/svn sudo mkdir myproject sudo svnadmin create /home/svn/myproject cd /home/svn sudo chown -R www-data:subversion myproject sudo chmod -R g+rws myproject
Global ignore
- Where to set the pattern for files to be ignored:
You can modify /etc/subversion/config like this
[miscellany] global-ignores = *.class *.o tmp
- How to use a different username for a svn client (for example, rapidsvn)
SVN_SSH='ssh -l username' rapidsvn
Single unix account, multiple user access with public key authorization
Setup
Here is a description on how to set up svn on a single unix account and using private-public key authorization for multiple users.
In short: edit .ssh/authorized_keys file by adding lines as follows:
Consider
ssh-rsa AAAABlotsmoregookhere= address@example.com
as "TYPE KEY COMMENT". Then add the following lines, one prer user:
command="/path/to/svnserve -t -r /repository/root --tunnel-user=alice",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty TYPE1 KEY1 COMMENT1 command="/path/to/svnserve -t -r /repository/root --tunnel-user=bob",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty TYPE2 KEY2 COMMENT2
Now you can have users authenticating the svn access with their private/public keys, using a single svn/unix account.
If you do not know how to generate the keys, here is how: Ssh_with_a_private-public_key
Access
Suppose you have created the svn account under the user svnuser, and the repository is stored on the server example.com at /home/svnuser/svn/the-project.
Suppose John wants to access the svn and has given his public key so that it is defined in the .ssh/authorized_keys file as follows:
command="/usr/bin/svnserve -t -r /svn/the-project --tunnel-user=John",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAABlotsmoregookhere= address@example.com
Then John can check out the repository from virtually any Linux account as follows:
SVN_SSH="ssh -l svnuser" svn co svn+ssh://example.com
This is rather long typing, so I suggest you set up an alias in your .bashrc or wherever:
alias mysvn='SVN_SSH="ssh -l svnuser" '
and use it like this:
mysvn svn co svn+ssh://example.com myproj ...checks out the repository the first time cd myproj gedit myfile1 ...create and edit a new file svn add myfile1 ...mark it to be added to the repository mysvn svn ci ...check in the new file and any modifications mysvn svn up ...update your working copy from the svn, in case someone else has done some changes. mysvn rapidsvn ...fire up an IDE for the svn project
Access from Windows
You can access the repository from windows as well. For example, using putty key agent and tortoiseSVN. Note that you need to specify the svn repository path with the proper username, e.g. svnuser as in the example above.
Integration with TRAC
You can make TRAC close messages when committing in svn by mentioning the ticket number like "This fixes #17". You will need to find (and install) the appropriate trac-post-commit-hook script for your TRAC version. Here is an example of the /var/svn/myproj/hooks/post-commit file:
#!/bin/sh REPOS="$1" REV="$2" TRAC_ENV="/var/trac/mytrac" MSG=$(svnlook log -r $REV /var/svn/myproj) /usr/bin/python /usr/local/bin/trac-post-commit-hook -p "$TRAC_ENV" -r "$REV" -m $MSG
Remove all .svn directories
Like this:
rm -rf `find . -type d -name .svn`