info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a commit script


From: Derkaoui
Subject: a commit script
Date: Wed, 12 Mar 2003 13:30:33 -0500 (EST)

Hi, 
I hope somebody could help me with these:
I am using a script to control commit , here it is ( only the part
that i think cause the probleme):

Usage:
#   commit.branch <username> <repository> <files1> <branch1> [<file2>
<branch2> ...]
#
# Checks that the specified branches are valid for the given files.
# Branch may be "." for head.
#
##########################################################################


use Mysql;

use diagnostics;
use strict;

my $scriptdir = `dirname $0`;
chomp $scriptdir;
require "$scriptdir/logmsg-parsing.pl";

use vars qw($db);

###########################################################################

sub branchIsLocked($$$) {
    my ($username, $module, $branch) = @_;

    my $query = $::db->query(<<ENDQUERY);
select 1 from open_branches br, user_groups ug
where
        br.cvs_module = '$module' and
        (br.branch_name = '$branch' or br.branch_name is null) and
        (br.username = '$username' or br.username is null) and
        ((br.groupname = ug.groupname and ug.username = '$username') or
br.groupname is null)
ENDQUERY

    if ($query->fetchrow()) {
        return 0;
    } else {
        return 1;
    }
}

###########################################################################
# Main routine of script

sub main() {
    # We require at least three arguments.
    (scalar(@ARGV) >= 4) || diePrinting("Script commit.branch invoked
wrongly.");
    my ($username, $repositoryPath, @remainder) = @ARGV;

    # Extract the root of the repository path, by stripping off
    # the /home/cvs ($cvsRootDir) and then looking at the first part
before '/'.
    $repositoryPath = stripCVSRoot($repositoryPath);
    my $module = "";
    if ($repositoryPath =~ m|^([^/]+)|) {
        $module = $1;
    } else {
        diePrinting("Invalid repository path (after CVSRoot strip) -
$repositoryPath");
    }

    # Check the branch for each file...
    while (@remainder) {
        my $file = shift @remainder;
        my $branch = shift @remainder;

        if ($branch eq ".") {
            $branch = "HEAD";
        }

        # See if we are locked on this module/branch
        if (branchIsLocked($username, $module, $branch)) {
            diePrinting("Branch '$branch' on module '$module'
($repositoryPath/$file) " .
                        "is locked for '$username'.")
        }
    }

    # At this point, we know that everything's cool!
    exit(0);
}

######################################################################
# Main body

main();
#####################################################################

Every time I commit I receve this message :
Branch 'HEAD' on module 'myproj' (myproj/fichier) is locked for
'root'

cvs commit: Pre-commit check failed
cvs commit: Examining myproj
cvs [commit aborted]: correct above errors first

I am the root, and at first I created my proj directory with fichier
as file in it, import it to the repository, i didn't create any
module or a branch  ( i am new to cvs and I don't know how to create
a module or a branch).

any help?
Thank you.


=====
M. Derkaoui
____________________
who can do, do.  Who can't do, teach.  Who can't teach, critics.

__________________________________________________________
Lèche-vitrine ou lèche-écran ?
magasinage.yahoo.ca




reply via email to

[Prev in Thread] Current Thread [Next in Thread]