Subversion Repositories DevTools

Rev

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

Rev 2319 Rev 2413
Line 31... Line 31...
31
use JatsProperties;
31
use JatsProperties;
32
use JatsEnv;
32
use JatsEnv;
33
use ConfigurationFile;
33
use ConfigurationFile;
34
use JatsSvn qw(:All);
34
use JatsSvn qw(:All);
35
use JatsLocateFiles;
35
use JatsLocateFiles;
-
 
36
use Encode;
36
 
37
 
37
 
38
 
38
#use Data::Dumper;
39
#use Data::Dumper;
39
use Fcntl ':flock'; # import LOCK_* constants
40
use Fcntl ':flock'; # import LOCK_* constants
40
use Cwd;
41
use Cwd;
Line 66... Line 67...
66
my $opt_postimage = 1;
67
my $opt_postimage = 1;
67
my $opt_workDir = '/work';
68
my $opt_workDir = '/work';
68
my $opt_vobMap;
69
my $opt_vobMap;
69
my $opt_preserveProjectBase;
70
my $opt_preserveProjectBase;
70
my $opt_ignoreProjectBaseErrors;
71
my $opt_ignoreProjectBaseErrors;
-
 
72
my $opt_ignoreMakeProjectErrors;
71
my $opt_delete;
73
my $opt_delete;
72
my $opt_recentAge = 14;             # Days
74
my $opt_recentAge = 14;             # Days
-
 
75
my $opt_relabel = 0;
73
 
76
 
74
################################################################################
77
################################################################################
75
#   List of Projects Suffixes and Branch Names to be used within SVN
78
#   List of Projects Suffixes and Branch Names to be used within SVN
76
#
79
#
77
#       Name        - Name of branch for the project
80
#       Name        - Name of branch for the project
Line 102... Line 105...
102
    '.uk'       => { Name => 'UkProject' },
105
    '.uk'       => { Name => 'UkProject' },
103
    '.pmb'      => { Name => 'Pietermaritzburg' },
106
    '.pmb'      => { Name => 'Pietermaritzburg' },
104
    '.vps'      => { Name => 'VixPayments' },
107
    '.vps'      => { Name => 'VixPayments' },
105
    '.ncc'      => { Name => 'NSWClubCard' },
108
    '.ncc'      => { Name => 'NSWClubCard' },
106
    '.rm'       => { Name => 'Rome' },
109
    '.rm'       => { Name => 'Rome' },
-
 
110
    '.vss'      => { Name => 'SmartSite' },
107
    'unknown'   => { Name => 'UnknownProject' },
111
    'unknown'   => { Name => 'UnknownProject' },
108
 
112
 
109
    '.ebr'      => { Name => 'eBrio' , Trunk => 1 },
113
    '.ebr'      => { Name => 'eBrio' , Trunk => 1 },
110
    '.mas'      => { Name => 'Mass'  , Trunk => 1 },
114
    '.mas'      => { Name => 'Mass'  , Trunk => 1 },
111
    '.cr'       => { Name => 'Core'  , Trunk => 1 },
115
    '.cr'       => { Name => 'Core'  , Trunk => 1 },
Line 126... Line 130...
126
    '.pxxx.sydddd'  => '.syd',
130
    '.pxxx.sydddd'  => '.syd',
127
    '.oslo'         => '.oso',
131
    '.oslo'         => '.oso',
128
    '.osl'          => '.oso',
132
    '.osl'          => '.oso',
129
);
133
);
130
 
134
 
-
 
135
my @excludeFromImport = (
-
 
136
 
-
 
137
    # 22-Oct-12: Excluded on request from Kasun Sirikumara
-
 
138
    # Pending VSS work
-
 
139
    'agency_website',
-
 
140
    'alx',
-
 
141
    'alx-api',
-
 
142
    'cardholder_website',
-
 
143
    'loginmodule-ad',
-
 
144
    'ols-enquiry',
-
 
145
    'ols-enquiry-api',
-
 
146
    'olsrpc4j',
-
 
147
    'orca-middleware',
-
 
148
    'orca-middleware-api',
-
 
149
    'orca-salesEngine',
-
 
150
    'orca-web-api',
-
 
151
    'orca-web-utils',
-
 
152
    'TestPaymentGateway',
-
 
153
    'tgen4j',
-
 
154
    'web-cd-client',
-
 
155
 
-
 
156
 
-
 
157
    # 05-Nov-12: Pending fixup for include.txt files that escape the VOB
-
 
158
    #
-
 
159
#    'ddu_app_manager',
-
 
160
#    'ddu_dog',
-
 
161
#    'ddu_dog_lib',
-
 
162
#    'ddu_fim',
-
 
163
#    'ddu_logging_lib',
-
 
164
#    'ddu_management',
-
 
165
#    'ddu_mccain',
-
 
166
#    'ddu_mon',
-
 
167
#    'ddu_rcu',
-
 
168
#    'ddu_status_logging',
-
 
169
    
-
 
170
);
-
 
171
 
131
my %specialPackages = (
172
my %specialPackages = (
132
    'core_devl'           =>  ',all,protected,',
173
    'core_devl'           =>  ',all,protected,',
133
    'daf_utils_mos'       => ',flat,',
174
    'daf_utils_mos'       => ',flat,',
134
    'mos_packager'        => ',all,',
175
    'mos_packager'        => ',all,',
135
    'cfmgr-cfmgr'         => ',flat,',
176
    'cfmgr-cfmgr'         => ',flat,',
136
    'daf_utils_button_st' => ',flat,',
177
    'daf_utils_button_st' => ',flat,',
-
 
178
    'ReleaseName'         => ',flat,',
-
 
179
    'reports'             => ',utf8,',
-
 
180
    'cda_imports'         => ',utf8,',
-
 
181
    'cdxforms'            => ',utf8,',
-
 
182
    'db_cda'              => ',utf8,',
-
 
183
 
137
 
184
 
138
    # Need to be handled in a special manner
185
    # Need to be handled in a special manner
139
    # Not done by this utility
186
    # Not done by this utility
140
    #
187
    #
141
    'linux_drivers_eb5600'  => ',protected,',
188
    'linux_drivers_eb5600'  => ',protected,',
Line 158... Line 205...
158
    'orahops-ssw-install'       => ',protected,',
205
    'orahops-ssw-install'       => ',protected,',
159
    'orahops-ssw-patch'         => ',protected,',
206
    'orahops-ssw-patch'         => ',protected,',
160
# End of ukHops migration exclussion
207
# End of ukHops migration exclussion
161
 
208
 
162
    'ftp'                   => 'SetProjectBase,',
209
    'ftp'                   => 'SetProjectBase,',
-
 
210
    'ddu_app_manager'       => 'SetProjectBase,',
163
 
211
 
164
    'icl'                   => 'IgnoreProjectBase,',
212
    'icl'                   => 'IgnoreProjectBase,',
165
    'itso'                  => 'IgnoreProjectBase,',
213
    'itso'                  => 'IgnoreProjectBase,',
166
    'daf_osa_mos'           => 'IgnoreProjectBase,',
214
    'daf_osa_mos'           => 'IgnoreProjectBase,',
167
    'daf_utils_mos'         => 'IgnoreProjectBase,',
215
    'daf_utils_mos'         => 'IgnoreProjectBase,',
Line 235... Line 283...
235
my $allSvn;
283
my $allSvn;
236
my @multiplePaths;
284
my @multiplePaths;
237
my @badEssentials;
285
my @badEssentials;
238
my %svnData;
286
my %svnData;
239
my $cwd;
287
my $cwd;
-
 
288
my $mustConvertFileNames;
-
 
289
my $workDir;
240
 
290
 
241
my $packageNames;
291
my $packageNames;
242
my @packageNames;
292
my @packageNames;
243
my $multiPackages = -1;
293
my $multiPackages = -1;
244
my $visitId = 0;
294
my $visitId = 0;
Line 246... Line 296...
246
my $rippleCount = 0;
296
my $rippleCount = 0;
247
my $svnRepo;
297
my $svnRepo;
248
my $processCount = 0;
298
my $processCount = 0;
249
my $processTotal = 0;
299
my $processTotal = 0;
250
my $recentCount = 0;
300
my $recentCount = 0;
-
 
301
my $packageReLabelCount = 0;
-
 
302
my %saneLabels;
251
 
303
 
252
our $GBE_RM_URL;
304
our $GBE_RM_URL;
253
my $UNIX = $ENV{'GBE_UNIX'};
305
my $UNIX = $ENV{'GBE_UNIX'};
254
 
306
 
255
my $result = GetOptions (
307
my $result = GetOptions (
Line 271... Line 323...
271
                "tip:s"         => \@opt_tip,           # Force tip version(s)
323
                "tip:s"         => \@opt_tip,           # Force tip version(s)
272
                "log!"          => \$opt_log,
324
                "log!"          => \$opt_log,
273
                "delete!"       => \$opt_delete,
325
                "delete!"       => \$opt_delete,
274
                "postimage!"    => \$opt_postimage,
326
                "postimage!"    => \$opt_postimage,
275
                'workdir:s'     => \$opt_workDir,
327
                'workdir:s'     => \$opt_workDir,
-
 
328
                'relabel!'      => \$opt_relabel,
276
                );
329
                );
277
 
330
 
278
#
331
#
279
#   Process help and manual options
332
#   Process help and manual options
280
#
333
#
Line 437... Line 490...
437
    }
490
    }
