Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:svn_tips

Subversion Tips

Apache Server Configuration

  • Uncomment or add the following to /etc/httpd/httpd.conf and restart Apache:
    LoadModule auth_digest_module lib/httpd/modules/mod_auth_digest.so
    LoadModule dav_module lib/httpd/modules/mod_dav.so
    LoadModule dav_svn_module lib/httpd/modules/mod_dav_svn.so
    LoadModule authz_svn_module lib/httpd/modules/mod_authz_svn.so
    
    <Location /svn>
      DAV svn
      SVNParentPath /home/svn
      SVNListParentPath on
      AuthType Digest
      AuthName "Subversion Repositories"
      AuthUserFile /home/svn/.htpasswd
      AuthDigestProvider file
      Require valid-user
    </Location>
  • Create the directiory /home/svn
  • Add one or more users with htdigest
  • Type svnadmin create /home/svn/test to create a repository called test
  • Type chown -R apache:apache /home/svn/*
  • Point your browser to http://localhost/svn to browse the repository/ies

svnserve Server Configuration

This is not necessary if Apache Server (see above) is used!

Required

Server OS is Slackware Linux 11.0. Infos are collected from the svnbook and this site. The easiest alternative for running a svn server is used, i.e. svnserve as daemon. No apache, no SSH is used:

su -
groupadd svn
useradd -g svn -d /home/svn svn
mkdir /home/svn
chown svn:svn /home/svn
su svn
rm /home/svn/.* # delete .bash_history
svnadmin create /home/svn
exit
chmod -R o-rwx /home/svn

Note: The svnserve process ist started as a separate user svn as recommended. This increases security, but seems to prevent local access via file:///home/svn/... urls.

To start svnserve at boot time, append this to /etc/rc.d/rc.local:

su svn -c "/usr/bin/svnserve -d -r /home/svn"

To give users access to the repository, edit /home/svn/conf/svnserv.conf and /home/svn/conf/passwd see Built-in authentication and authorization

Browser Interface Configuration

This is optional. www.viewvc.org is mentioned in svnbook and used. Viewvc requieres Subversion with its SWIG Python bindings. Install swig e.g. from linuxpackages.

The Subversion which comes with Slack 11.0 is compiled witout swig/python support. Therefore download from the Slack source subversion dir, eg form here.

Now the buildscript subversion.SlackBuild has to be patched a bit in order to include the python bindings:

53a54
> make swig-py || exit 1
55a57
> make install-swig-py DESTDIR=$PKG
88a91,93
> mkdir -p $PKG/usr/lib/python2.4/site-packages
> echo "/usr/lib/svn-python" > $PKG/usr/lib/python2.4/site-packages/svn.pth
>

Run the buildscript to create a the package and install the package with upgradepkg –reinstall subversion-1.4.0-i486-1.tgz

Install viewvc by running viewrc-install (described in viewrc-1.0.4/INSTALL)

Edit /usr/local/viewrc-1.0.4/viewrc.conf:

80c80
< #svn_roots = svn: /home/svnrepos
---
> svn_roots = svn: /home/svn
105c105
< default_root = cvs
---
> default_root = svn

Copy (symlinks don't work) /usr/local/viewrc-1.0.4/bin/cgi/*.cgi to /var/www/cgi-bin

Add user nobody (Apache) to group svn in /etc/group to give Apache read permission for the svn repository. Then restart Apache and point your browser to http://server-hostname/cgi-bin/viewvc.cgi/.

Other Administration

Rename a Repostitory

Just use normal mv as root. See also

Locks

View and remove locks:

svnadmin lslocks /local/path/to/repo
svnadmin rmlocks /local/path/to/repo

Clients can remove own and other locks as well. See below!

more

Client Configuration

If you use the provieded command line svn client no config at all is necessary. This is also true if Cygwin is used as environment. Username and password are stored automatically after first login, see client credentials caching.

Client Usage

Commands refere to the SVN command line client which comes with SVN. Snytax for usage of SVN over HTTP is used. If the svnserve protocol is used, just replace http:// with svn://.

Subversion Complete Reference

First Import

Create a project. 3 directories are recommended:

becki@client:~/test$ tree testproj/
testproj/
|-- branches
|-- tags
`-- trunk
    `-- main.c

The import command imports the testproj project to the root dir of the repostitory also as project testproj

becki@client:~/test$ svn import testproj http://<servername>/<svnrootdir>/<reponame>/testproj

Checkout

svn co http://<servername>/<svnrootdir>/<reponame>/testproj

This creates the dir testproj in the current dir and fills it with the content of the project. If you want to have another directory name, just append the alternative name:

svn co http://<servername>/<svnrootdir>/<reponame>/testproj alternativeDirName

Check working copy status

[svn up]
svn st [-u] [-v] [file or dir]
  • -u adds working revision and server out-of-date information
  • -v prints full revision information on every item

The status seems to be always against the current head revision number of the local copy, not of the head of the repository. Therefore it is advisable to run svn update before.

See 1.4/svn.ref.svn.c.status.html

svn info

shows the highest revision of the current working dir.

See history of files, dirs and projects

[svn up]
svn log [-v] [fileOrDir]

The log seems to be always against the current head revision number of the local copy, not of the head of the repository. Therefore it is advisable to run svn update before running log.

FIXME verify: This way, you can always get a complete log o your project by changing into the root dir of the projcet, issuing the update command and then the log command.

Updating working directory

svn up

Brings changes from the head revision of the repository into the current dir and preserves local changes.

svn up -r <refNumber>

Brings the current dir into the state of revision of <refNumber> of the repository (and preserves local changes :?:). svn info reveals the revision of the current working dir.

Move Files and Dirs

svn move <from> <to>

Works just like the shell mv command :-) See 1.4/svn.ref.svn.c.move.html

Give up working copy

According to http://svn.haxx.se/dev/archive-2002-08/1385.shtml there is no command like the release of CVS. Just delete the working copy locally.

Branching

Intro

A branch is created simply by making a copy of the project. SVN knows only how to copy. Copies may have the meaning of branches or tags.

It is recommended to do the copy on the server, not locally. The remote copy also includes the commit in one step. Eg:

svn cp http://url/project/trunk http://url/project/branches/foo -m "Creating a branch for working on feature foo"
svn checkout http://url/project/branches/foo
project
|-- branches
|   `-- foo
|-- tags
`-- trunk

Use Cases

  • Try out a new feature in a separate branch without disturbing the trunk
  • Create a branch from an older revision to make a bug fix
  • FIXME Create client-specific variants of the same main project eg. for special needs of customers

Merging

Intro

Merging (explanation / manpage): Apply the changes between repository tree X and repository tree Y into the working directory. Any revision on any branch is a repository tree.
  • FIXME Verify: Merging is not symmetrical, i.e. if a line was added to a file between rev X and rev Y, than merge X Y will add that line to the file in the working dir and merge Y X will remove that line!
  • Merging can not just happen between branches, but also between older revisions in the same branch
  • Merging does not always need to cover the whole project, it can be restricted to subdirs or single files. See also 1.5/svn.branchmerge.basicmerging.html → selectively “copy” changes
  • Have a clean working directory before merging :!:
  • It is also possible to specify only one repository tree source (e.g. the tunk) with the merge command. In this case, all modifications of the trunk since you first created your branch (which you work on) are applied to the working dir. Used e.g to keep a branch in sync.
  • For merging finishd branches which are to be discontinued and merged back into the trunk, the –reintegrate option is necssary
  • AFAIK it is not possible to easily keep two branches in sync (merge in both directions) like in Mercurial. Basic merging in SVN is meant to frequently update branches from the trunk and finally reintegrate the branch into the trunk. To keep two branches in sync, advanced merging (with manual bookkeeping about what has already been merged) is necessary.

Use Cases

  • Merge a new feature in a separate branch into the trunk
  • Merge bug fixes of an older revision into the trunk
  • FIXME Merge common parts of client-specific branches
  • Undo committed Changes, see below

Undoing Changes

Undoing lokal Changes

See revert

Undoing committed Changes

svn merge [--dry-run] -r 627:480 http://url/project

This command removes all changes which have been done between r480 and r627 in the workin copy. Afterwards a commit is necessary.

See also 1.4/svn.branchmerge.commonuses.html → Undoing Changes

Commit Log Message Correction

Example:

svnadmin setlog /path/to/repository --bypass-hooks logmessage.txt -r 25120

See also: Svnbook

Locks

View locks:

svn st -u
  • O: Lock from someone else
  • K: Own lock

Create and remove locks:

svn lock file
svn unlock file

more → from „Discovering Locks“ on

Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/svn_tips.txt · Zuletzt geändert: 2015-11-04 14:32 von becki

Impressum - Datenschutzerklärung