WaZaRWiki : SVNTips

GaelReignier :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register :: Hosted by: eNiX
ITTips

Backup all your SVN repositories

for i in `ls -1 /data/svn/`;do svnadmin dump /data/svn/$i|bzip2 >/root/svndump/svn.$i.dump.bz2; done;


Load SVN repo from dump


svnadmin create /repository/repo
svnadmin load /repository/repo < /tmp/repo.dump


To send an email for each commit


Go into your repository folder into your svn server then:

cd /data/svn/repository/hooks # replace the path by your actual path on your server
mv post-commit.tmpl post-commit
vim post-commit


Update the file in the hook folder as followed:
REPOS="$1"
REV="$2"
AUTHOR=`/usr/bin/svnlook author /data/svn/version2`
RECIP=svn.recipients@xyz.com
FROM=$AUTHOR@svn.xyz.com
SUBJ="SVN COMMIT $REPOS"

/usr/bin/svnnotify -p"$REPOS" -r"$REV" -t$RECIP -f$FROM -Dsvn.xyz.com -P"$SUBJ" -C -d --handler HTML::ColorDiff


Good guide here
That is the reference for SVN!


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

Set up subversion client on severs

We faced an issue as per this explanation:
The full error message is:
This client is too old to work with working copy '.'; please get a newer Subversion client.

You will get this error message once you have used a Subversion client linked with a higher Subversion version, and then try to 
execute a command with a Subversion client linked with an older version, e.g., you used an 1.4.x client on your working copy, 
and now you try an svn 1.3.x client on the same working copy.

The reason for this is that Subversion 1.4 and 1.5 upgrade the working copies transparently on every command. But once the working 
copy format is upgraded, older clients can't access the working copy anymore because they don't know the new format.


So we need the same subversion version for our windows and Linux client.

To do so, we need to use RPM from sourceforge. On some servers, we have set up repository priorities. So we need to give a higher priority to the repository from sourceforge than from CentOS. To do so, we need to update the following file:

/etc/yum.repos.d/CentOS-Base.repo
/etc/yum.repos.d/rpmforge.repo

And look for the line priority=XX.
Once it is located, in the file CentOS-Base.repo you have to give an higher value than the one in rpmforge. So that the rpmforge repository will take priority over the CentOS one.
Once the installation is done, please revert your change - using svn if the file is svn'ed.

General SVN workflow
http://svnbook.red-bean.com/en/1.4/svn.tour.cycle.html

SVN file evolution
http://svnbook.red-bean.com/en/1.4/svn.tour.history.html

Checking Out

Check out trunk of V2 into your current working directory:

svn checkout http://svn.xyz.com/version2/trunk


Check out branch 'searchresults' of V2 into your current working directory:

svn checkout http://svn.xyz.com/version2/branches/searchresults

Info About Current Working Directory

svn info

This should give a list of results as follows:

Path: .
URL: http://svn.xyz.com/version2/branches/searchresults
Repository UUID: cc772aa9-b311-0410-add0-e3369e114bd9
Revision: 233
Node Kind: directory
Schedule: normal
Last Changed Author: rhiad
Last Changed Rev: 228
Last Changed Date: 2006-05-17 15:16:25 +0100 (Wed, 17 May 2006)

The above tells us that we are pointing to the 'searchresults' branch.


Switching Between Branches/Trunk

If you need to change to another branch/trunk use svn switch. Example below would switch to point to trunk:

svn switch http://svn.xyz.com/version2/trunk

'N.B. svn switch does an svn update from the branch/trunk you are switching to straight away, and will most often overwright your changes to the current working directory - if in doubt make a copy of your working directory BEFORE you svn switch.'


Updating

svn update

This will then give us a list of files that have been added/deleted/updated/merged like so:

M htdocs/includes/main.php
C htdocs/includes/letarchive_searches.php
A htdocs/includes/section_qs.php
D htdocs/includes/vars.php
G htdocs/includes/miniboxes_weather.php

When the update is finished it will go back to the prompt.

The following are what the letters next to the files mean:
A - Added
D - Deleted
U - Updated
M - Merged
G - Merged (using different methods)
C - Conflict

The only one we should really worry about is 'C' for conflict - however, it's worth looking through the list anyway to ensure it's done things right!

Next we Sort out any conflicts...

SVN deals with conflicts by creating four versions of the file e.g. for file main.php it would create:
main.php - a copy of the original file with the conflicts inline in the usual manner
main.php.mine - the working copy of the file
main.php.r212 - a copy of the file at revision 212
main.php.r213 - a copy of the file at revision 213

The above files will basically give you several ways of understanding the changes so you can manually edit main.php to include all necessary changes.

Once you have finished editting main.php, delete the other three conflict files (main.php.mine, main.php.r212, main.php.r213).

Do the same with all other conflicted files - confer with other members of the team if you aren't sure what versions of the file(s) to keep/delete.


Status Of Working Directory

svn status

