Subversion Repositories DevTools

Rev

Rev 2439 | Rev 2764 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2439 Rev 2450
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
2
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
3
#
3
#
4
# Module name   : cc2svn_reposcan.pl
4
# Module name   : cc2svn_reposcan.pl
5
# Module name   : cc2svn_updatermSuck.pl
-
 
6
# Module type   : Makefile system
5
# Module type   : Makefile system
7
# Compiler(s)   : Perl
6
# Compiler(s)   : Perl
8
# Environment(s): jats
7
# Environment(s): jats
9
#
8
#
10
# Description   : Process the Repo.dat file and generate lists of
9
# Description   : Process the Repo.dat file and generate lists of
11
#                 packages to be processed
10
#                 packages to be processed
12
# Usage:
-
 
13
#
11
#
14
# Version   Who      Date        Description
12
#                 Used to select packages that can be processed
-
 
13
# Usage:
15
#
14
#
16
#......................................................................#
15
#......................................................................#
17
 
16
 
18
require 5.008_002;
17
require 5.008_002;
19
use strict;
18
use strict;
Line 21... Line 20...
21
 
20
 
22
use Pod::Usage;
21
use Pod::Usage;
23
use Getopt::Long;
22
use Getopt::Long;
24
 
23
 
25
use JatsError;
24
use JatsError;
-
 
25
use FileUtils;
26
 
26
 
27
#
27
#
28
#   Globals
28
#   Globals
29
#
29
#
30
my  $VERSION = "1.0.0";                      # Update this
30
my  $VERSION = "1.0.0";                      # Update this
Line 34... Line 34...
34
#   Options
34
#   Options
35
#
35
#
36
my $opt_verbose = 0;
36
my $opt_verbose = 0;
37
my $opt_help = 0;
37
my $opt_help = 0;
38
my $opt_repo;
38
my $opt_repo;
-
 
39
my $opt_repoExclude;
39
my $opt_last;
40
my $opt_age;
40
my $opt_user;
41
my $opt_user;
41
my $opt_svn = 0;
42
my $opt_svn = 0;
42
my $opt_tail;
43
my $opt_tail;
43
my $opt_ageorder;
44
my $opt_ageorder;
44
my $opt_ageorderUser;
45
my $opt_ageorderUser;
-
 
46
my $opt_reposort;
45
my $opt_onlyName;
47
my $opt_onlyName;
-
 
48
my $opt_touch;
-
 
49
my $opt_available;
-
 
50
my $opt_all;
-
 
51
 
-
 
52
my %excludeRepos;
46
 
53
 
47
#-------------------------------------------------------------------------------
54
#-------------------------------------------------------------------------------
48
# Function        : Main Entry
55
# Function        : Main Entry
49
#
56
#
50
# Description     :
57
# Description     :
Line 56... Line 63...
56
my $result = GetOptions (
63
my $result = GetOptions (
57
                "help+"         => \$opt_help,          # flag, multiple use allowed
64
                "help+"         => \$opt_help,          # flag, multiple use allowed
58
                "manual:3"      => \$opt_help,
65
                "manual:3"      => \$opt_help,
59
                "verbose:+"     => \$opt_verbose,       # flag
66
                "verbose:+"     => \$opt_verbose,       # flag
60
                'repo:s'        => \$opt_repo,
67
                'repo:s'        => \$opt_repo,
-
 
68
                'excluderepo:s' => \$opt_repoExclude,
61
                'last:i'        => \$opt_last,
69
                'age:i'         => \$opt_age,
62
                'user:i'        => \$opt_user,
70
                'user:i'        => \$opt_user,
63
                'tail:i'        => \$opt_tail,
71
                'tail:i'        => \$opt_tail,
64
                'byage'         => \$opt_ageorder,
72
                'byage'         => \$opt_ageorder,
65
                'byuser'        => \$opt_ageorderUser,
73
                'byuser'        => \$opt_ageorderUser,
-
 
74
                'byrepo'        => \$opt_reposort,
66
                'byname'        => \$opt_onlyName,
75
                'byname'        => \$opt_onlyName,
67
                'svn'           => \$opt_svn,            # Include SVNed packages
76
                'svn'           => \$opt_svn,            # Include SVNed packages
-
 
77
                'touch:s'       => \$opt_touch,
-
 
78
                'available:s'   => \$opt_available,
-
 
79
                'all'           => \$opt_all,
68
                );
80
                );
