Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to forbid subversion commits to svn:external to revisions?

We use svn:externals to specific revisions of a library, e.g. like

xyzlib -r12345 https://asdf.asdf.local/xyzlib/trunk/

When you make a modification in your working copy to such a checked out external, it is possible to commit even though the external links to a specific revision and not the HEAD.

When you run svn update after the commit, the changes will be gone in the working copy because subversion reverts everything back to the revision 12345. So you never really see the changes yourself but they still are in the HEAD, which is bad.

Is it possible to forbid commits only when the external does not point to the HEAD revision?

like image 563
martinus Avatar asked Jun 16 '09 13:06

martinus


2 Answers

For these kinds of validations I would also recommend a pre-commit hook, but instead of writing a script which can easily turn out to be impossible to understand I recommend using a library like SVNKit - http://svnkit.com/ (if you know Java).

I've written a few pre-commit hooks myself using this library and it is quite easy to work with. You write a small runnable Java program which is called from the pre-commit hook by Subversion. Then it is easy to extract e.g. properties or parts of the URL to do the validation and reject the commit if it doesn't apply to your "rules".

Take a look at the SVNLookClient and SVNChangeEntry classes - they have methods for the most common cases (e.g. extracting info about a commit in progress.)

like image 135
Erik Finnman Avatar answered Nov 12 '22 06:11

Erik Finnman


You could try something like this: use a pre-commit script to check if the commit is going to a tag. If so, then fail out and provide a message. Read some more about subversion hooks. You'll have to re-write the regex so that it fails out if its not HEAD rather than failing if is a tag.

$SVNLOOK changed -t “$TXN” “$REPOS” | egrep -v “^[AD][[:space:]]+(.*/)?tags/[^/]+/$” | egrep “^[^[:space:]]+[[:space:]]+tags/[^/]+/.+”
if [ $? -eq 0 ] ; then
echo >&2 “***************************************”
echo >&2 “* Modification of tags is not allowed *”
echo >&2 “***************************************”
exit 1
fi
like image 32
nont Avatar answered Nov 12 '22 07:11

nont