438
 
491
 
439
    #
492
    #
440
    #   Perform all the work in a package specific subdirectory
493
    #   Perform all the work in a package specific subdirectory
441
    #
494
    #
442
    my $workDir = $opt_workDir . '/' . $packageNames;
495
    $workDir = $opt_workDir . '/' . $packageNames;
443
    mkdir $workDir unless ( -d $workDir );
496
    mkdir $workDir unless ( -d $workDir );
444
    chdir $workDir || Error ("Cannot cd to $workDir");
497
    chdir $workDir || Error ("Cannot cd to $workDir");
445
 
498
 
446
    #
499
    #
447
    #   Process all packages
500
    #   Process all packages
Line 581... Line 634...
581
    }
634
    }
582
 
635
 
583
    #
636
    #
584
    #   Some packages are special
637
    #   Some packages are special
585
    #
638
    #
-
 
639
    if ( $svnRepo =~ m~/Manufacturing(/|$)~ )
-
 
640
    {
-
 
641
        Message ("Set Manufacturing Repo style");
-
 
642
        $opt_flat = 1;
-
 
643
        setPruneMode('none') unless (defined $opt_pruneModeString);
-
 
644
    }
-
 
645
 
586
 
646
 
587
    if ( $packageNames[0] =~ m'^br_applet_' )
647
    if ( $packageNames[0] =~ m'^br_applet_' )
588
    {
648
    {
589
        $opt_flat = 1 unless defined $opt_flat;
649
      $opt_flat = 1 unless defined $opt_flat;
-
 
650
    }
-
 
651
 
-
 
652
    foreach  ( @excludeFromImport )
-
 
653
    {
-
 
654
         $specialPackages{$_} .= 'protected,';
590
    }
655
    }
591
 
656
 
592
    if ( exists $specialPackages{$packageNames[0]} )
657
    if ( exists $specialPackages{$packageNames[0]} )
593
    {
658
    {
594
        my $data = $specialPackages{$packageNames[0]};
659
        my $data = $specialPackages{$packageNames[0]};
Line 613... Line 678...
613
        if ( index( $data, 'IgnoreProjectBase,' ) >= 0) {
678
        if ( index( $data, 'IgnoreProjectBase,' ) >= 0) {
614
            $opt_ignoreProjectBaseErrors = 1;
679
            $opt_ignoreProjectBaseErrors = 1;
615
            Message ("Ignore ProjectBase Errors");
680
            Message ("Ignore ProjectBase Errors");
616
        }
681
        }
617
 
682
 
-
 
683
        if ( index( $data, 'IgnoreMakeProject,' ) >= 0) {
-
 
684
            $opt_ignoreMakeProjectErrors = 1;
-
 
685
            Message ("Ignore MakeProject Usage");
-
 
686
        }
-
 
687
        
-
 
688
 
-
 
689
        if ( index( $data, 'utf8,' ) >= 0) {
-
 
690
            $mustConvertFileNames = 1;
-
 
691
            Message ("Convert filenames to UTF8");
-
 
692
        }
618
    }
693
    }
619
 
694
 
620
    Message("Package Type: $packageType, $pruneModeString");
695
    Message("Package Type: $packageType, $pruneModeString");
621
}
696
}
622
 
697
 
Line 1563... Line 1638...
1563
    #   Delete the created view
1638
    #   Delete the created view
1564
    #   Its just a directory, so delete it
1639
    #   Its just a directory, so delete it
1565
    #
1640
    #
1566
    if ( $data{ViewRoot} && -d $data{ViewRoot})
1641
    if ( $data{ViewRoot} && -d $data{ViewRoot})
