Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2438 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
3
#
4
# Module name   : cc2svn_reposcan.pl
5
# Module name   : cc2svn_updatermSuck.pl
6
# Module type   : Makefile system
7
# Compiler(s)   : Perl
8
# Environment(s): jats
9
#
10
# Description   : Process the Repo.dat file and generate lists of
11
#                 packages to be processed
12
# Usage:
13
#
14
# Version   Who      Date        Description
15
#
16
#......................................................................#
17
 
18
require 5.008_002;
19
use strict;
20
use warnings;
21
 
22
use Pod::Usage;
23
use Getopt::Long;
24
 
25
use JatsError;
26
 
27
#
28
#   Globals
29
#
30
my  $VERSION = "1.0.0";                      # Update this
31
our %ScmRepoMap;
32
 
33
#
34
#   Options
35
#
36
my $opt_verbose = 0;
37
my $opt_help = 0;
38
my $opt_repo;
39
my $opt_last;
40
my $opt_user;
41
my $opt_svn = 0;
42
my $opt_tail;
43
my $opt_ageorder;
44
my $opt_ageorderUser;
45
my $opt_onlyName;
46
 
47
#-------------------------------------------------------------------------------
48
# Function        : Main Entry
49
#
50
# Description     :
51
#
52
# Inputs          :
53
#
54
# Returns         :
55
#
56
my $result = GetOptions (
57
                "help+"         => \$opt_help,          # flag, multiple use allowed
58
                "manual:3"      => \$opt_help,
59
                "verbose:+"     => \$opt_verbose,       # flag
60
                'repo:s'        => \$opt_repo,
61
                'last:i'        => \$opt_last,
62
                'user:i'        => \$opt_user,
63
                'tail:i'        => \$opt_tail,
64
                'byage'         => \$opt_ageorder,
65
                'byuser'        => \$opt_ageorderUser,
66
                'byname'        => \$opt_onlyName,
67
                'svn'           => \$opt_svn,            # Include SVNed packages
68
                );
69
 
70
#
71
#   Process help and manual options
72
#
73
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
74
pod2usage(-verbose => 1)  if ($opt_help == 2);
75
pod2usage(-verbose => 2)  if ($opt_help > 2);
76
 
77
ErrorConfig( 'name'    =>'CC2SVN_REPOSCAN',
78
             'verbose' => $opt_verbose,
79
              );
80
 
81
#
82
#   Read in the Mapping Data
83
#
84
Message ("Read in Vob Mapping");
85
 
86
my $fname = 'cc2svn.repo.dat';
87
my $rname;
88
foreach my $base ( '' , '../' , '-' )
89
{
90
    Error ("Connot find file: $fname") if ( $base eq '-' );
91
    $rname = $base . $fname;
92
    last if ( -f $rname );
93
}
94
require $rname;
95
 
96
Error("Data in $fname is not valid")
97
    unless ( keys(%ScmRepoMap) >= 0 );
98
 
99
#
100
#   Filter Repos
101
#
102
my $keep = 0;
103
foreach my $pkgname ( keys %ScmRepoMap )
104
{
105
    my $entry = $ScmRepoMap{$pkgname};
106
    $keep = 1;
107
 
108
    if ( $opt_repo )
109
    {
110
        unless ( $entry->{repo} =~ m~^$opt_repo($|/)~i )
111
        {
112
         $keep = 0;
113
        }
114
    }
115
    next unless ( $keep );
116
 
117
    if ( defined $opt_last )
118
    {
119
        if ( $opt_last > $entry->{youngest} )
120
        {
121
            $keep = 0;
122
        }
123
    }
124
    next unless ( $keep );
125
 
126
    if ( defined $opt_user )
127
    {
128
        if ( $opt_user > $entry->{ynr} )
129
        {
130
            $keep = 0;
131
        }
132
    }
133
    next unless ( $keep );
134
 
135
 
136
    my $isSvn = exists ($entry->{SVN}) &&  $entry->{SVN};
137
    if (  !$opt_svn )
138
    {
139
        $keep = ! $isSvn;
140
    }
141
    next unless ( $keep );
142
}
143
continue
144
{
145
    delete $ScmRepoMap{$pkgname} unless ( $keep );
146
}
147
 
148
my $count = 0;
149
my $total = scalar keys %ScmRepoMap;
150
my @printOrder;
151
 
152
if ( $opt_ageorderUser ) {
153
    @printOrder = sort {$ScmRepoMap{$a}{ynr} <=> $ScmRepoMap{$b}{ynr}} keys %ScmRepoMap;
154
} elsif ( $opt_ageorder ) {
155
    @printOrder = sort {$ScmRepoMap{$a}{youngest} <=> $ScmRepoMap{$b}{youngest}} keys %ScmRepoMap;
156
} else {
157
    @printOrder =  sort {$a cmp $b} keys %ScmRepoMap ;
158
}
159
 
160
 
161
foreach my $pkgname ( @printOrder )
162
{
163
    $count++;
164
    if ( $opt_tail && ($count <= ($total - $opt_tail)) )
165
    {
166
        next;
167
    }
168
 
169
    if ( $opt_onlyName )
170
    {
171
        print "$pkgname\n";
172
    }
173
    else
174
    {
175
        my $entry = $ScmRepoMap{$pkgname};
176
 
177
        my $repo = $entry->{repo};
178
        my $svn = $entry->{SVN} ? 'SVN' : '---';
179
 
180
        my $youngest            = $entry->{youngest};
181
        my $youngestNonRipple   = $entry->{ynr};
182
        my $youngestNonBuildadm = $entry->{ynb};
183
 
184
 
185
        my $txt = sprintf ("Last:%5d, User:%5d, NonR:%5d, $svn", $youngest, $youngestNonBuildadm, $youngestNonRipple);
186
        $txt .= sprintf (" %45s %s", $pkgname, $repo );
187
        print "$txt\n";
188
    }
189
}
190
print "Maching entires: $total\n";
191
 
192
#-------------------------------------------------------------------------------
193
#   Documentation
194
#
195
 
196
=pod
197
 
198
=for htmltoc    SYSUTIL::cc2svn::
199
 
200
=head1 NAME
201
 
202
cc2svn_reposcan - Scan Repo.dat file
203
 
204
=head1 SYNOPSIS
205
 
206
  jats cc2svn_reposcan
207
 
208
 Options:
209
    -help              - brief help message
210
    -help -help        - Detailed help message
211
    -man               - Full documentation
212
    -verbose           - Enable verbosity
213
    -svn               - Include packages in SVN
214
    -repo=name         - Select named repos (default all)
215
    -last=nn           - Select last build > nn
216
    -user=nn           - Select last user > nn
217
    -tail=nn           - Displau last nn items
218
    -byage             - Sort by last build age
219
    -byuser            - Sort by last User Mode age
220
    -byname            - Only display package names
221
 
222
=head1 OPTIONS
223
 
224
=over 8
225
 
226
=item B<-help>
227
 
228
Print a brief help message and exits.
229
 
230
=item B<-help -help>
231
 
232
Print a detailed help message with an explanation for each option.
233
 
234
=item B<-man>
235
 
236
Prints the manual page and exits.
237
 
238
=back
239
 
240
=head1 DESCRIPTION
241
 
242
This program is a tool used in the conversion of ClearCase VOBS to subversion.
243
 
244
=cut
245