Hi all,
I realize what I'm about to ask for pretty much flies in the face of all that SVN stands for, so let me give you some backstory first.
I am part of an aerospace club at my university that is being run much like a real aerospace company, complete with full revision control and such. Configuration management is extremely strict, which is not what SVN was built for of course. I was tasked with switching us from a non-existent revision control system to SVN.
When I say extremely strict, here's what I mean:
-Commits must be approved by an admin before SVN can allow it - this means getting paperwork filled out and signed by a member of a dedicated config management team member
-All changelogs must be non-empty.
I'm pretty decent with Perl, so both wasn't so difficult. Essentially, admins run a script that generates an approval code, and emails to the admin and the committer are sent out with that approval code. The approval code is stored along with admin information in a .CSV file that cannot be accessed by non-admins (only admins have ssh capability to the server). This approval code, and the code only, must be the very first line of your changelog before the server will accept the commit. Not terribly difficult.
Now, here is my problem: On post-commit, I'd like to remove the access code from the log and append the log with information about the approving admin. See the below code (Perl). If you need to know what's in my modules, let me know. I just don't want to post unnecessary information...
Everything works correctly up to the attempted propset, which is of course the entire point of this post-commit script. The script always dies at that system() call:Code:#!/usr/bin/perl # post-commit # Automatically sets changelog to remove the approval code and append admin information # the repository is in /specworks/sandbox use strict; use warnings; use lib '/specworks/admin/perllib'; use SpecWorks::Admin; use SpecWorks::Code; use Carp; # Prepare databases my %codes = Code::retrieve_list(); my %users = Admin::retrieve_roster(); my ($repo_path, $rev_num) = @ARGV; # Retrieve the entire log file; remove the approval code and perform updates chomp(my @log = `svnlook log $repo_path -r $rev_num`); my $user_code = shift @log; my %approval = ( admin => $codes{$user_code}{admin }, date => $codes{$user_code}{date }, comments => $codes{$user_code}{comments}, ); my %admin_info = Admin::find_user($approval{admin}, \%users, {admin_only => 1,}); # Start writing approval information my $admin_info = <<"EOF"; ======== Approval information: Approval code : $user_code Admin : $approval{admin} Admin email : $admin_info{email} Time of approve : $approval{date} Comments : $approval{comments} EOF push @log, $admin_info; my $log_single_line = join "\n", @log; # Attempt to write the changelog - pre-revprop-change will only work if the approval code given is still in the database my $successful_edit = system qq{svn propset svn:log --revprop -r $rev_num "$log_single_line" $repo_path}; if (! $successful_edit){ die "Couldn't append approval information to changelog!\n"; } #If we get this far, then the user's commit attempt is legitimate. Delete the old code from the list. Code::remove_from_list($user_code);
I figure the issue is that svn propset does not take $repo_path as an argument, but instead takes the actual path to the repository (call it svn://my_repo.com:3690/sandbox). Placing that in there doesn't work either, though.svn: /specworks is not a working directory
Right now, pre-revprop-change is set to always return success. My only concern at the moment is getting properties set on post-commit.
So, any ideas on how to append logs on post-commit?
Thanks for your help!


Reply With Quote

Bookmarks