1567
    {
1642
    {
1568
        if ( !$opt_reuse || $rv )
1643
        if ( !$opt_reuse || ($rv && ($rv != 4 && $rv != 12 )) )
1569
        {
1644
        {
1570
            Message ("Delete View: $data{ViewRoot}");
1645
            Message ("Delete View: $data{ViewRoot}");
1571
            RmDirTree ($data{ViewRoot} );
1646
            RmDirTree ($data{ViewRoot} );
1572
        }
1647
        }
1573
        else
1648
        else
Line 1585... Line 1660...
1585
    #
1660
    #
1586
    #   If this version has any 'ripples' then process them while we have the
1661
    #   If this version has any 'ripples' then process them while we have the
1587
    #   main view. Note the ripple list may contain entries that do not
1662
    #   main view. Note the ripple list may contain entries that do not
1588
    #   exist - they will have been pruned.
1663
    #   exist - they will have been pruned.
1589
    #
1664
    #
1590
if(0) {
1665
if(1) {
1591
    foreach my $rentry ( @{$versions{$entry}{rippleList}} )
1666
    foreach my $rentry ( @{$versions{$entry}{rippleList}} )
1592
    {
1667
    {
1593
        next unless( exists $versions{$rentry} );
1668
        next unless( exists $versions{$rentry} );
1594
 
1669
 
1595
        if ($versions{$rentry}{Processed})
1670
        if ($versions{$rentry}{Processed})
Line 1623... Line 1698...
1623
{
1698
{
1624
    my ($data, $entry) = @_;
1699
    my ($data, $entry) = @_;
1625
    my $rv;
1700
    my $rv;
1626
    my $cc_label;
1701
    my $cc_label;
1627
    my $cc_path;
1702
    my $cc_path;
-
 
1703
    my $cc_path_original;
1628
 
1704
 
1629
    #
1705
    #
1630
    #   Init Data
1706
    #   Init Data
1631
    #
1707
    #
1632
    $data->{rmRef} = 'ERROR';
1708
    $data->{rmRef} = 'ERROR';
Line 1665... Line 1741...
1665
    $data->{tag} =~ m~^(.+?)::(.*?)(::(.+))?$~;
1741
    $data->{tag} =~ m~^(.+?)::(.*?)(::(.+))?$~;
1666
    $cc_label = $4;
1742
    $cc_label = $4;
1667
    $cc_path = $2;
1743
    $cc_path = $2;
1668
    $cc_path = '/' . $cc_path;
1744
    $cc_path = '/' . $cc_path;
1669
    $cc_path =~ tr~\\/~/~s;
1745
    $cc_path =~ tr~\\/~/~s;
-
 
1746
    $cc_path_original = $cc_path;
1670
 
1747
 
1671
    #
1748
    #
1672
    #   Correct well known path mistakes
1749
    #   Correct well known path mistakes
1673
    #
1750
    #
1674
    $cc_path =~ s~/build.pl$~~i;
1751
    $cc_path =~ s~/build.pl$~~i;
1675
    $cc_path =~ s~/src$~~i;
1752
    $cc_path =~ s~/src$~~i;
-
 
1753
    $cc_path =~ s~/cpp$~~i;
1676
    $cc_path =~ s~/MASS_Dev/Infra/~/MASS_Dev_Infra/~i;
1754
    $cc_path =~ s~/MASS_Dev/Infra/~/MASS_Dev_Infra/~i;
1677
    $cc_path =~ s~/MASS_Dev/Tools/~/MASS_Dev_Tools/~i;
1755
    $cc_path =~ s~/MASS_Dev/Tools/~/MASS_Dev_Tools/~i;
1678
    $cc_path =~ s~/MASS_Dev/Bus/~/MASS_Dev_Bus/~i;
1756
    $cc_path =~ s~/MASS_Dev/Bus/~/MASS_Dev_Bus/~i;
1679
    $cc_path =~ s~/MASS_Dev_Bus/Cbp/~/MASS_Dev_Bus/CBP/~i;
1757
    $cc_path =~ s~/MASS_Dev_Bus/Cbp/~/MASS_Dev_Bus/CBP/~i;
1680
    $cc_path =~ s~/MREF_Package/ergpostmongui$~/MREF_Package/ergpostmongui~i;
1758
    $cc_path =~ s~/MREF_Package/ergpostmongui$~/MREF_Package/ergpostmongui~i;
1681
    $cc_path =~ s~/MREF_21/MREF_Package/~/MREF_Package/~i;
1759
    $cc_path =~ s~/MREF_../MREF_Package/~/MREF_Package/~i;
-
 
1760
    $cc_path =~ s~/MREF_Package/mass_ergocdp/~/MREF_Package/ergocdp/~i;
-
 
1761
    $cc_path =~ s~/MASS_Dev_Bus/CBP/systemCD.ejb~/MASS_Dev_Bus/CBP/systemCD/ejb~i;
-
 
1762
    $cc_path =~ s~/MASS_Dev_Bus/Financial/cpp/paymentmanager~/MASS_Dev_Bus/Financial/cpp/paymentmanager~i;
-
 
1763
    $cc_path =~ s~/MASS_Dev_Bus/WebServices~/MASS_Dev_Bus/WebServices~i;
-
 
1764
    $cc_path =~ s~/MASS_Dev_Bus/CBP/nullAdapter~//MASS_Dev_Bus/CBP/nullAdaptor~i;
-
 
1765
 
-
 
1766
    $cc_path = '/MASS_Dev_Bus' if ( $cc_path =~ m~/MASS_Dev_Bus/ImageCapture(/|$)~i );
-
 
1767
    $cc_path = '/MASS_Dev_Bus/CBP/enquiry' if ( $versions{$entry}{name} eq 'EJBEnqPxyConnector');
-
 
1768
    $cc_path = '/MASS_Dev_Bus/CBP/enquiry' if ( $versions{$entry}{name} eq 'proxyif4j');
-
 
1769
    $cc_path = '/MASS_Dev_Bus' if ( $versions{$entry}{name} eq 'ImageCaptureTomcatDeployment');
-
 
1770
    $cc_path = '/MASS_Dev_Bus/WebServices/MassWS' if ( $versions{$entry}{name} eq 'MassWebServicesImpl');
-
 
1771
 
-
 
1772
    if (   $versions{$entry}{name} =~ m/^ERGagency$/i
-
 
1773
        || $versions{$entry}{name} =~ m/^ERGavm$/i
-
 
1774
        || $versions{$entry}{name} =~ m/^ERGboi$/i
-
 
1775
        || $versions{$entry}{name} =~ m/^ERGcallcenter$/i
-
 
1776
        || $versions{$entry}{name} =~ m/^ERGcardholder$/i
-
 
1777
        || $versions{$entry}{name} =~ m/^ERGcdaimports$/i
-
 
1778
        || $versions{$entry}{name} =~ m/^ERGcda$/i
-
 
1779
        || $versions{$entry}{name} =~ m/^ERGcscedit$/i
-
 
1780
        || $versions{$entry}{name} =~ m/^ERGcs$/i
-
 
1781
        || $versions{$entry}{name} =~ m/^ERGofs$/i
-
 
1782
        || $versions{$entry}{name} =~ m/^ERGols$/i
-
 
1783
        || $versions{$entry}{name} =~ m/^ERGtpf$/i
-
 
1784
        || $versions{$entry}{name} =~ m/^ERGorasys$/i
-
 
1785
        || $versions{$entry}{name} =~ m/^ERGoracs$/i
-
 
1786
        || $versions{$entry}{name} =~ m/^ERGpxyif$/i
-
 
1787
        || $versions{$entry}{name} =~ m/^ERGtp5upg$/i
-
 
1788
        || $versions{$entry}{name} =~ m/^ERGinstitutional$/i
-
 
1789
        || $versions{$entry}{name} =~ m/^ERGinfra$/i
-
 
1790
        || $versions{$entry}{name} =~ m/^ERGcrrpts$/i
-
 
1791
        || $versions{$entry}{name} =~ m/^ERGmiddle$/i
-
 
1792
        || $versions{$entry}{name} =~ m/^ERGmiddleapi$/i
-
 
1793
        || $versions{$entry}{name} =~ m/^ERGwebapi$/i
-
 
1794
        || $versions{$entry}{name} =~ m/^ERGwebtestui$/i
-
 
1795
        || $versions{$entry}{name} =~ m/^ERGwebesbui$/i
-
 
1796
        || $versions{$entry}{name} =~ m/^ERGwspiv$/i
-
 
1797
        || $versions{$entry}{name} =~ m/^ERGwscst$/i
-
 
1798
        || $versions{$entry}{name} =~ m/^sposMUG$/i
-
 
1799
        || $versions{$entry}{name} =~ m/^ERGfinman$/i
-
 
1800
        || $versions{$entry}{name} =~ m/^ERGkm$/i
-
 
1801
        || $versions{$entry}{name} =~ m/^ERGxml$/i
-
 
1802
        || $versions{$entry}{name} =~ m/^ERGoradacw$/i
-
 
1803
        || $versions{$entry}{name} =~ m/^ERGtru$/i
-
 
1804
        )
-
 
1805
    {
-
 
1806
        $cc_path = '/MREF_Package';
-
 
1807
    }
1682
 
1808
 
-
 
1809
    if (   $versions{$entry}{name} =~ m/^tp5000_MUG$/i )
-
 
1810
    {
-
 
1811
        if ( $versions{$entry}{version} =~ m~vtk$~ )
-
 
1812
        {
-
 
1813
            $cc_path = '/MREF_Package';
-
 
1814
        }
-
 
1815
    }
1683
 
1816
 
-
 
1817
    if ( $cc_path_original ne $cc_path )
-
 
1818
    {
-
 
1819
            Message ("Package: $versions{$entry}{name}. Forcing CC path to: $cc_path" );
-
 
1820
    }
-
 
1821
    
1684
#print "--- Path: $cc_path, Label: $cc_label\n";
1822
#print "--- Path: $cc_path, Label: $cc_label\n";
1685
 
1823
 
1686
    #
1824
    #
1687
    #   Create CC view
1825
    #   Create CC view
1688
    #   Import into Subversion View
1826
    #   Import into Subversion View
1689
    #
1827
    #
1690
    $data->{ViewRoot} = $opt_name ? $opt_name : "$cc_label";
1828
    $rv = extractFilesFromClearCase( $data, $cc_path, $cc_label );
1691
    $data->{ViewPath} =  $data->{ViewRoot} . $cc_path;
-
 
1692
 
-
 
1693
    if ( $opt_preserveProjectBase )
-
 
1694
    {
-
 
1695
        my $cc_vob = $cc_path;
1829
    return $rv if ( $rv );
1696
        $cc_vob =~ s~^/~~;
-
 
1697
        $cc_vob =~ s~/.*~~;
-
 
1698
        $data->{ViewPath} =  $data->{ViewRoot} . '/' . $cc_vob;
-
 
1699
        Message ("Preserving Project Base");
-
 
1700
    }
-
 
1701
    $data->{ViewPath} =~  tr~/~/~s;
-
 
1702
 
1830
 
1703
    if ( $opt_reuse && -d $data->{ViewPath}  )
-
 
1704
    {
1831
    #
1705
        Message ("Reusing view: $cc_label");
1832
    #   Developers have been slack
-
 
1833
    #       Sometime the mark the source path as 'GMTPE2005'
-
 
1834
    #       Sometimes as 'GMTPE2005/Package/Fred/Jill/Harry'
1706
    }
1835
    #
-
 
1836
    #   Attempt to suck up empty directories below the specified
-
 
1837
    #   source path
1707
    else
1838
    #
-
 
1839
    unless ( $opt_preserveProjectBase )
1708
    {
1840
    {
1709
        my @args;
1841
        #
1710
        push (@args, '-view', $opt_name ) if ( defined $opt_name );
-
 
1711
        $rv = JatsToolPrint ( 'jats_ccrelease', '-extractfiles', '-root=.' , '-noprefix',
-
 
1712
                    "-label=$cc_label" ,
1842
        #   Look in ViewPath
1713
                    "-path=$cc_path",
1843
        #   If it contains only ONE directory then we can suck it up
1714
                    @args
1844
        #
1715
                    );
1845
        my $testDir = findDirWithStuff( $data->{ViewPath} );
1716
 
1846
 
1717
        unless ( -d $data->{ViewPath}  )
1847
        unless ( $data->{ViewPath} eq $testDir  )
1718
        {
1848
        {
-
 
1849
            Message ("Adjust Base Dir: $testDir");
1719
            $data->{errStr} = 'Failed to extract files from CC';
1850
            $data->{adjustedPath} = $data->{ViewPath};
1720
            return 2;
1851
            $data->{ViewPath} = $testDir;
1721
        }
1852
        }
1722
    }
1853
    }
1723
 
-
 
1724
 
1854
    
1725
    #
1855
    #
1726
    #   Some really ugly packages make use of a Jats feature called 'SetProjectBase'
1856
    #   Some really ugly packages make use of a Jats feature called 'SetProjectBase'
1727
    #   Detect such packages as we will need to handle them differently
1857
    #   Detect such packages as we will need to handle them differently
1728
    #   Can't really handle it on the fly
1858
    #   Can't really handle it on the fly
1729
    #   All we can do is detect it and report it - at the moment
1859
    #   All we can do is detect it and report it - at the moment
Line 1737... Line 1867...
1737
            return 4;           # Lets see what the others look like too
1867
            return 4;           # Lets see what the others look like too
1738
#            return 14;
1868
#            return 14;
1739
        }
1869
        }
1740
    }
1870
    }
1741
 
1871
 
1742
 
-
 
1743
    #
1872
    #
-
 
1873
    #   Some really really ugly packgaes make use of the MakeProject directive
-
 
1874
    #   and then use an 'include.txt file to access paths all over the VOB
1744
    #   Developers have been slack
1875
    #   The problem is with lines like
-
 
1876
    #           /I ..\..\..\..\..\..\DPG_SWCode\projects\seattle\ddu\component\DTIApp\dsi\inc
-
 
1877
    #   Two problems:
1745
    #       Sometime the mark the source path as 'GMTPE2005'
1878
    #       Vob Name is not a part of the migration
1746
    #       Sometimes as 'GMTPE2005/Package/Fred/Jill/Harry'
1879
    #       If we 'SuckUp' empty directories then this may break
-
 
1880
    #       the pathing.
-
 
1881
    #   All we can do is detect it and report it - at the moment
1747
    #
1882
    #
-
 
1883
    if (detectMakeProjectUsage($data, $cc_path) )
-
 
1884
    {
-
 
1885
        unless ( $opt_ignoreMakeProjectErrors )
-
 
1886
        {
-
 
1887
            $data->{BadMakeProject}++;
-
 
1888
            $data->{errStr} = 'Use of MakeProject detected';
1748
    #   Attempt to suck up empty directories below the specified
1889
            return 4;           # Lets see what the others look like too
1749
    #   source path
1890
#            return 14;
-
 
1891
        }
-
 
1892
    }
-
 
1893
 
1750
    #
1894
    #
-
 
1895
    #   Some packages have filenames that are need to be converted
-
 
1896
    #
1751
    unless ( $opt_preserveProjectBase )
1897
    if ( $mustConvertFileNames  )
1752
    {
1898
    {
-
 
1899
        $rv = system ( '/home/dpurdie/svn/tools/convmv-1.15/convmv',
-
 
1900
                 '-fiso-8859-1',
-
 
1901
                 '-tutf8',
-
 
1902
                 '-r',
-
 
1903
                 '--notest',
-
 
1904
                 $data->{ViewPath} );
-
 
1905
 
-
 
1906
        if ( $rv )
-
 
1907
        {
-
 
1908
            $data->{errStr} = 'Failed to convert filenames to UTF8';
-
 
1909
            return 14;
-
 
1910
        }
-
 
1911
 
1753
        #
1912
        #
1754
        #   Look in ViewPath
1913
        #   Check to see if our ViewPath has been changed
1755
        #   If it contains only ONE directory then we can suck it up
1914
        #   If so, then try to fix it
1756
        #
1915
        #
1757
        my $testDir = findDirWithStuff( $data->{ViewPath} );
-
 
1758
 
-
 
1759
        unless ( $data->{ViewPath} eq $testDir  )
1916
        unless ( -d $data->{ViewPath} )
1760
        {
1917
        {
1761
            Message ("Adjust Base Dir: $testDir");
1918
            Message ("Correct UTF-8 change to ViewPath");
1762
            $data->{adjustedPath} = $data->{ViewPath};
1919
            $data->{ViewPath} = encode('UTF-8', $data->{ViewPath}, Encode::FB_DEFAULT);
1763
            $data->{ViewPath} = $testDir;
1920
            Warning ("Correct UTF-8 change to ViewPath - FAILED") unless ( -d $data->{ViewPath} );
1764
        }
1921
        }
1765
    }
1922
    }
1766
    
1923
    
1767
 
-
 
1768
    #
1924
    #
1769
    #   Have a CC view
1925
    #   Have a CC view
1770
    #   Now we can create the SVN package and branching point before we
1926
    #   Now we can create the SVN package and branching point before we
1771
    #   import the CC data into SVN
1927
    #   import the CC data into SVN
1772
    #
1928
    #
Line 2190... Line 2346...
2190
#
2346
#
2191
# Returns         : 
2347
# Returns         : 
2192
#
2348
#
2193
sub endPackage
2349
sub endPackage
2194
{
2350
{
-
 
2351
    Message ("-- Import Summary ------------------------------------------------" );
2195
    RmDirTree ('SvnImportDir');
2352
    RmDirTree ('SvnImportDir');
2196
 
2353
 
2197
    #
2354
    #
2198
    #   Display versions that did get captured
2355
    #   Display versions that did get captured
2199
    #
2356
    #
Line 2209... Line 2366...
2209
    #
2366
    #
2210
    foreach my $entry ( @processOrder )
2367
    foreach my $entry ( @processOrder )
2211
    {
2368
    {
2212
        $versions{$entry}{Scanned} = 1;
2369
        $versions{$entry}{Scanned} = 1;
2213
        next if ( $versions{$entry}{TagCreated} );
2370
        next if ( $versions{$entry}{TagCreated} );
-
 
2371
        my $reason = $versions{$entry}{data}{errStr} || '';
-
 
2372
        my $tag = $versions{$entry}{vcsTag}|| 'No Tag';
2214
        Warning ("Not Processed: " . GetVname($entry) );
2373
        Warning ("Not Processed: " . GetVname($entry) . ':' . $tag . ' : ' . $reason );
2215
    }
2374
    }
2216
 
2375
 
2217
    foreach my $entry ( keys(%versions) )
2376
    foreach my $entry ( keys(%versions) )
2218
    {
2377
    {
2219
        next if ( $versions{$entry}{Scanned} );
2378
        next if ( $versions{$entry}{Scanned} );
2220
        Warning ("(E) INTERNAL ERROR. Package Not Processed: " . GetVname($entry) );
2379
        Warning ("(E) INTERNAL ERROR. Package Not Processed: " . GetVname($entry) );
2221
    }
2380
    }
2222
 
2381
 
-
 
2382
    Message ("Packages Relabled: $packageReLabelCount") if ( $packageReLabelCount );
2223
    Message ("All Done");
2383
    Message ("All Done");
2224
}
2384
}
2225
 
2385
 
2226
#-------------------------------------------------------------------------------
2386
#-------------------------------------------------------------------------------
-
 
2387
# Function        : extractFilesFromClearCase
-
 
2388
#
-
 
2389
# Description     : Extract files from ClearCase
-
 
2390
#                   May take a while as we handle nasty errors
-
 
2391
#
-
 
2392
# Inputs          : $data           - Hash of good stuff from newPackageVersionBody
-
 
2393
#                   $cc_path
-
 
2394
#                   $cc_label
-
 
2395
#
-
 
2396
# Returns         : exit code
-
 
2397
#                   Sets up
-
 
2398
#                       $data->{errStr}
-
 
2399
#                       $data->{errCode}
-
 
2400
#                   As per newPackageVersionBody
-
 
2401
#
-
 
2402
sub extractFilesFromClearCase
-
 
2403
{
-
 
2404
    my ($data, $cc_path, $cc_label) = @_;
-
 
2405
    my $tryCount = 0;
-
 
2406
    my $rv = 99;
-
 
2407
 
-
 
2408
    $data->{ViewRoot} = $opt_name ? $opt_name : "$cc_label";
-
 
2409
    $data->{ViewPath} =  $data->{ViewRoot} . $cc_path;
-
 
2410
    
-
 
2411
    if ( $opt_preserveProjectBase )
-
 
2412
    {
-
 
2413
        my $cc_vob = $cc_path;
-
 
2414
        $cc_vob =~ s~^/~~;
-
 
2415
        $cc_vob =~ s~/.*~~;
-
 
2416
        $data->{ViewPath} =  $data->{ViewRoot} . '/' . $cc_vob;
-
 
2417
        Message ("Preserving Project Base");
-
 
2418
    }
-
 
2419
    $data->{ViewPath} =~  tr~/~/~s;
-
 
2420
 
-
 
2421
    if ( $opt_reuse && -d $data->{ViewPath}  )
-
 
2422
    {
-
 
2423
        Message ("Reusing view: $cc_label");
-
 
2424
        return 0;
-
 
2425
    }
-
 
2426
 
-
 
2427
    while ( $rv == 99 ) {
-
 
2428
        my @args;
-
 
2429
        push (@args, '-view', $opt_name ) if ( defined $opt_name );
-
 
2430
        $rv = JatsToolPrint ( 'jats_ccrelease', '-extractfiles', '-root=.' , '-noprefix',
-
 
2431
                    "-label=$cc_label" ,
-
 
2432
                    "-path=$cc_path",
-
 
2433
                    @args
-
 
2434
                    );
-
 
2435
 
-
 
2436
        if ( $rv == 10 ) {
-
 
2437
 
-
 
2438
            #
-
 
2439
            #   No files found
-
 
2440
            #   If this is the first time then try really hard to find them
-
 
2441
            #
-
 
2442
            unless ( $tryCount++ )
-
 
2443
            {
-
 
2444
                if ( $opt_relabel )
-
 
2445
                {
-
 
2446
                    $packageReLabelCount++;
-
 
2447
                    $rv = JatsToolPrint('cc2svn_labeldirs',
-
 
2448
                                            '-vob', $cc_path,
-
 
2449
                                            $cc_label,
-
 
2450
                                            );
-
 
2451
                    $data->{DirsLabled} = 100 + $rv;
-
 
2452
                }
-
 
2453
 
-
 
2454
                #
-
 
2455
                #   Second attempt - massage the users path
-
 
2456
                #   We should have labled up to the VOB root so lets
-
 
2457
                #   just use the VOB and not the path
-
 
2458
                #
-
 
2459
                #   If we are not relabeling then we can still do this
-
 
2460
                #   in an attempt to fix user stupidity
-
 
2461
                #
-
 
2462
                $cc_path =~ s~^/~~;
-
 
2463
                $cc_path =~ s~/.*~~;
-
 
2464
                $cc_path = '/' . $cc_path;
-
 
2465
                $data->{ViewPath} =  $data->{ViewRoot} . $cc_path;
-
 
2466
                redo;
-
 
2467
            }
-
 
2468
 
-
 
2469
            $data->{errStr}  = 'No Files in the extracted view';
-
 
2470
            $data->{errCode} = '0';
-
 
2471
            return 2;
-
 
2472
        }
-
 
2473
        elsif ( $rv == 11 ) {
-
 
2474
            $data->{errStr} = 'Label not found';
-
 
2475
            $data->{errCode} = 'L';
-
 
2476
            return 2;
-
 
2477
        }
-
 
2478
 
-
 
2479
        unless ( -d $data->{ViewPath}  )
-
 
2480
        {
-
 
2481
            $data->{errStr} = 'Failed to extract files from CC';
-
 
2482
            return 2;
-
 
2483
        }
-
 
2484
 
-
 
2485
        #
-
 
2486
        #   Looks good
-
 
2487
        #
-
 
2488
        return 0;
-
 
2489
    };
-
 
2490
 
-
 
2491
    $data->{errStr}  = 'No Files in the extracted view after labeling dirs';
-
 
2492
    $data->{errCode} = '0';
-
 
2493
    return 2;
-
 
2494
 
-
 
2495
}
-
 
2496
 
-
 
2497
#-------------------------------------------------------------------------------
-
 
2498
# Function        : detectMakeProjectUsage
-
 
2499
#
-
 
2500
# Description     : etect and report usage of the MakeProject directive
-
 
2501
#
-
 
2502
# Inputs          : $data               - Ref to a hash of bits
-
 
2503
#                   $cc_path            - Packages cc_path
-
 
2504
#
-
 
2505
# Returns         : true    - Bad usage (Really good usage not detected)
-
 
2506
#                   false   - Good usage detected
-
 
2507
#
-
 
2508
sub detectMakeProjectUsage
-
 
2509
{
-
 
2510
    my ($data, $cc_path) = @_;
-
 
2511
    my $retval = 0;
-
 
2512
    my $eSuf = $opt_ignoreMakeProjectErrors ? '' : 'Error';
-
 
2513
 
-
 
2514
    #
-
 
2515
    #   Find makefile.pl
-
 
2516
    #
-
 
2517
    Message ("Locate JATS makefiles");
-
 
2518
    my $usesMakeProject = 0;
-
 
2519
    my $badIncludeFile = 0;
-
 
2520
 
-
 
2521
    my $search = JatsLocateFiles->new("--Recurse=1",
-
 
2522
                                       "--FilterIn=makefile.pl",
-
 
2523
                                       );
-
 
2524
    my @makefiles = $search->search($data->{ViewRoot});
-
 
2525
    foreach my $file ( @makefiles )
-
 
2526
    {
-
 
2527
#print "---Reading: $workDir/$data->{ViewRoot}/$file\n";
-
 
2528
        if ( open( my $fh, '<', "$data->{ViewRoot}/$file" ) )
-
 
2529
        {
-
 
2530
            my $eof = 0;
-
 
2531
            my $line = '';
-
 
2532
            until ( $eof )
-
 
2533
            {
-
 
2534
                my $in = <$fh>;
-
 
2535
                unless ( defined $in )
-
 
2536
                {
-
 
2537
                    $eof = 1;
-
 
2538
                }
-
 
2539
                else
-
 
2540
                {
-
 
2541
                $in =~ s~\s+$~~;
-
 
2542
                $in =~ s~^\s+~~;
-
 
2543
                $in =~ s~^#.*$~~;
-
 
2544
                $in =~ s~\s*[^\$]#.*$~~;
-
 
2545
                $line .= ' ' if ( $line );
-
 
2546
                $line .= $in;
-
 
2547
                $line =~ s~\s+~ ~g;
-
 
2548
#print "====== '$line'\n";
-
 
2549
                redo unless ( $line =~ m~;$~  );
-
 
2550
                }
-
 
2551
#print "---- $line\n";
-
 
2552
                if ( $line =~ m~^MakeProject~ )
-
 
2553
                {
-
 
2554
                    $usesMakeProject++;
-
 
2555
                    $data->{UsesMakeProject}++;
-
 
2556
                    Warning ("Package uses MakeProject:",
-
 
2557
                             "Line: " . $line,
-
 
2558
                             "Root: " . "$data->{ViewRoot}",
-
 
2559
                             "File: " . "$data->{ViewRoot}/$file",
-
 
2560
                            );
-
 
2561
 
-
 
2562
                    #
-
 
2563
                    #   Extract out the project name
-
 
2564
                    #
-
 
2565
                    my @myArgs;
-
 
2566
                    my $myProjectDir;
-
 
2567
                    my $myProject = "$data->{ViewRoot}/$file";
-
 
2568
                    $myProject =~ s~/[^/]+$~~;
-
 
2569
                    $line =~ s~MakeProject~push \@myArgs,~;
-
 
2570
                    eval $line;
-
 
2571
                    Error("Line did not compiler: $line", "Err: $@" ) if ($@);
-
 
2572
                    shift @myArgs;
-
 
2573
                    foreach ( @myArgs )
-
 
2574
                    {
-
 
2575
                        next if ( m~^--~ );
-
 
2576
                        $myProject .= '/' . $_;
-
 
2577
                        $myProjectDir = $myProject;
-
 
2578
                        $myProjectDir =~ s~/[^/]+$~~;
-
 
2579
                        last;
-
 
2580
                    }
-
 
2581
                    Error ("No project Found") unless ( defined $myProjectDir);
-
 
2582
                    if ( -f "$myProjectDir/include.txt" )
-
 
2583
                    {
-
 
2584
                        Warning ("Co-located 'include.txt' file also found");
-
 
2585
                    }
-
 
2586
 
-
 
2587
                    # The only problem is if the include.txt file
-
 
2588
                    # escapes from the VOB - or even uses the vob root
-
 
2589
                    #
-
 
2590
                    # Examine the include file
-
 
2591
                    # Expect it to look like
-
 
2592
                    #   /I Path
-
 
2593
                    #
-
 
2594
 
-
 
2595
                    #
-
 
2596
                    #   Determine safe level
-
 
2597
                    #   Relative to the include file
-
 
2598
                    #
-
 
2599
                    my $depthPath = $myProjectDir;
-
 
2600
                    my $depth = 0;
-
 
2601
                    Error ("Expect this to work") unless ( $depthPath =~ s~^$data->{ViewRoot}/~~ );
-
 
2602
                    foreach ( split('/', $depthPath) )
-
 
2603
                    {
-
 
2604
                        if ( $_ eq '..' ) {
-
 
2605
                            $depth--;
-
 
2606
                        } else {
-
 
2607
                            $depth++;
-
 
2608
                        }
-
 
2609
                    }
-
 
2610
#print "Depth: $depth, $depthPath\n";
-
 
2611
 
-
 
2612
                    if ( open( my $if, '<', "$myProjectDir/include.txt" ) )
-
 
2613
                    {
-
 
2614
                        while ( <$if> )
-
 
2615
                        {
-
 
2616
                            s~\s+$~~;
-
 
2617
                            s~^\s+~~;
-
 
2618
                            next unless ( $_ );
-
 
2619
                            if ( m~/I\s+(.*)~ )
-
 
2620
                            {
-
 
2621
                                my $path = $1;
-
 
2622
                                $path =~ tr~\\/~/~s;
-
 
2623
                                $path =~ s~\\~/~g;
-
 
2624
#print "Examine: $path\n";
-
 
2625
                                my $minLevel = 0;
-
 
2626
                                my $level = 0;
-
 
2627
                                foreach ( split('/', $path) )
-
 
2628
                                {
-
 
2629
                                    if ( $_ eq '..' )
-
 
2630
                                    {
-
 
2631
                                        $level--;
-
 
2632
                                        $minLevel = $level if ($level < $minLevel);
-
 
2633
                                    }
-
 
2634
                                    else
-
 
2635
                                    {
-
 
2636
                                        $level++;
-
 
2637
                                    }
-
 
2638
                                }
-
 
2639
#print "Min: $minLevel, $level, ($depth + $minLevel)\n";
-
 
2640
                                if ( $depth + $minLevel <= 0)
-
 
2641
                                {
-
 
2642
                                    $badIncludeFile++;
-
 
2643
                                    Warning ("Included path escapes package:",
-
 
2644
                                             "Line: " . $_,
-
 
2645
                                             "File: " . "$myProjectDir/include.txt",
-
 
2646
                                            );
-
 
2647
                                    last;
-
 
2648
                                }
-
 
2649
                            }
-
 
2650
                        }
-
 
2651
                        close $if;
-
 
2652
                    }
-
 
2653
 
-
 
2654
                }
-
 
2655
                $line = '';
-
 
2656
            }
-
 
2657
            close $fh;
-
 
2658
        }
-
 
2659
        else
-
 
2660
        {
-
 
2661
            Warning ("MakeProject$eSuf - Cannot open makefile: $file");
-
 
2662
            $retval = 1;
-
 
2663
        }
-
 
2664
    }
-
 
2665
 
-
 
2666
    #
-
 
2667
    #   Used
-
 
2668
    #   May be improved latter
-
 
2669
    #
-
 
2670
    if ( $usesMakeProject && $badIncludeFile)
-
 
2671
    {
-
 
2672
        Warning ("MakeProject$eSuf - Problem detected");
-
 
2673
        $retval = 1;
-
 
2674
    }
-
 
2675
 
-
 
2676
    #
-
 
2677
    #   Until we have more faith in the detection algorithm
-
 
2678
    #
-
 
2679
    if ( $usesMakeProject )
-
 
2680
    {
-
 
2681
        Warning ("MakeProject$eSuf - Makeproject used. Must check manually");
-
 
2682
        $retval = 1;
-
 
2683
    }
-
 
2684
    
-
 
2685
    return $retval;
-
 
2686
}
-
 
2687
 
-
 
2688
#-------------------------------------------------------------------------------
2227
# Function        : detectProjectBaseUsage
2689
# Function        : detectProjectBaseUsage
2228
#
2690
#
2229
# Description     : Detect and report usage of the SetProjectBase directive
2691
# Description     : Detect and report usage of the SetProjectBase directive
2230
#
2692
#
2231
# Inputs          : $data               - Ref to a hash of bits
2693
# Inputs          : $data               - Ref to a hash of bits
Line 2380... Line 2842...
2380
 
2842
 
2381
#-------------------------------------------------------------------------------
2843
#-------------------------------------------------------------------------------
2382
# Function        : findDirWithStuff
2844
# Function        : findDirWithStuff
2383
#
2845
#
2384
# Description     : Find a directory that contains more than just another subdir
2846
# Description     : Find a directory that contains more than just another subdir
-
 
2847
#                   Note: don't use 'glob' it doesn't work if the name has a space in it.
2385
#
2848
#
2386
# Inputs          : $base               - Start of the scan
2849
# Inputs          : $base               - Start of the scan
2387
#
2850
#
2388
# Returns         : Path to dir with more than just a single dir in it
2851
# Returns         : Path to dir with more than just a single dir in it
2389
#
2852
#
Line 2395... Line 2858...
2395
    {
2858
    {
2396
    my $fileCount = 0;
2859
    my $fileCount = 0;
2397
    my $dirCount = 0;
2860
    my $dirCount = 0;
2398
    my $firstDir;
2861
    my $firstDir;
2399
 
2862
 
-
 
2863
    opendir (my $dh, $base ) || Error ("Cannot opendir $base. $!");
2400
    my @list = glob( $base . '/*');
2864
    my @list =readdir $dh;
-
 
2865
    closedir $dh;
2401
    foreach ( @list )
2866
    foreach ( @list )
2402
    {
2867
    {
2403
        next if ( $_ eq '.' );
2868
        next if ( $_ eq '.' );
2404
        next if ( $_ eq '..' );
2869
        next if ( $_ eq '..' );
-
 
2870
 
-
 
2871
        $_ = $base . '/' . $_;
2405
        if ( -d $_ )
2872
        if ( -d $_ )
2406
        {
2873
        {
2407
            $dirCount++;
2874
            $dirCount++;
2408
            $firstDir = $_ unless ( defined $firstDir );
2875
            $firstDir = $_ unless ( defined $firstDir );
-
 
2876
            return $base
2409
            return $base if ( $dirCount > 1  );
2877
                if ( $dirCount > 1  )
2410
        }
2878
        }
2411
        elsif ( -e $_ )
2879
        elsif ( -e $_ )
2412
        {
2880
        {
2413
            return $base;
2881
            return $base;
2414
        }
2882
        }
2415
 
2883
 
2416
        # else its probably a dead symlink
2884
        # else its probably a dead symlink
2417
    }
2885
    }
-
 
2886
 
-
 
2887
    return $base
2418
    return $base unless ( $dirCount == 1  );
2888
        unless ( $dirCount == 1  );
2419
    $base = $firstDir;
2889
    $base = $firstDir;
2420
    }
2890
    }
2421
}
2891
}
2422
 
2892
 
2423
 
-
 
2424
#-------------------------------------------------------------------------------
2893
#-------------------------------------------------------------------------------
2425
# Function        : JatsToolPrint
2894
# Function        : JatsToolPrint
2426
#
2895
#
2427
# Description     : Print and Execuate a JatsTool command
2896
# Description     : Print and Execuate a JatsTool command
2428
#
2897
#
Line 2450... Line 2919...
2450
        }
2919
        }
