Subversion Repositories DevTools

Rev

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

Rev 1341 Rev 1356
Line 39... Line 39...
39
use Fcntl ':flock'; # import LOCK_* constants
39
use Fcntl ':flock'; # import LOCK_* constants
40
use Cwd;
40
use Cwd;
41
use DBI;
41
use DBI;
42
use Getopt::Long;
42
use Getopt::Long;
43
use Pod::Usage;                             # required for help support
43
use Pod::Usage;                             # required for help support
-
 
44
use Encode;
44
 
45
 
45
#
46
#
46
#   Options
47
#   Options
47
#
48
#
48
my $opt_help = 0;
49
my $opt_help = 0;
Line 1381... Line 1382...
1381
 
1382
 
1382
    #
1383
    #
1383
    #   If we have a global error,then we pretend to process, but we
1384
    #   If we have a global error,then we pretend to process, but we
1384
    #   report errors for the logging system
1385
    #   report errors for the logging system
1385
    #
1386
    #
1386
    unless ( $globalError )
1387
    if ( $globalError )
-
 
1388
    {
-
 
1389
        Message ("Global error prevents futher importation");
-
 
1390
    }
-
 
1391
    else
1387
    {
1392
    {
1388
        #
1393
        #
1389
        #   Call worker function
1394
        #   Call worker function
1390
        #   It will exist on any error so that it can be logged
1395
        #   It will exist on any error so that it can be logged
1391
        #
1396
        #
Line 1733... Line 1738...
1733
    {
1738
    {
1734
        $data->{errStr} = 'Failed to determine Rm Reference';
1739
        $data->{errStr} = 'Failed to determine Rm Reference';
1735
        return 13;
1740
        return 13;
1736
    }
1741
    }
1737
 
1742
 
-
 
1743
 
-
 
1744
    #
-
 
1745
    #   Add supplemental tags if this version is in a 'Release'
-
 
1746
    #   But only for some packages - els looks like a mess
-
 
1747
    #   Just a solution for the ITSO guys
-
 
1748
    #
-
 
1749
    foreach my $rtag_id ( keys %{$versions{$entry}{Releases}}  )
-
 
1750
    {
-
 
1751
        next unless ( $svnRepo =~ m~/ITSO_TRACS(/|$)~);
-
 
1752
 
-
 
1753
        my $prog_id = $versions{$entry}{Releases}{$rtag_id}{proj_id};
-
 
1754
        Message ("Adding Release Tag:$prog_id:$rtag_id");
-
 
1755
 
-
 
1756
        my $rtext = 'Release_' . saneString($versions{$entry}{Releases}{$rtag_id}{rname});
-
 
1757
        my @comment;
-
 
1758
        push @comment, "Tagged by ClearCase to Subversion import";
-
 
1759
        push @comment, "Project:$prog_id:$versions{$entry}{Releases}{$rtag_id}{pname}";
-
 
1760
        push @comment, "Release:$rtag_id:$versions{$entry}{Releases}{$rtag_id}{rname}";
-
 
1761
 
-
 
1762
        $data->{ReleaseTag}{$prog_id}{$rtag_id}{name} = $rtext;
-
 
1763
 
-
 
1764
        $rv = JatsToolPrint ( 'jats_svnlabel' ,
-
 
1765
                    '-comment', encode('UTF-8', join("\n", @comment), Encode::FB_DEFAULT),
-
 
1766
                    $data->{rmRef},
-
 
1767
                    '-clone',
-
 
1768
                    $rtext,
-
 
1769
#                    @args,
-
 
1770
                    '-author=buildadm',
-
 
1771
                     );
-
 
1772
        $data->{ReleaseTag}{$prog_id}{$rtag_id}{eState} = $rv;
-
 
1773
        $data->{ReleaseTag}{tCount}++;
-
 
1774
 
-
 
1775
        if ( $rv )
-
 
1776
        {
-
 
1777
            $data->{ReleaseTag}{eCount}++;
-
 
1778
            Warning("Failed to add Release Tag: $rtext");
-
 
1779
        }
-
 
1780
    }
-
 
1781
 
-
 
1782
 
1738
    Message ("RM Ref: $data->{rmRef}");
1783
    Message ("RM Ref: $data->{rmRef}");
1739
    unlink $datafile;
1784
    unlink $datafile;
1740
 
1785
 
1741
    #
1786
    #
1742
    #   All is good
1787
    #   All is good
Line 1988... Line 2033...
1988
    #   Perform the branch
2033
    #   Perform the branch
1989
    #
2034
    #
1990
    if ( defined $src_label )
2035
    if ( defined $src_label )
1991
    {
2036
    {
1992
        #
2037
        #
1993
        #   Backtrack source label to a branch
2038
        #   The 'clone' operation will backtrack the branch point
-
 
2039
        #   to the source of the label. This will make the output version
1994
        #   Will make the output version tree much prettier
2040
        #   tree much prettier
1995
        #
2041
        #
1996
        $src_label = backTrackSvnLabel( $src_label );
-
 
1997
 
-
 
1998
        my @opts;
2042
        my @opts;
1999
        push (@opts, '-date', $date) if ( $date );
2043
        push (@opts, '-date', $date) if ( $date );
2000
        push (@opts, '-author', $author) if ( $author );
2044
        push (@opts, '-author', $author) if ( $author );
2001
        
2045
        
2002
        JatsToolPrint ( 'jats_svnlabel',
2046
        JatsToolPrint ( 'jats_svnlabel',
2003
                        '-packagebase', "$svnRepo/$packageNames",
2047
                        '-packagebase', "$svnRepo/$packageNames",
2004
                        $src_label,
2048
                        'tags/' . $src_label,
2005
                        '-branch',
2049
                        '-branch',
2006
                        '-clone', $tgt_label,
2050
                        '-clone', $tgt_label,
2007
                        @opts
2051
                        @opts
2008
                      );
2052
                      );
2009
    }
2053
    }
Line 2312... Line 2356...
2312
    $me =~ tr~_~_~s;
2356
    $me =~ tr~_~_~s;
2313
 
2357
 
2314
    return $me;
2358
    return $me;
2315
}
2359
}
2316
 
