#!/usr/bin/perl -w

# START-COMMIT HOOK
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] USER         (the authenticated user attempting to commit)
#   [3] CAPABILITIES (a colon-separated list of capabilities reported
#                     by the client; see note below)
#
# Note: The CAPABILITIES parameter is new in Subversion 1.5, and 1.5
# clients will typically report at least the "mergeinfo" capability.
# If there are other capabilities, then the list is colon-separated,
# e.g.: "mergeinfo:some-other-capability" (the order is undefined).
#

my $repospath     = $ARGV[0];
my $user          = $ARGV[1];
my $capabilities  = $ARGV[2];

# CAPABILITIES is a colon-separated list of svn client capabilities
if (! defined $capabilities) {
    print STDERR "commit fail: you must use Subversion 1.5 or later\n";
    exit 1;
}

my @capabilities  = split /:/, $capabilities;

foreach my $parameter ( @capabilities ){
    $capabilities{ $parameter }++;
}

if( $capabilities{ "mergeinfo" } ){
    exit 0;
}
else{
    print STDERR "commit fail: you must use Subversion 1.5 or later\n";
    exit 1;
}