2451
    }
2920
    }
2452
    return $me;
2921
    return $me;
2453
}
2922
}
2454
 
2923
 
-
 
2924
#-------------------------------------------------------------------------------
-
 
2925
# Function        : saneLabel
-
 
2926
#
-
 
2927
# Description     : Generate a sane version label
-
 
2928
#                   Handle suplicates (due to character squishing)
-
 
2929
#                   Cache results for repeatability
-
 
2930
#
-
 
2931
# Inputs          : $entry          - Version info
-
 
2932
#                   $pkgname        - Alternate pkgname (branching)
-
 
2933
#
-
 
2934
# Returns         : Sane string
-
 
2935
#
2455
sub saneLabel
2936
sub saneLabel
2456
{
2937
{
2457
    my ($entry, $pkgname) = @_;
2938
    my ($entry, $pkgname) = @_;
2458
    my $me;
2939
    my $me;
2459
    $me = $versions{$entry}{vname};
2940
    $me = $versions{$entry}{vname};
2460
    $pkgname = $versions{$entry}{name} unless ( defined $pkgname );
2941
    $pkgname = $versions{$entry}{name} unless ( defined $pkgname );
2461
 
2942
 
-
 
2943
    #
-
 
2944
    #   If we have calculated it, then reuse it.
-
 
2945
    #
-
 
2946
    if ( exists $versions{$entry}{saneLabel}{$pkgname} )
-
 
2947
    {
-
 
2948
        return $versions{$entry}{saneLabel}{$pkgname};
-
 
2949
    }
-
 
2950
 
-
 
2951
 
2462
    Error ("Package does have a version string: pvid: $entry")
2952
    Error ("Package does have a version string: pvid: $entry")
2463
        unless ( defined $me );
2953
        unless ( defined $me );
2464
 
2954
 
2465
    #
2955
    #
2466
    #   Convert Wip format (xxxx) into a string that can be used for a label
2956
    #   Convert Wip format (xxxx) into a string that can be used for a label
Line 2480... Line 2970...
2480
    $me = $pkgname . '_' . $me;
2970
    $me = $pkgname . '_' . $me;
2481
    $me =~ tr~ ~-~s;
2971
    $me =~ tr~ ~-~s;
2482
    $me =~ tr~-~-~s;
2972
    $me =~ tr~-~-~s;
2483
    $me =~ tr~_~_~s;
2973
    $me =~ tr~_~_~s;
2484
 
2974
 
-
 
2975
    #
-
 
2976
    #   Due to some sillyness ( package version starting with _ )
-
 
2977
    #   we may get duplicates. Detect and allocate different numbers
-
 
2978
    #
-
 
2979
    if ( exists $saneLabels{$me} )
-
 
2980
    {
-
 
2981
        $saneLabels{$me}++;
-
 
2982
        $me = $me . '.' . $saneLabels{$me};
-
 
2983
        Message ("Duplicate SaneLabel resolved as: $me");
-
 
2984
    }
-
 
2985
    else
-
 
2986
    {
-
 
2987
        $saneLabels{$me} = 0;
-
 
2988
    }
-
 
2989
 
-
 
2990
    #
-
 
2991
    #   Cache value
-
 
2992
    #
-
 
2993
    $versions{$entry}{saneLabel}{$pkgname} = $me;
2485
    return $me;
2994
    return $me;
2486
}
2995
}
2487
 