2360
 
-
 
2361
sub saneString
-
 
2362
{
-
 
2363
    my ($string) = @_;
-
 
2364
    #
-
 
2365
    #   Get rid of multiple '_'
-
 
2366
    #   Replace space with -
-
 
2367
    #
-
 
2368
    $string =~ s~\W~_~g;
-
 
2369
    $string =~ tr~ ~_~s;
-
 
2370
    $string =~ tr~_-~-~s;
-
 
2371
    $string =~ tr~-_~-~s;
-
 
2372
    $string =~ tr~-~-~s;
-
 
2373
    $string =~ tr~_~_~s;
-
 
2374
    $string =~ s~-$~~;
-
 
2375
    $string =~ s~_$~~;
-
 
2376
 
-
 
2377
    return $string;
-
 
2378
}
-
 
2379
 
2317
 
2380
 
2318
exit 0;
2381
exit 0;
2319
 
2382
 
2320
 
2383
 
2321
#-------------------------------------------------------------------------------
2384
#-------------------------------------------------------------------------------
Line 3025... Line 3088...
3025
#        $stateText .= ' Count='. $versions{$entry}{EssentialSplitPoint} if (exists $versions{$entry}{EssentialSplitPoint});
3088
#        $stateText .= ' Count='. $versions{$entry}{EssentialSplitPoint} if (exists $versions{$entry}{EssentialSplitPoint});
3026
#        $stateText .= ' M='. $versions{$entry}{maxVersion} if (exists $versions{$entry}{maxVersion});
3089
#        $stateText .= ' M='. $versions{$entry}{maxVersion} if (exists $versions{$entry}{maxVersion});
3027
 
3090
 
3028
        push @label, "(${stateText})" if ( $stateText );
3091
        push @label, "(${stateText})" if ( $stateText );
3029
 
3092
 
-
 
3093
##       Insert Release Names
-
 
3094
#        foreach my $rtag_id ( keys %{$versions{$entry}{Releases}}  ) {
-
 
3095
#            push @label, "Release: $versions{$entry}{Releases}{$rtag_id}{rname}";
-
 
3096
#        }
-
 
3097
 
3030
        return join ('\n', @label );
3098
        return join ('\n', @label );
3031
    }
3099
    }
3032
 
3100
 
3033
    sub genAttributes
3101
    sub genAttributes
