You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Chris Walquist <cw...@DRWHoldings.com> on 2007/06/28 22:58:17 UTC

Protecting labels in SubVersion

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.

 


RE: Protecting labels in SubVersion

Posted by Shawn Talbert <st...@exploreconsulting.com>.
I think I once made an even simpler script for preventing mods to tagged
project which just prevented anything but (A)adds to any path with "tags" in
it. 

-----Original Message-----
From: Roy Franz [mailto:roy.lists@gmail.com] 
Sent: Friday, June 29, 2007 3:01 PM
To: Chris Walquist
Cc: users@subversion.tigris.org
Subject: Re: Protecting labels in SubVersion

I have also looked around and did not find much that was really
helpful.  I ended up
writing something that works for me, although it probably still has some
holes.

Some things to watch out for:
* paths being deleted from a tag after it is created
* someone deleting the entire 'tags' directory.***
* mixed revision tags may need special handling.

*** This really happened, and although it was trivial to just copy the
tags directory from an earlier revision and recover all the tags, this
is a rather unsatisfactory fix.
This changes the history of the tags, such that log --stop-on-copy now
reports
the copy of the tag directory, not the copy that created the tag.
(This is of course the correct thing for the log command to do.) This
breaks tools such as tksvn that abuse that option to log.  We ended up
doing a dump/load to remove the offending
revisions so that our history would not be screwed up the the extra copy.

Roy

(I'll see if I can get permission to publish the script, although that
could take a while.)


On 6/28/07, Chris Walquist <cw...@drwholdings.com> wrote:
>
>
>
>
> 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.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Protecting labels in SubVersion

Posted by Roy Franz <ro...@gmail.com>.
I have also looked around and did not find much that was really
helpful.  I ended up
writing something that works for me, although it probably still has some holes.

Some things to watch out for:
* paths being deleted from a tag after it is created
* someone deleting the entire 'tags' directory.***
* mixed revision tags may need special handling.

*** This really happened, and although it was trivial to just copy the
tags directory from an earlier revision and recover all the tags, this
is a rather unsatisfactory fix.
This changes the history of the tags, such that log --stop-on-copy now reports
the copy of the tag directory, not the copy that created the tag.
(This is of course the correct thing for the log command to do.) This
breaks tools such as tksvn that abuse that option to log.  We ended up
doing a dump/load to remove the offending
revisions so that our history would not be screwed up the the extra copy.

Roy

(I'll see if I can get permission to publish the script, although that
could take a while.)


On 6/28/07, Chris Walquist <cw...@drwholdings.com> wrote:
>
>
>
>
> 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.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org