2996
 
2488
sub saneString
2997
sub saneString
2489
{
2998
{
Line 2586... Line 3095...
2586
    connectRM(\$RM_DB) unless ( $RM_DB );
3095
    connectRM(\$RM_DB) unless ( $RM_DB );
2587
 
3096
 
2588
    #
3097
    #
2589
    #   Extract data from Release Manager
3098
    #   Extract data from Release Manager
2590
    #
3099
    #
-
 
3100
    my $m_sqlstr = "SELECT " .
-
 
3101
                       "pkg.PKG_NAME, " .                                       # row[0]
-
 
3102
                       "pv.PKG_VERSION, " .                                     # row[1]
-
 
3103
                       "pkg.PKG_ID, " .                                         # row[2]
-
 
3104
                       "pv.PV_ID, " .                                           # row[3]
-
 
3105
                       "pv.LAST_PV_ID, " .                                      # row[4]
-
 
3106
                       "pv.MODIFIED_STAMP, " .                                  # row[5]
2591
    my $m_sqlstr = "SELECT pkg.PKG_NAME, pv.PKG_VERSION, pkg.PKG_ID, pv.PV_ID, pv.LAST_PV_ID, pv.MODIFIED_STAMP, release_manager.PK_RMAPI.return_vcs_tag(pv.PV_ID), amu.USER_NAME, pv.COMMENTS, pv.DLOCKED, pv.CREATOR_ID ".
3107
                       "release_manager.PK_RMAPI.return_vcs_tag(pv.PV_ID), " .  # row[6]
2592
                   " FROM RELEASE_MANAGER.PACKAGES pkg, RELEASE_MANAGER.PACKAGE_VERSIONS pv, ACCESS_MANAGER.USERS amu" .
3108
                       "amu.USER_NAME, " .                                      # row[7]
-
 
3109
                       "pv.COMMENTS, " .                                        # row[8]
-
 
3110
                       "pv.DLOCKED, " .                                         # row[9]
-
 
3111
                       "pv.CREATOR_ID, ".                                       # row[10]
2593
                   " WHERE pv.PKG_ID = \'$pkg_id\' AND pkg.PKG_ID = pv.PKG_ID AND amu.USER_ID (+) = pv.CREATOR_ID";
3112
                       "pv.BUILD_TYPE ".                                        # row[11]
2594
                   
3113
                   " FROM " .
-
 
3114
                        "RELEASE_MANAGER.PACKAGES pkg, " .
-
 
3115
                        "RELEASE_MANAGER.PACKAGE_VERSIONS pv, " .
-
 
3116
                        "ACCESS_MANAGER.USERS amu" .
2595
                   
3117
                   " WHERE " .
-
 
3118
                        "pv.PKG_ID = \'$pkg_id\' " .
-
 
3119
                        "AND pkg.PKG_ID = pv.PKG_ID " .
-
 
3120
                        "AND amu.USER_ID (+) = pv.CREATOR_ID";
-
 
3121
 
2596
    my $sth = $RM_DB->prepare($m_sqlstr);
3122
    my $sth = $RM_DB->prepare($m_sqlstr);
2597
    if ( defined($sth) )
3123
    if ( defined($sth) )
2598
    {
3124
    {
2599
        if ( $sth->execute( ) )
3125
        if ( $sth->execute( ) )
2600
        {
3126
        {
Line 2613... Line 3139...
2613
                    my $vcstag =  $row[6] || 'Unknown';
3139
                    my $vcstag =  $row[6] || 'Unknown';
2614
 
3140
 
2615
                    my $created_id =  $row[7] || ($row[10] ? "Userid_$row[10]" :'Unknown');
3141
                    my $created_id =  $row[7] || ($row[10] ? "Userid_$row[10]" :'Unknown');
2616
                    my $comment =  $row[8] || '';
3142
                    my $comment =  $row[8] || '';
2617
                    my $locked =  $row[9] || 'N';
3143
                    my $locked =  $row[9] || 'N';
-
 
3144
                    my $manual = $row[11] || 'M';
2618
 
3145
 
2619
                    #
3146
                    #
2620
                    #   Some developers have a 'special' package version
3147
                    #   Some developers have a 'special' package version
2621
                    #   We really need to ignore them
3148
                    #   We really need to ignore them
2622
                    #
3149
                    #
Line 2636... Line 3163...
2636
                    $versions{$pv_id}{comment} = $comment;
3163
                    $versions{$pv_id}{comment} = $comment;
2637
                    $versions{$pv_id}{locked} = $locked;
3164
                    $versions{$pv_id}{locked} = $locked;
2638
                    $versions{$pv_id}{TimeStamp} = str2time( $created );
3165
                    $versions{$pv_id}{TimeStamp} = str2time( $created );
2639
                    $versions{$pv_id}{Age} = ($now - $versions{$pv_id}{TimeStamp}) / (60 * 60 * 24);
3166
                    $versions{$pv_id}{Age} = ($now - $versions{$pv_id}{TimeStamp}) / (60 * 60 * 24);
2640
                    $versions{$pv_id}{TooOld} = 1 if ( $opt_age && $opt_age <= $versions{$pv_id}{Age} );
3167
                    $versions{$pv_id}{TooOld} = 1 if ( $opt_age && $opt_age <= $versions{$pv_id}{Age} );
-
 
3168
                    $versions{$pv_id}{BuildType} = $manual;
2641
                    examineVcsTag($pv_id);
3169
                    examineVcsTag($pv_id);
2642
 
3170
 
2643
                    #
3171
                    #
2644
                    #   Process version number
3172
                    #   Process version number
2645
                    #
3173
                    #
2646
                    my ($suffix, $version, $isaR, $isaWip, $buildVersion ) = massageVersion($pkg_ver, $pkg_name);
3174
                    my ($suffix, $version, $isaR, $isaWip, $buildVersion ) = massageVersion($pkg_ver, $pkg_name);
2647
 
3175
 
2648
                    $versions{$pv_id}{version} = $version;
3176
                    $versions{$pv_id}{version} = $version;
2649
                    $versions{$pv_id}{buildVersion} = $buildVersion;
3177
                    $versions{$pv_id}{buildVersion} = $buildVersion;
2650
                    $versions{$pv_id}{isaRipple} = 1 if ( $isaR );
-
 
2651
                    $versions{$pv_id}{isaWip} = 1 if ( $isaWip );
3178
                    $versions{$pv_id}{isaWip} = 1 if ( $isaWip );
2652
 
3179
 
2653
                    #
3180
                    #
-
 
3181
                    #   New methof for detecting a ripple
-
 
3182
                    #       Don't look at the version number
-
 
3183
                    #       Use RM data
-
 
3184
                    #       Inlude the comment - there are some cases where the comment
-
 
3185
                    #       appears to have been user modified.
-
 
3186
                    #
-
 
3187
#                    $versions{$pv_id}{isaRipple} = 1 if ( $isaR );
-
 
3188
#                    $versions{$pv_id}{isaRipple} = 1 if ( uc($manual) eq 'Y' );
-
 
3189
                    $versions{$pv_id}{isaRipple} = ( $comment =~ m~^Rippled Build~i && ( uc($manual) eq 'Y' ));
-
 
3190
 
-
 
3191
                    #
2654
                    #   Process suffix
3192
                    #   Process suffix
2655
                    #
3193
                    #
2656
                    $suffix = 'Unknown' unless ( $suffix );
3194
                    $suffix = 'Unknown' unless ( $suffix );
2657
                    $suffix = lc ($suffix);
3195
                    $suffix = lc ($suffix);
2658
                    $versions{$pv_id}{suffix} = $suffix;
3196
                    $versions{$pv_id}{suffix} = $suffix;
Line 2912... Line 3450...
2912
{
3450
{
2913
    my ($tag) = @_;
3451
    my ($tag) = @_;
2914
    $tag =~ tr~\\/~/~;
3452
    $tag =~ tr~\\/~/~;
2915
    if ( $tag =~ m~^CC::~ )
3453
    if ( $tag =~ m~^CC::~ )
2916
    {
3454
    {
2917
        $tag =~ s~CC::\s+~CC::~;
3455
        $tag =~ s~CC::load\s+~CC::~;                # Load rule
-
 
3456
        $tag =~ s~CC::\s+~CC::~;                    # Leading white space
-
 
3457
        $tag =~ s~CC::[A-Za-z]\:/~CC::/~;           # Leading driver letter
-
 
3458
        $tag =~ s~CC::/+~CC::/~;                    # Multiple initial /'s
2918
        $tag =~ s~/build.pl::~::~i;
3459
        $tag =~ s~/build.pl::~::~i;
2919
        $tag =~ s~/src::~::~i;
3460
        $tag =~ s~/src::~::~i;
2920
        $tag =~ s~MASS_Dev_Bus/Cbp/~MASS_Dev_Bus/CBP/~i;
3461
        $tag =~ s~MASS_Dev_Bus/Cbp/~MASS_Dev_Bus/CBP/~i;
2921
        $tag =~ s~MASS_Dev_Bus~MASS_Dev_Bus~i;
3462
        $tag =~ s~MASS_Dev_Bus~MASS_Dev_Bus~i;
2922
        $tag =~ s~/MASS_Dev/Infra~MASS_Dev_Infra~i;
3463
        $tag =~ s~/MASS_Dev/Infra~MASS_Dev_Infra~i;
Line 3093... Line 3634...
3093
            push @text, '|';
3634
            push @text, '|';
3094
            push @text, 'Subversion';
3635
            push @text, 'Subversion';
3095
            push @text, 'Trunk used' if exists $svnData{branches}{trunk} ;
3636
            push @text, 'Trunk used' if exists $svnData{branches}{trunk} ;
3096
            push @text, 'Labels: ' . scalar keys %{$svnData{tags}} ;
3637
            push @text, 'Labels: ' . scalar keys %{$svnData{tags}} ;
3097
            push @text, 'Branches: ' . scalar keys %{$svnData{branches}} ;
3638
            push @text, 'Branches: ' . scalar keys %{$svnData{branches}} ;
-
 
3639
            push @text, 'Relabled Packages : ' . $packageReLabelCount;
3098
        }
3640
        }
3099
 
3641
 
3100
        push @text, '';
3642
        push @text, '';
3101
        my $text = join '\l', @text;
3643
        my $text = join '\l', @text;
3102
        $text =~ s~\|\\l~|~g;
3644
        $text =~ s~\|\\l~|~g;
Line 3129... Line 3671...
3129
        push @text, '|{N: Not Locked';
3671
        push @text, '|{N: Not Locked';
3130
        push @text, 'b: Bad Singleton';
3672
        push @text, 'b: Bad Singleton';
3131
        push @text, 'B: Bad VCS Tag';
3673
        push @text, 'B: Bad VCS Tag';
3132
        push @text, 'D: DeadWood';
3674
        push @text, 'D: DeadWood';
3133
        push @text, 'E: Essential Release Version';
3675
        push @text, 'E: Essential Release Version';
-
 
3676
        push @text, 'F: Package directories labled';
3134
        push @text, 'G: Glued into Version Tree';
3677
        push @text, 'G: Glued into Version Tree';
-
 
3678
        push @text, 'L: Label not in VOB';
3135
        push @text, 'r: Recent version';
3679
        push @text, 'r: Recent version';
3136
        push @text, 'R: Ripple';
3680
        push @text, 'R: Ripple';
3137
        push @text, 'S: Splitpoint';
3681
        push @text, 'S: Splitpoint';
3138
        push @text, 't: Glued into Project Tree';
3682
        push @text, 't: Glued into Project Tree';
3139
        push @text, 'T: Tip version';
3683
        push @text, 'T: Tip version';
3140
        push @text, 'V: In SVN';
3684
        push @text, 'V: In SVN';
3141
        push @text, '+: In Subversion';
3685
        push @text, '+: In Subversion';
-
 
3686
        push @text, '0: Zero files extracted';
3142
        push @text, '}}';
3687
        push @text, '}}';
3143
 
3688
 
3144
        push @text, '|';
3689
        push @text, '|';
3145
        push @text, 'Outline';
3690
        push @text, 'Outline';
3146
        push @text, 'Red: Dead or Bad VCS Tag';
3691
        push @text, 'Red: Dead or Bad VCS Tag';
3147
        push @text, 'Orange: Project Branch Root';
3692
        push @text, 'Orange: Project Branch Root';
3148
        push @text, 'Green: Ripple Build Version';
3693
        push @text, 'Green: Ripple Build Version';
3149
        push @text, 'Blue: Essential Version';
3694
        push @text, 'Blue: Essential Version';
3150
        push @text, 'Darkmagenta: Entry Glued into tree';
3695
        push @text, 'Darkmagenta: Entry Glued into tree';
3151
        push @text, 'Magenta: Entry added to project tree';
3696
        push @text, 'Magenta: Entry added to project tree';
-
 
3697
        push @text, 'DeepPink: Label not in VOB';
-
 
3698
        push @text, 'DarkViolet: Zero files extracted';
3152
 
3699
 
3153
 
3700
 
3154
        push @text, '|';
3701
        push @text, '|';
3155
        push @text, 'Fill';
3702
        push @text, 'Fill';
3156
        push @text, 'PowderBlue: Essential Version';
3703
        push @text, 'PowderBlue: Essential Version';
Line 3209... Line 3756...
3209
        $stateText .= 'r' if (exists $versions{$entry}{keepRecent} && $versions{$entry}{keepRecent} );
3756
        $stateText .= 'r' if (exists $versions{$entry}{keepRecent} && $versions{$entry}{keepRecent} );
3210
        $stateText .= 'S' if (exists $versions{$entry}{EssentialSplitPoint} && $versions{$entry}{EssentialSplitPoint} > 1 );
3757
        $stateText .= 'S' if (exists $versions{$entry}{EssentialSplitPoint} && $versions{$entry}{EssentialSplitPoint} > 1 );
3211
        $stateText .= 'T' if (exists $versions{$entry}{Tip} );
3758
        $stateText .= 'T' if (exists $versions{$entry}{Tip} );
3212
        $stateText .= 'V' if (exists $versions{$entry}{isSvn} );
3759
        $stateText .= 'V' if (exists $versions{$entry}{isSvn} );
3213
        $stateText .= '+' if (exists $versions{$entry}{svnVersion} );
3760
        $stateText .= '+' if (exists $versions{$entry}{svnVersion} );
-
 
3761
        $stateText .= '0' if (exists $versions{$entry}{data}{errCode} && $versions{$entry}{data}{errCode} eq '0');
-
 
3762
        $stateText .= 'L' if (exists $versions{$entry}{data}{errCode} && $versions{$entry}{data}{errCode} eq 'L');
-
 
3763
        $stateText .= 'F' if ($versions{$entry}{data}{DirsLabled});
-
 
3764
 
-
 
3765
 
3214
#        $stateText .= 's' if (exists $versions{$entry}{branchPoint} );
3766
#        $stateText .= 's' if (exists $versions{$entry}{branchPoint} );
3215
#        $stateText .= ' T='. $versions{$entry}{threadId} if (exists $versions{$entry}{threadId});
3767
#        $stateText .= ' T='. $versions{$entry}{threadId} if (exists $versions{$entry}{threadId});
3216
#        $stateText .= ' EssentalPath' if (exists $versions{$entry}{EssentialPath});
3768
#        $stateText .= ' EssentalPath' if (exists $versions{$entry}{EssentialPath});
3217
#        $stateText .= ' Count='. $versions{$entry}{EssentialSplitPoint} if (exists $versions{$entry}{EssentialSplitPoint});
3769
#        $stateText .= ' Count='. $versions{$entry}{EssentialSplitPoint} if (exists $versions{$entry}{EssentialSplitPoint});
3218
#        $stateText .= ' M='. $versions{$entry}{maxVersion} if (exists $versions{$entry}{maxVersion});
3770
#        $stateText .= ' M='. $versions{$entry}{maxVersion} if (exists $versions{$entry}{maxVersion});
3219
 
3771
 
3220
        push @label, "(${stateText})" if ( $stateText );
3772
        push @label, "(${stateText})" if ( length($stateText) );
3221
 
3773
 
3222
##       Insert Release Names
3774
##       Insert Release Names
3223
        foreach my $rtag_id ( keys %{$versions{$entry}{Releases}}  ) {
3775
        foreach my $rtag_id ( keys %{$versions{$entry}{Releases}}  ) {
3224
            next unless ( exists $ukHopsReleases{$rtag_id} );
3776
            next unless ( exists $ukHopsReleases{$rtag_id} );
3225
            push @label, "Release: $versions{$entry}{Releases}{$rtag_id}{rname}";
3777
            push @label, "Release: $versions{$entry}{Releases}{$rtag_id}{rname}";
Line 3250... Line 3802...
3250
           $color = 'color=orange style=bold' if ( $versions{$entry}{newSuffix} );
3802
           $color = 'color=orange style=bold' if ( $versions{$entry}{newSuffix} );
3251
           $color = 'color=red style=bold' if ( $versions{$entry}{DeadWood} || $versions{$entry}{badVcsTag} );
3803
           $color = 'color=red style=bold' if ( $versions{$entry}{DeadWood} || $versions{$entry}{badVcsTag} );
3252
           $color = 'color=blue style=bold' if ( $versions{$entry}{Essential} );
3804
           $color = 'color=blue style=bold' if ( $versions{$entry}{Essential} );
3253
           $color = 'color=darkmagenta style=bold' if ( $versions{$entry}{GluedIn} );
3805
           $color = 'color=darkmagenta style=bold' if ( $versions{$entry}{GluedIn} );
3254
           $color = 'color=magenta style=bold' if ( $versions{$entry}{MakeTree} );
3806
           $color = 'color=magenta style=bold' if ( $versions{$entry}{MakeTree} );
-
 
3807
           $color = 'color=DeepPink style=bold' if (exists $versions{$entry}{data}{errCode} && $versions{$entry}{data}{errCode} eq 'L');
-
 
3808
           $color = 'color=DarkViolet style=bold' if (exists $versions{$entry}{data}{errCode} && $versions{$entry}{data}{errCode} eq '0');
3255
 
3809
 
3256
           $fill = 'style=filled fillcolor=powderblue' if ( $versions{$entry}{Essential} );
3810
           $fill = 'style=filled fillcolor=powderblue' if ( $versions{$entry}{Essential} );
3257
           $fill = 'style=filled fillcolor=red' if ( $versions{$entry}{Essential} && $versions{$entry}{badVcsTag} );
3811
           $fill = 'style=filled fillcolor=red' if ( $versions{$entry}{Essential} && $versions{$entry}{badVcsTag} );
3258
           $fill = 'style=filled fillcolor="#99FF99"' if ( exists $versions{$entry}{svnVersion} );
3812
           $fill = 'style=filled fillcolor="#99FF99"' if ( exists $versions{$entry}{svnVersion} );
3259
 
3813
 
Line 3475... Line 4029...
3475
        }
4029
        }
3476
        
4030
        
3477
        #print "ESSENTIAL: $versions{$_}{name} $versions{$_}{vname}\n";
4031
        #print "ESSENTIAL: $versions{$_}{name} $versions{$_}{vname}\n";
3478
    }
4032
    }
3479
 
4033
 
3480
 
-
 
3481
    #
4034
    #
3482
    #   Free memory
4035
    #   Free memory
3483
    #
4036
    #
3484
    %ScmReleases = ();
4037
    %ScmReleases = ();
3485
    %ScmPackages = ();
4038
    %ScmPackages = ();
Line 3787... Line 4340...
3787
    -name=aaa          - Alternate output package name. Test Only
4340
    -name=aaa          - Alternate output package name. Test Only
3788
    -[no]log           - Write output to log file. Def: -nolog
4341
    -[no]log           - Write output to log file. Def: -nolog
3789
    -[no]postimage     - Create image after transger: Def: -post
4342
    -[no]postimage     - Create image after transger: Def: -post
3790
    -workdir=path      - Use for temp storage (def:/work)
4343
    -workdir=path      - Use for temp storage (def:/work)
3791
    -delete            - Delete SVN package before test
4344
    -delete            - Delete SVN package before test
-
 
4345
    -[no]relabel       - Attempt to relabel dirs in packages that don't extract
3792
 
4346
 
3793
=head1 OPTIONS
4347
=head1 OPTIONS
3794
 
4348
 
3795
=over 8
4349
=over 8
3796
 
4350