Subversion Repositories DevTools

Rev

Rev 2439 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

########################################################################
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
#
# Module name   : cc2svn_reposcan.pl
# Module name   : cc2svn_updatermSuck.pl
# Module type   : Makefile system
# Compiler(s)   : Perl
# Environment(s): jats
#
# Description   : Process the Repo.dat file and generate lists of
#                 packages to be processed
# Usage:
#
# Version   Who      Date        Description
#
#......................................................................#

require 5.008_002;
use strict;
use warnings;

use Pod::Usage;
use Getopt::Long;

use JatsError;

#
#   Globals
#
my  $VERSION = "1.0.0";                      # Update this
our %ScmRepoMap;

#
#   Options
#
my $opt_verbose = 0;
my $opt_help = 0;
my $opt_repo;
my $opt_last;
my $opt_user;
my $opt_svn = 0;
my $opt_tail;
my $opt_ageorder;
my $opt_ageorderUser;
my $opt_onlyName;

#-------------------------------------------------------------------------------
# Function        : Main Entry
#
# Description     :
#
# Inputs          :
#
# Returns         :
#
my $result = GetOptions (
                "help+"         => \$opt_help,          # flag, multiple use allowed
                "manual:3"      => \$opt_help,
                "verbose:+"     => \$opt_verbose,       # flag
                'repo:s'        => \$opt_repo,
                'last:i'        => \$opt_last,
                'user:i'        => \$opt_user,
                'tail:i'        => \$opt_tail,
                'byage'         => \$opt_ageorder,
                'byuser'        => \$opt_ageorderUser,
                'byname'        => \$opt_onlyName,
                'svn'           => \$opt_svn,            # Include SVNed packages
                );

#
#   Process help and manual options
#
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
pod2usage(-verbose => 1)  if ($opt_help == 2);
pod2usage(-verbose => 2)  if ($opt_help > 2);

ErrorConfig( 'name'    =>'CC2SVN_REPOSCAN',
             'verbose' => $opt_verbose,
              );

#
#   Read in the Mapping Data
#
Message ("Read in Vob Mapping");

my $fname = 'cc2svn.repo.dat';
my $rname;
foreach my $base ( '' , '../' , '-' )
{
    Error ("Connot find file: $fname") if ( $base eq '-' );
    $rname = $base . $fname;
    last if ( -f $rname );
}
require $rname;

Error("Data in $fname is not valid")
    unless ( keys(%ScmRepoMap) >= 0 );

#
#   Filter Repos
#
my $keep = 0;
foreach my $pkgname ( keys %ScmRepoMap )
{
    my $entry = $ScmRepoMap{$pkgname};
    $keep = 1;

    if ( $opt_repo )
    {
        unless ( $entry->{repo} =~ m~^$opt_repo($|/)~i )
        {
         $keep = 0;
        }
    }
    next unless ( $keep );

    if ( defined $opt_last )
    {
        if ( $opt_last > $entry->{youngest} )
        {
            $keep = 0;
        }
    }
    next unless ( $keep );

    if ( defined $opt_user )
    {
        if ( $opt_user > $entry->{ynr} )
        {
            $keep = 0;
        }
    }
    next unless ( $keep );
    

    my $isSvn = exists ($entry->{SVN}) &&  $entry->{SVN};
    if (  !$opt_svn )
    {
        $keep = ! $isSvn;
    }
    next unless ( $keep );
}
continue
{
    delete $ScmRepoMap{$pkgname} unless ( $keep );
}

my $count = 0;
my $total = scalar keys %ScmRepoMap;
my @printOrder;

if ( $opt_ageorderUser ) {
    @printOrder = sort {$ScmRepoMap{$a}{ynr} <=> $ScmRepoMap{$b}{ynr}} keys %ScmRepoMap;
} elsif ( $opt_ageorder ) {
    @printOrder = sort {$ScmRepoMap{$a}{youngest} <=> $ScmRepoMap{$b}{youngest}} keys %ScmRepoMap;
} else {
    @printOrder =  sort {$a cmp $b} keys %ScmRepoMap ;
}


foreach my $pkgname ( @printOrder )
{
    $count++;
    if ( $opt_tail && ($count <= ($total - $opt_tail)) )
    {
        next;
    }

    if ( $opt_onlyName )
    {
        print "$pkgname\n";
    }
    else
    {
        my $entry = $ScmRepoMap{$pkgname};

        my $repo = $entry->{repo};
        my $svn = $entry->{SVN} ? 'SVN' : '---';

        my $youngest            = $entry->{youngest};
        my $youngestNonRipple   = $entry->{ynr};
        my $youngestNonBuildadm = $entry->{ynb};
    

        my $txt = sprintf ("Last:%5d, User:%5d, NonR:%5d, $svn", $youngest, $youngestNonBuildadm, $youngestNonRipple);
        $txt .= sprintf (" %45s %s", $pkgname, $repo );
        print "$txt\n";
    }
}
print "Maching entires: $total\n";

#-------------------------------------------------------------------------------
#   Documentation
#

=pod

=for htmltoc    SYSUTIL::cc2svn::

=head1 NAME

cc2svn_reposcan - Scan Repo.dat file

=head1 SYNOPSIS

  jats cc2svn_reposcan

 Options:
    -help              - brief help message
    -help -help        - Detailed help message
    -man               - Full documentation
    -verbose           - Enable verbosity
    -svn               - Include packages in SVN
    -repo=name         - Select named repos (default all)
    -last=nn           - Select last build > nn
    -user=nn           - Select last user > nn
    -tail=nn           - Displau last nn items
    -byage             - Sort by last build age
    -byuser            - Sort by last User Mode age
    -byname            - Only display package names

=head1 OPTIONS

=over 8

=item B<-help>

Print a brief help message and exits.

=item B<-help -help>

Print a detailed help message with an explanation for each option.

=item B<-man>

Prints the manual page and exits.

=back

=head1 DESCRIPTION

This program is a tool used in the conversion of ClearCase VOBS to subversion.

=cut