3034
    {
3102
    {
Line 3264... Line 3332...
3264
        next unless ( exists  $pkg_ids{ $ScmPackages{$_}{pkgid} } );
3332
        next unless ( exists  $pkg_ids{ $ScmPackages{$_}{pkgid} } );
3265
        push @EssentialPackages, $_;
3333
        push @EssentialPackages, $_;
3266
        Error ("Essential Package Version not in extracted Release Manager Data: $_")
3334
        Error ("Essential Package Version not in extracted Release Manager Data: $_")
3267
            unless ( exists $versions{$_} );
3335
            unless ( exists $versions{$_} );
3268
        $versions{$_}{Essential} = 1;
3336
        $versions{$_}{Essential} = 1;
-
 
3337
 
-
 
3338
        # Retain which RM Release this package-version is the tip
-
 
3339
        # Release of
-
 
3340
        foreach my $rtag_id ( @{$ScmPackages{$_}{'release'}} )
-
 
3341
        {
-
 
3342
            $versions{$_}{Releases}{$rtag_id}{rname}   = $ScmReleases{$rtag_id}{name};
-
 
3343
            $versions{$_}{Releases}{$rtag_id}{pname}   = $ScmReleases{$rtag_id}{pName};
-
 
3344
            $versions{$_}{Releases}{$rtag_id}{proj_id} = $ScmReleases{$rtag_id}{proj_id};
-
 
3345
        }
-
 
3346
        
3269
        #print "ESSENTIAL: $versions{$_}{name} $versions{$_}{vname}\n";
3347
        #print "ESSENTIAL: $versions{$_}{name} $versions{$_}{vname}\n";
3270
    }
3348
    }
3271
 
3349
 
-
 
3350
 
3272
    #
3351
    #
3273
    #   Free memory
3352
    #   Free memory
3274
    #
3353
    #
3275
    %ScmReleases = ();
3354
    %ScmReleases = ();
3276
    %ScmPackages = ();
3355
    %ScmPackages = ();
Line 3413... Line 3492...
3413
            $fromBranch = 'trunk';
3492
            $fromBranch = 'trunk';
3414
        } elsif ( $entry->{fromPath} =~ m~/branches/(.*)~ ) {
3493
        } elsif ( $entry->{fromPath} =~ m~/branches/(.*)~ ) {
3415
            $fromBranch = $1;
3494
            $fromBranch = $1;
3416
        }
3495
        }
3417
 
3496
 
-
 
3497
        # largest Rev number on branch
3418
        if ( defined($fromBranch) && ! exists $svnData{branches}{$fromBranch} )
3498
        if ( exists $svnData{max}{$fromBranch} )
3419
        {
3499
        {
3420
            unless ( $name eq $fromBranch )
3500
            if ( $svnData{max}{$fromBranch}{rev} <  $entry->{fromRev} )
3421
            {
3501
            {
3422
                $svnData{branches}{$fromBranch} = $name;
3502
                $svnData{max}{$fromBranch}{rev} =  $entry->{fromRev};
3423
                $svnData{tips}{$name} = $fromBranch;
3503
                $svnData{max}{$fromBranch}{name} = $name;
3424
            }
3504
            }
3425
        }
3505
        }
-
 
3506
        else
-
 
3507
        {
-
 
3508
            $svnData{max}{$fromBranch}{rev} =  $entry->{fromRev};
-
 
3509
            $svnData{max}{$fromBranch}{name} = $name;
-
 
3510
        }
3426
    }
3511
    }
-
 
3512
 
-
 
3513
    foreach my $branch ( keys %{$svnData{max}} )
-
 
3514
    {
-
 
3515
        $svnData{tips}{$svnData{max}{$branch}{name}} = $branch;
-
 
3516
    }
-
 
3517
#    DebugDumpData("svnDataItems", \@svnDataItems);
3427
#    DebugDumpData("SvnData", \%svnData);
3518
#    DebugDumpData("SvnData", \%svnData);
3428
 
3519
 
-
 
3520
 
3429
    foreach my $entry ( keys(%versions) )
3521
    foreach my $entry ( keys(%versions) )
3430
    {
3522
    {
3431
        my $import_label = saneLabel($entry);
3523
        my $import_label = saneLabel($entry);
3432
        delete $versions{$entry}{svnVersion};
3524
        delete $versions{$entry}{svnVersion};
3433
        delete $versions{$entry}{svnBranchTip};
3525
        delete $versions{$entry}{svnBranchTip};
Line 3441... Line 3533...
3441
        {
3533
        {
3442
            $versions{$entry}{svnBranchTip} = $svnData{tips}{$import_label};
3534
            $versions{$entry}{svnBranchTip} = $svnData{tips}{$import_label};
3443
        }
3535
        }
3444
    }
3536
    }
3445
 
3537
 
3446
    Message ( 'Trunk used: ' . (exists $svnData{branches}{trunk} ? 'Yes' : 'No') );
