Eli : Memcached, MySQL, Highcharts

Tag - svnsync

Thursday, September 23 2010

Solving the revprop change blocked by pre-revprop-change hook (exit code 255) with no output error

What is the pre-revprop-change hook ?

The pre-revprop-change script is launched before any property is modified on the Subversion repository.

Because Subversion's revision properties are not versioned, making modifications will overwrite the previous value of that property and since data can be lost, Subversion supplies this hook to log changes or enable only some properties to be changed, ...

revprop change blocked by pre-revprop-change hook (exit code 255) with no output is a common error when playing with revision properties that can be solved in two simple steps.

Check the pre-revprop-change hook existence

By default, there only a template hook named pre-revprop-change.tmpl in the repository hooks folder.
You need a pre-revprop-change file, so you can rename it to only enable svn:log and svn:author (Commit log message & author) :

mv hooks/pre-revprop-change.tmpl hooks/pre-revprop-change

Or make your own hook to enable all properties to be changed :

vi hooks/pre-revprop-change

then insert

#!/bin/sh 
exit 0;

The exit 0; instruction is equivalent to a success for svn, so this one will allow EVERY revision properties on repository to be changed (Useful for svnsync).

Give the execution right to pre-revprop-change hook

It's a common mistake to forget enabling execution right to the hook

chmod +x hooks/pre-revprop-change

This is the second step, you are now able to change revision properties on your repository.

(exit code 1)

In case you obtain revprop change blocked by pre-revprop-change hook (exit code 1), this mean that pre-revprop-change hook is enabled, executable, but it does not allow you to modify the revision property you're trying to change.

Check the message it return (unless with no output is specified), check the hook code, if you can't or are not allowed to do theses things, check repository hosting documentation or contact your repository administrator.

Wednesday, May 12 2010

Using svnsync to mirror a google code repository

Why use svnsync, there already a repository !

All our websites are put into production using subversion (But not directly, first we update an hidden working copy, then rsync it on filer).

We use minify and log4php with svn:externals and want to keep it versionned to easily switch to new release but don't want to be dependent on code.google.com or apache.org repositories, that sometime goes into 502 or 503, to put new releases in production.

code.google.com or apache.org permit us to use svnsync, let's see how to easily use it. Note that you can use Google Code repository as a mirror and have your master repository on your server (in case you own the project), but keep in mind that wiki is also in project repository, so front end modification on wiki will alter your mirror repository, and break the sync.


Create the mirror repository

svnadmin create /repos/minify

At work, subversion is on an "open bar" mode, no user authentication required at all, we've got a general user, and a svn superuser, no use of username or sync-username.

Let's make the svn superuser the only able to commit and edit properties on the mirror repository, the mirror must be read-only for any method other than 'svnsync'.

To do that we must enable revision property changes and commit to the dedicated server account on the mirror repository.

Enable the pre-revprop-change hook

vi minify/hooks/pre-revprop-change

then insert

#!/bin/sh 
USER="$3"
if [ "$USER" = "svnroot" ]; then exit 0; fi
echo "Only the svnroot user may change revision properties" >&2
exit 1

if you don't want to use a specific user, simply leave the svn pre-revprop-change hook empty.

#!/bin/sh


Enable the start-commit hook

vi minify/hooks/start-commit

then insert

#!/bin/sh 
USER="$2"
if [ "$USER" = "svnroot" ]; then exit 0; fi
echo "Only the svnroot user may commit new revisions" >&2
exit 1

if you don't want to use a specific user, simply leave the svn start-commit hook empty

#!/bin/sh

As you see, it's not 100% secure, it's only to prevent mistakes.

Give the execution right to both svn hooks

Otherwise you'll have a message like blocked by pre-revprop-change hook (exit code 255) with no output.

chmod +x minify/hooks/start-commit
chmod +x minify/hooks/pre-revprop-change


Init the synchronisation

We use svn over ssh, you can also use svn://, http:// whatever protocol you use usually.

Command usage is `svnsync init DEST_URL SOURCE_URL`

svnsync init svn+ssh://svnroot@svnserver.local/repos/minify http://minify.googlecode.com/svn

If everything is ok you'll see

Copied properties for revision 0.

You can check mirror repository by using command

svn proplist --revprop -r 0 -v svn+ssh://svnroot@svnserver.local/repos/minify
Unversioned properties on revision 0:
  svn:sync-from-uuid : c230a260-702f-0410-900f-efd535441baf
  svn:sync-last-merged-rev : 412
  svn:date : 2007-05-01T22:46:50.958069Z
  svn:sync-from-url : http://minify.googlecode.com/svn

svn:sync-last-merged-rev and svn:sync-from-url are ok


Synchronize the repository

Command usage is `svnsync sync DEST_URL`

svnsync sync svn+ssh://svnroot@svnserver.local/repos/minify

Every revision and properties from source repository will be mirrored.

Committed revision 1.
Copied properties for revision 1.
Transmitting file data ..
Committed revision 2.
Copied properties for revision 2.
Transmitting file data .

This could be long, very long, apache.org repository has more than 960 000 revisions, and svnsync must read each one.

If you want, you can stop the sync process, but you will have a sync-lock error message like :

Copied properties for revision 625.
Killed by signal 2.
svnsync: Caught signal
svnsync sync svn+ssh://svnroot@svnserver.local/repos/log4php
Failed to get lock on destination repos, currently held by 'svnserver.local:16655307-acde-47f1-b392-15e547cc99e1'
Failed to get lock on destination repos, currently held by 'svnserver.local:16655307-acde-47f1-b392-15e547cc99e1'

Execute this command to be able to resume the sync process

svn propdel svn:sync-lock --revprop -r 0  svn+ssh://svnroot@svnserver.local/repos/log4php


Use & update of the mirror

Now you can checkout and update from the mirror repository without dependence to original repository or network, remember no commit or properties change on the repository only svnsync.

Make manual svnsync or cron to keep the repository up to date.

Resources

http://svn.apache.org/repos/asf/subversion/trunk/notes/svnsync.txt