69
 
81
 
70
#
82
#
71
#   Process help and manual options
83
#   Process help and manual options
72
#
84
#
Line 77... Line 89...
77
ErrorConfig( 'name'    =>'CC2SVN_REPOSCAN',
89
ErrorConfig( 'name'    =>'CC2SVN_REPOSCAN',
78
             'verbose' => $opt_verbose,
90
             'verbose' => $opt_verbose,
79
              );
91
              );
80
 
92
 
81
#
93
#
-
 
94
#   Sanity test
-
 
95
#
-
 
96
Error ("Touch path is not a directory") if ( defined $opt_touch && ! -d $opt_touch );
-
 
97
Error ("Available selector is not a directory") if ( defined $opt_available && ! -d $opt_available );
-
 
98
 
-
 
99
if ($opt_repoExclude)
-
 
100
{
-
 
101
    foreach (split m/\s*,\s*/, $opt_repoExclude )
-
 
102
    {
-
 
103
        $excludeRepos{$_} = 1;
-
 
104
    }
-
 
105
}
-
 
106
 
-
 
107
#
82
#   Read in the Mapping Data
108
#   Read in the Mapping Data
83
#
109
#
84
Message ("Read in Vob Mapping");
110
Message ("Read in Vob Mapping");
85
 
111
 