This will give a list of files similar to svn update. If there are any ? question marks these are files that exist in the working directory that do not exist in the svn repository i.e. you need to svn add them (or just delete them if no longer needed).


Commiting Changes

'N.B. If you are making changes to a branch, ensure that you speak to the other members of the team BEFORE you commit any of these changes to trunk!'

First ensure that you are in the correct branch by using svn info.

Once you are pointing to the correct branch/trunk, do an svn update.

Next do an svn status to ensure you have added/deleted all files correctly using svn.

Once you have done all this you are ready to commit:

svn commit

Or to commit specific files:

svn commit htdocs/foo.php htdocs/includes/main.php htdocs/index.php

This will bring up an editor to allow you to comment the commit - do so and exit the editor saving changes and svn will commit the changes giving a list of the files being saved.


Differences

To see a list of changes from the working copy to the current revision that your working copy points to (see svn info):

svn diff

To see differences between revision 212 and 213 of trunk:

svn diff -r 212:213 http://svn.xyz.com/version2/trunk


To see differences between branch 'searchresults' and trunk:

svn diff http://svn.xyz.com/version2/trunk http://svn.xyz.com/version2/branches/searchresults


To see a list of changed files, but not the changes themselves:

svn diff http://svn.xyz.com/version2/trunk http://svn.xyz.com/version2/branches/searchresults | diffstat

To view diffs in colour - much easier to read - pipe the command to 'colordiff' so:

svn diff | colordiff

or

svn diff -r 212:213 http://svn.xyz.com/version2/trunk | colordiff

or... etc etc etc

To view a diff of different versions of different branches use the '@' symbol followed by the version number after the URL:

svn diff http://svn.xyz.com/version2/branches/RB-1.2@861 http://svn.xyz.com/version2/branches/RB-1.2@890


Merging Branches To Trunk And Vice Versa

First commit your changes to your branch (see above).

Then do the following command to find out the revision number you branched at:

svn log --stop-on-copy http://svn.xyz.com/version2/branches/searchresults

This will give a list of changes made to the branch, the bottom item is the one we want:


r213 | aphillipo | 2006-05-16 11:32:23 +0100 (Tue, 16 May 2006) | 2 lines

Copied Rev205 for rhiad



This tells us that branch 'searchresults' was branched at revision 213.

Next checkout a new up to date copy of the 'TRUNK' repository 'INTO A NEW FOLDER' - not your working directory(!!!):

cd ../
mkdir new_trunk
cd new_trunk
svn checkout http://svn.xyz.com/version2/trunk
cd trunk

Then merge the changes from your branch repository to the new copy of trunk using revision 213 as the common revision to start the merge from:

svn merge -r 213:HEAD http://svn.xyz.com/version2/branches/searchresults

Next resolve any conflicts.

You can now do either of two things:

- You can commit the up to date merged version of trunk/your branch to trunk (AS ALWAYS, CONSULT WITH THE TEAM BEFORE YOU DO THIS).

- You can delete all the '.svn' folders/files in the merged directory and copy the changes over the top of your working directory of the branch you are working off. This ensures you have all your changes and everyone elses changes in your branch - making it easier to merge later.


Undoing A Dodgy Commit

svn merge -r[current version #]:[old version #] http://svn.xyz.com/version2/branches/searchresults

Do the above and then commit to your branch/trunk.



Editing A Commit Message

svn propedit svn:log --revprop -r[version #] http://svn.xyz.com/version2/branches/searchresults

Do the above if you wish to edit a commit message after you have commited.


Creating a new repository

Log as root then:
# sudo -u www-data svnadmin create /data/svn/test


Creating the associated base structure
Here we will create the trunk, tag and branch folders.

# svn mkdir -m 'layout creation for xyz repository' http://svn.xyz.com/symfony/trunk http://svn.xyz.com/symfony/tags http://svn.xyz.com/symfony/branches


Email notification - Send emails on commits

The template you're looking for is:

/data/svn/<REPO_NAME>/hooks/post-commit.tmpl

Save the hook without the .tmpl and you're off!

There are options to specify the to:, from:, and subject: of the notifications. If you need details, send me a PM.


Creating a new branch

Log as you username, then go to the folder holding the files which are under the version control and in the directory where you need to create the new branch

Then issue the command:
$svn mkdir myNewBranch # This will create the new folder, considered as a new branch
$svn commit # This will sync your changes with the repository


Deleting a repository
Assuming you want to get rid of it forever, no turning back:
Repo location: root@office:/data/svn/test#
root@office:~#rm -r /data/svn/test 

Its just a matter of deleting the berkley database that contains it.

Renaming a repository
The solution: svnadmin create, svnadmin dump & svnadmin load

sudo -u www-data svnadmin create /data/svn/test
sudo -u www-data svnadmin dump /the/path/to/old/repository/<old-repo-name> > old-repo.dump
sudo -u www-data svnadmin load /data/svn/test < old-repo.dump

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0898 seconds