[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Protecting labels in SubVersion

From: Chris Walquist <cwalquist_at_DRWHoldings.com>
Date: 2007-06-29 00:58:17 CEST

Hi,

 

I've looked around a fair bit today for svn hooks that protect labels,
but was unsuccessful. Any pointers to already-written label-guarding
hooks? Below is the dead-simple pre-commit one that I wrote, which
nevertheless will help me sleep easier tonight.

 

Thanks!

-chris walquist

chris@walquist.com

 

#!/usr/bin/env perl

 

use strict;

 

my $SVNLOOK = '/usr/bin/svnlook';

 

my($REPOS,$TXN) = @ARGV;

 

my $logfile = "/tmp/pre-commit.log";

open(LOG, ">>$logfile") or die "Couldn't open log $logfile for append";

 

print LOG '-'x80 . "\n" . `date`;

 

my $cmd = "$SVNLOOK changed --copy-info -t \"$TXN\" \"$REPOS\" ";

print LOG "Running cmd '$cmd'...\n";

my @output = `$cmd` or die "Couldn't execute $cmd";

print LOG @output;

 

if (!grep(m:\(from :, @output)) { # Allow copies to /tags/ to go
thru

        if (grep(m:/tags/:, @output)) {

                my $msg = "***** No changes allowed to existing labels
(i.e., paths with \"/tags/\"); see your friendly SCC admin *****\n";

                print LOG $msg;

                die $msg;

        }

}

 

close LOG;

 

exit 0; # All checks passed, so allow the commit.

 
Received on Fri Jun 29 14:23:02 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.