86
my $fname = 'cc2svn.repo.dat';
112
my $fname = 'cc2svn.repo.dat';
Line 103... Line 129...
103
foreach my $pkgname ( keys %ScmRepoMap )
129
foreach my $pkgname ( keys %ScmRepoMap )
104
{
130
{
105
    my $entry = $ScmRepoMap{$pkgname};
131
    my $entry = $ScmRepoMap{$pkgname};
106
    $keep = 1;
132
    $keep = 1;
107
 
133
 
-
 
134
    unless ( $opt_all )
-
 
135
    {
-
 
136
        if ( $entry->{protected} )
-
 
137
        {
-
 
138
            $keep = 0;
-
 
139
            next;
-
 
140
        }
-
 
141
    }
-
 
142
 
-
 
143
    if ( $opt_repoExclude )
-
 
144
    {
-
 
145
        $entry->{repo} =~ m~^(.*?)(/|$)~;
-
 
146
        my $baseRepo = $1;
-
 
147
        if ( exists $excludeRepos{$baseRepo} || exists $excludeRepos{$entry->{repo}}  )
-
 
148
        {
-
 
149
            $keep = 0;
-
 
150
            next;
-
 
151
        }
-
 
152
    }
-
 
153
 
-
 
154
    if ( $opt_available )
-
 
155
    {
-
 
156
        unless ( -f $opt_available . '/' . $pkgname || -f $opt_available . '/' . $pkgname . '.svg' )
-
 
157
        {
-
 
158
            $keep = 0;
-
 
159
            next;
-
 
160
        }
-
 
161
    }
-
 
162
 
108
    if ( $opt_repo )
163
    if ( $opt_repo )
109
    {
164
    {
110
        unless ( $entry->{repo} =~ m~^$opt_repo($|/)~i )
165
        unless ( $entry->{repo} =~ m~^$opt_repo($|/)~i )
111
        {
166
        {
112
         $keep = 0;
167
         $keep = 0;
-
 
168
         next;
113
        }
169
        }
114
    }
170
    }
115
    next unless ( $keep );
-
 
116
 
171
 
117
    if ( defined $opt_last )
172
    if ( defined $opt_age )
118
    {
173
    {
119
        if ( $opt_last > $entry->{youngest} )
174
        if ( $opt_age > $entry->{youngest} )
120
        {
175
        {
121
            $keep = 0;
176
            $keep = 0;
-
 
177
            next;
122
        }
178
        }
123
    }
179
    }
124
    next unless ( $keep );
-
 
125
 
180
 
126
    if ( defined $opt_user )
181
    if ( defined $opt_user )
127
    {
182
    {
128
        if ( $opt_user > $entry->{ynr} )
183
        if ( $opt_user > $entry->{ynr} )
129
        {
184
        {
130
            $keep = 0;
185
            $keep = 0;
-
 
186
            next;
131
        }
187
        }
132
    }
188
    }
133
    next unless ( $keep );
-
 
134
    
-
 
135
 
189
 
136
    my $isSvn = exists ($entry->{SVN}) &&  $entry->{SVN};
190
    my $isSvn = exists ($entry->{SVN}) &&  $entry->{SVN};
137
    if (  !$opt_svn )
191
    if (  !$opt_svn )
138
    {
192
    {
139
        $keep = ! $isSvn;
193
        $keep = ! $isSvn;
Line 151... Line 205...
151
 
205
 
152
if ( $opt_ageorderUser ) {
206
if ( $opt_ageorderUser ) {
153
    @printOrder = sort {$ScmRepoMap{$a}{ynr} <=> $ScmRepoMap{$b}{ynr}} keys %ScmRepoMap;
207
    @printOrder = sort {$ScmRepoMap{$a}{ynr} <=> $ScmRepoMap{$b}{ynr}} keys %ScmRepoMap;
154
} elsif ( $opt_ageorder ) {
208
} elsif ( $opt_ageorder ) {
155
    @printOrder = sort {$ScmRepoMap{$a}{youngest} <=> $ScmRepoMap{$b}{youngest}} keys %ScmRepoMap;
209
    @printOrder = sort {$ScmRepoMap{$a}{youngest} <=> $ScmRepoMap{$b}{youngest}} keys %ScmRepoMap;
-
 
210
} elsif ( $opt_reposort ) {
-
 
211
    @printOrder = sort {lc $ScmRepoMap{$a}{repo} cmp lc $ScmRepoMap{$b}{repo}} keys %ScmRepoMap;
156
} else {
212
} else {
157
    @printOrder =  sort {$a cmp $b} keys %ScmRepoMap ;
213
    @printOrder =  sort {$a cmp $b} keys %ScmRepoMap ;
158
}
214
}
159
 
215
 
160
 
216
 
Line 174... Line 230...
174
    {
230
    {
175
        my $entry = $ScmRepoMap{$pkgname};
231
        my $entry = $ScmRepoMap{$pkgname};
176
 
232
 
177
        my $repo = $entry->{repo};
233
        my $repo = $entry->{repo};
178
        my $svn = $entry->{SVN} ? 'SVN' : '---';
234
        my $svn = $entry->{SVN} ? 'SVN' : '---';
-
 
235
        my $prot = $entry->{protected} ? $entry->{protected} :' ';
-
 
236
        $prot =~ m~(.)~;
-
 
237
        $prot = $1;
179
 
238
 
180
        my $youngest            = $entry->{youngest};
239
        my $youngest            = $entry->{youngest};
181
        my $youngestNonRipple   = $entry->{ynr};
240
        my $youngestNonRipple   = $entry->{ynr};
182
        my $youngestNonBuildadm = $entry->{ynb};
241
        my $youngestNonBuildadm = $entry->{ynb};
183
    
242
    
184
 
243
 
185
        my $txt = sprintf ("Last:%5d, User:%5d, NonR:%5d, $svn", $youngest, $youngestNonBuildadm, $youngestNonRipple);
244
        my $txt = sprintf ("Last:%5d, User:%5d, NonR:%5d, $svn $prot", $youngest, $youngestNonBuildadm, $youngestNonRipple);
186
        $txt .= sprintf (" %45s %s", $pkgname, $repo );
245
        $txt .= sprintf (" %45s %s", $pkgname, $repo );
187
        print "$txt\n";
246
        print "$txt\n";
188
    }
247
    }
-
 
248
 
-
 
249
    if ( $opt_touch )
-
 
250
    {
-
 
251
        TouchFile( $opt_touch .'/'.$pkgname);
-
 
252
        unlink ($opt_available . '/' . $pkgname) if ( $opt_available );
-
 
253
        unlink ($opt_available . '/' . $pkgname . '.svg') if ( $opt_available );
-
 
254
    }
189
}
255
}
190
print "Maching entires: $total\n";
256
print "Maching entires: $total\n";
191
 
257
 
192
#-------------------------------------------------------------------------------
258
#-------------------------------------------------------------------------------
193
#   Documentation
259
#   Documentation
Line 208... Line 274...
208
 Options:
274
 Options:
209
    -help              - brief help message
275
    -help              - brief help message
210
    -help -help        - Detailed help message
276
    -help -help        - Detailed help message
211
    -man               - Full documentation
277
    -man               - Full documentation
212
    -verbose           - Enable verbosity
278
    -verbose           - Enable verbosity
-
 
279
   Package Selection
213
    -svn               - Include packages in SVN
280
    -svn               - Include packages in SVN too
214
    -repo=name         - Select named repos (default all)
281
    -repo=name         - Select named repos (default all)
-
 
282
    -excludeRepo=name  - Exclude repos
215
    -last=nn           - Select last build > nn
283
    -last=nn           - Select last build > nn
216
    -user=nn           - Select last user > nn
284
    -user=nn           - Select last user > nn
-
 
285
    -available=path    - Select if in named directory
217
    -tail=nn           - Displau last nn items
286
    -all               - Include Protected and Broken packages
-
 
287
   Output Sorting
218
    -byage             - Sort by last build age
288
    -byage             - Sort by last build age
219
    -byuser            - Sort by last User Mode age
289
    -byuser            - Sort by last User Mode age
-
 
290
    -byprepo           - Sort by repository name
-
 
291
   Display control
-
 
292
    -tail=nn           - Display last nn items
220
    -byname            - Only display package names
293
    -byname            - Only display package names
-
 
294
   Process control
-
 
295
    -touch=path        - Create a file named after the package
-
 
296
                         Delete 'available' marker file
221
 
297
 
222
=head1 OPTIONS
298
=head1 OPTIONS
223
 
299
 
224
=over 8
300
=over 8
225
 
301
 
Line 233... Line 309...
233
 
309
 
234
=item B<-man>
310
=item B<-man>
235
 
311
 
236
Prints the manual page and exits.
312
Prints the manual page and exits.
237
 
313
 
-
 
314
=item B<-available=path>
-
 
315
 
-
 
316
This option will limit the selection to packages that have a marker file in
-
 
317
the named directory. The marker file will be file with the same name
-
 
318
as the package or with a '.svg' extension.
-
 
319
 
-
 
320
When used in conjunction with the '-touch' option the marker file will be
-
 
321
deleted after the target marker file has been 'touched'.
-
 
322
 
-
 
323
=item B<-touch=path>
-
 
324
 
-
 
325
This option will populate a 'new' or test directory with packages. When used,
-
 
326
an empty file named after the package, will be created in the target path.
-
 
327
 
238
=back
328
=back
239
 
329
 
240
=head1 DESCRIPTION
330
=head1 DESCRIPTION
241
 
331
 
242
This program is a tool used in the conversion of ClearCase VOBS to subversion.
332
This program is a tool used in the conversion of ClearCase VOBS to subversion.
243
 
333
 
-
 
334
=head2 Examples
-
 
335
 
-
 
336
The follwoing command will:
-
 
337
 
-
 
338
 jats cc2svn_reposcan -repo=MASS_Dev_Infra -user=30 -byuser -available=. -touch=../new
-
 
339
 
-
 
340
Process packages in the MASS_Dev_Infra repository, selecting that that have
-
 
341
not been modified by a user for 30 days and that have a marker file in the
-
 
342
current directory. It will display the results sorted by the time since last
-
 
343
modified by a user. It will also create a marker file in the directory '../new'.
-
 
344
 
244
=cut
345
=cut
245
 
346