3538
    Message ( 'Trunk used: ' . (exists $svnData{'max'}{trunk} ? 'Yes' : 'No') );
3447
    Message ( 'Labels    : ' . scalar keys %{$svnData{tags}} );
3539
    Message ( 'Labels    : ' . scalar keys %{$svnData{tags}} );
3448
    Message ( 'Branches  : ' . scalar keys %{$svnData{branches}} );
3540
    Message ( 'Branches  : ' . scalar keys %{$svnData{'max'}} );
3449
}
3541
}
3450
 
3542
 
3451
#-------------------------------------------------------------------------------
3543
#-------------------------------------------------------------------------------
3452
# Function        : ProcessSvnLog
3544
# Function        : ProcessSvnLog
3453
#
3545
#
Line 3504... Line 3596...
3504
    #
3596
    #
3505
    #   Return 0 to keep on going
3597
    #   Return 0 to keep on going
3506
    return 0;
3598
    return 0;
3507
}
3599
}
3508
 
3600
 
3509
 
-
 
3510
#-------------------------------------------------------------------------------
-
 
3511
# Function        : backTrackSvnLabel
-
 
3512
#
-
 
3513
# Description     : Examine a Svn Tag and packtrack until we find the branch
-
 
3514
#                   that was used to create the label
-
 
3515
#
-
 
3516
# Inputs          : $src_label              - Label to process
-
 
3517
#
-
 
3518
#                   Assumes "$svnRepo/$packageNames"
-
 
3519
#
-
 
3520
# Returns         : label
-
 
3521
#
-
 
3522
sub backTrackSvnLabel
-
 
3523
{
-
 
3524
    my ($src_label) = @_;
-
 
3525
 
-
 
3526
    #
-
 
3527
    #   Re-init data
-
 
3528
    #
-
 
3529
    @svnDataItems = ();
-
 
3530
    %svnData = ();
-
 
3531
    
-
 
3532
    #
-
 
3533
    #   Create an SVN session
-
 
3534
    #
-
 
3535
    return unless ( $svnRepo );
-
 
3536
    my $svn = NewSessionByUrl ( "$svnRepo/$packageNames" );
-
 
3537
    return unless ( $svn );
-
 
3538
 
-
 
3539
    #
-
 
3540
    #   extract data
-
 
3541
    #
-
 
3542
#    DebugDumpData("SVN", $svn );
-
 
3543
    $svn->SvnCmd ( 'log', '-v', '--xml', '--stop-on-copy', $svn->Full() . '/tags/' . $src_label
-
 
3544
                    , { 'credentials' => 1,
-
 
3545
                        'process' => \&ProcessSvnLog,
-
 
3546
                         }
-
 
3547
                        );
-
 
3548
 
-
 
3549
    #
-
 
3550
    #   Process data
-
 
3551
    #
-
 
3552
#    DebugDumpData("svnDataItems", \@svnDataItems );
-
 
3553
#    DebugDumpData("svnData", \%svnData );
-
 
3554
 
-
 
3555
    my $branch;
-
 
3556
    foreach my $entry ( @svnDataItems )
-
 
3557
    {
-
 
3558
        my $name;
-
 
3559
        my $isaBranch;
-
 
3560
        my $target = $entry->{target};
-
 
3561
 
-
 
3562
        if ( $target =~ m~/tags/$src_label$~ )
-
 
3563
        {
-
 
3564
            my $parent = $entry->{fromPath};
-
 
3565
            if ( $parent =~ m~(.+)/((tags|branches|trunk)(/|$).*)~ )
-
 
3566
            {
-
 
3567
                $branch = $2 . '@' . $entry->{fromRev};
-
 
3568
                last;
-
 
3569
            }
-
 
3570
        }
-
 
3571
    }
-
 
3572
 
-
 
3573
    #
-
 
3574
    #   Return nice value or original value
-
 
3575
    #
-
 
3576
    unless ( $branch )
-
 
3577
    {
-
 
3578
        $branch = 'tags/' . $src_label;
-
 
3579
    }
-
 
3580
 
-
 
3581
    Message( "backTrackSvnLabel: $src_label -> $branch");
-
 
3582
    return $branch;
-
 
3583
}
-
 
3584
 
-
 
3585
#-------------------------------------------------------------------------------
3601
#-------------------------------------------------------------------------------
3586
# Function        : saveData
3602
# Function        : saveData
3587
#
3603
#
3588
# Description     : Save essential data
3604
# Description     : Save essential data
3589
#
3605
#