Subversion Repositories DevTools

Rev

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

Rev 1340 Rev 1341
Line 1733... Line 1733...
1733
    {
1733
    {
1734
        $data->{errStr} = 'Failed to determine Rm Reference';
1734
        $data->{errStr} = 'Failed to determine Rm Reference';
1735
        return 13;
1735
        return 13;
1736
    }
1736
    }
1737
 
1737
 
-
 
1738
 
-
 
1739
    #
-
 
1740
    #   Add supplemental tags if this version is in a 'Release'
-
 
1741
    #
-
 
1742
    foreach my $rname ( keys %{$versions{$entry}{Releases}}  )
-
 
1743
    {
-
 
1744
        my $rtext = 'Release_' . saneString($versions{$entry}{Releases}{$rname});
-
 
1745
        Message ("Adding Release Tag: $rname");
-
 
1746
        $rv = JatsToolPrint ( 'jats_svnlabel' ,
-
 
1747
                    $data->{rmRef},
-
 
1748
                    '-clone',
-
 
1749
                    $rtext,
-
 
1750
#                    @args,
-
 
1751
                     );
-
 
1752
        if ( $rv )
-
 
1753
        {
-
 
1754
            $data->{errStr} = 'Failed to add Release tag';
-
 
1755
            return 14;
-
 
1756
        }
-
 
1757
                     
-
 
1758
    }
-
 
1759
 
-
 
1760
 
1738
    Message ("RM Ref: $data->{rmRef}");
1761
    Message ("RM Ref: $data->{rmRef}");
1739
    unlink $datafile;
1762
    unlink $datafile;
1740
 
1763
 
1741
    #
1764
    #
1742
    #   All is good
1765
    #   All is good
Line 1988... Line 2011...
1988
    #   Perform the branch
2011
    #   Perform the branch
1989
    #
2012
    #
1990
    if ( defined $src_label )
2013
    if ( defined $src_label )
1991
    {
2014
    {
1992
        #
2015
        #
1993
        #   Backtrack source label to a branch
2016
        #   The 'clone' operation will backtrack the branch point
-
 
2017
        #   to the source of the label. This will make the output version
1994
        #   Will make the output version tree much prettier
2018
        #   tree much prettier
1995
        #
2019
        #
1996
        $src_label = backTrackSvnLabel( $src_label );
-
 
1997
 
-
 
1998
        my @opts;
2020
        my @opts;
1999
        push (@opts, '-date', $date) if ( $date );
2021
        push (@opts, '-date', $date) if ( $date );
2000
        push (@opts, '-author', $author) if ( $author );
2022
        push (@opts, '-author', $author) if ( $author );
2001
        
2023
        
2002
        JatsToolPrint ( 'jats_svnlabel',
2024
        JatsToolPrint ( 'jats_svnlabel',
2003
                        '-packagebase', "$svnRepo/$packageNames",
2025
                        '-packagebase', "$svnRepo/$packageNames",
2004
                        $src_label,
2026
                        'tags/' . $src_label,
2005
                        '-branch',
2027
                        '-branch',
2006
                        '-clone', $tgt_label,
2028
                        '-clone', $tgt_label,
2007
                        @opts
2029
                        @opts
2008
                      );
2030
                      );
2009
    }
2031
    }
Line 2312... Line 2334...
2312
    $me =~ tr~_~_~s;
2334
    $me =~ tr~_~_~s;
2313
 
2335
 
2314
    return $me;
2336
    return $me;
2315
}
2337
}
2316
 
2338
 
-
 
2339
sub saneString
-
 
2340
{
-
 
2341
    my ($string) = @_;
-
 
2342
    #
-
 
2343
    #   Get rid of multiple '_'
-
 
2344
    #   Replace space with -
-
 
2345
    #
-
 
2346
    $string =~ s~\W~_~g;
-
 
2347
    $string =~ tr~ ~_~s;
-
 
2348
    $string =~ tr~_-~-~s;
-
 
2349
    $string =~ tr~-_~-~s;
-
 
2350
    $string =~ tr~-~-~s;
-
 
2351
    $string =~ tr~_~_~s;
-
 
2352
    $string =~ s~-$~~;
-
 
2353
    $string =~ s~_$~~;
-
 
2354
 
-
 
2355
    return $string;
-
 
2356
}
-
 
2357
 
2317
 
2358
 
2318
exit 0;
2359
exit 0;
2319
 
2360
 
2320
 
2361
 
2321
#-------------------------------------------------------------------------------
2362
#-------------------------------------------------------------------------------
Line 3025... Line 3066...
3025
#        $stateText .= ' Count='. $versions{$entry}{EssentialSplitPoint} if (exists $versions{$entry}{EssentialSplitPoint});
3066
#        $stateText .= ' Count='. $versions{$entry}{EssentialSplitPoint} if (exists $versions{$entry}{EssentialSplitPoint});
3026
#        $stateText .= ' M='. $versions{$entry}{maxVersion} if (exists $versions{$entry}{maxVersion});
3067
#        $stateText .= ' M='. $versions{$entry}{maxVersion} if (exists $versions{$entry}{maxVersion});
3027
 
3068
 
3028
        push @label, "(${stateText})" if ( $stateText );
3069
        push @label, "(${stateText})" if ( $stateText );
3029
 
3070
 
-
 
3071
##       Insert Release Names
-
 
3072
#        foreach my $rname ( keys %{$versions{$entry}{Releases}}  ) {
-
 
3073
#            push @label, "Release: $versions{$entry}{Releases}{$rname}";
-
 
3074
#        }
-
 
3075
 
3030
        return join ('\n', @label );
3076
        return join ('\n', @label );
3031
    }
3077
    }
3032
 
3078
 
3033
    sub genAttributes
3079
    sub genAttributes
3034
    {
3080
    {
Line 3264... Line 3310...
3264
        next unless ( exists  $pkg_ids{ $ScmPackages{$_}{pkgid} } );
3310
        next unless ( exists  $pkg_ids{ $ScmPackages{$_}{pkgid} } );
3265
        push @EssentialPackages, $_;
3311
        push @EssentialPackages, $_;
3266
        Error ("Essential Package Version not in extracted Release Manager Data: $_")
3312
        Error ("Essential Package Version not in extracted Release Manager Data: $_")
3267
            unless ( exists $versions{$_} );
3313
            unless ( exists $versions{$_} );
3268
        $versions{$_}{Essential} = 1;
3314
        $versions{$_}{Essential} = 1;
-
 
3315
 
-
 
3316
        # Retain which RM Release this package-version is the tip
-
 
3317
        # Release of
-
 
3318
        foreach my $release ( @{$ScmPackages{$_}{'release'}} )
-
 
3319
        {
-
 
3320
            $versions{$_}{Releases}{$release} = $ScmReleases{$release}{name};
-
 
3321
        }
-
 
3322
        
3269
        #print "ESSENTIAL: $versions{$_}{name} $versions{$_}{vname}\n";
3323
        #print "ESSENTIAL: $versions{$_}{name} $versions{$_}{vname}\n";
3270
    }
3324
    }
3271
 
3325
 
-
 
3326
 
3272
    #
3327
    #
3273
    #   Free memory
3328
    #   Free memory
3274
    #
3329
    #
3275
    %ScmReleases = ();
3330
    %ScmReleases = ();
3276
    %ScmPackages = ();
3331
    %ScmPackages = ();
Line 3413... Line 3468...
3413
            $fromBranch = 'trunk';
3468
            $fromBranch = 'trunk';
3414
        } elsif ( $entry->{fromPath} =~ m~/branches/(.*)~ ) {
3469
        } elsif ( $entry->{fromPath} =~ m~/branches/(.*)~ ) {
3415
            $fromBranch = $1;
3470
            $fromBranch = $1;
3416
        }
3471
        }
3417
 
3472
 
-
 
3473
        # largest Rev number on branch
3418
        if ( defined($fromBranch) && ! exists $svnData{branches}{$fromBranch} )
3474
        if ( exists $svnData{max}{$fromBranch} )
3419
        {
3475
        {
3420
            unless ( $name eq $fromBranch )
3476
            if ( $svnData{max}{$fromBranch}{rev} <  $entry->{fromRev} )
3421
            {
3477
            {
3422
                $svnData{branches}{$fromBranch} = $name;
3478
                $svnData{max}{$fromBranch}{rev} =  $entry->{fromRev};
3423
                $svnData{tips}{$name} = $fromBranch;
3479
                $svnData{max}{$fromBranch}{name} = $name;
3424
            }
3480
            }
3425
        }
3481
        }
-
 
3482
        else
-
 
3483
        {
-
 
3484
            $svnData{max}{$fromBranch}{rev} =  $entry->{fromRev};
-
 
3485
            $svnData{max}{$fromBranch}{name} = $name;
-
 
3486
        }
3426
    }
3487
    }
-
 
3488
 
-
 
3489
    foreach my $branch ( keys %{$svnData{max}} )
-
 
3490
    {
-
 
3491
        $svnData{tips}{$svnData{max}{$branch}{name}} = $branch;
-
 
3492
    }
-
 
3493
#    DebugDumpData("svnDataItems", \@svnDataItems);
3427
#    DebugDumpData("SvnData", \%svnData);
3494
#    DebugDumpData("SvnData", \%svnData);
3428
 
3495
 
-
 
3496
 
3429
    foreach my $entry ( keys(%versions) )
3497
    foreach my $entry ( keys(%versions) )
3430
    {
3498
    {
3431
        my $import_label = saneLabel($entry);
3499
        my $import_label = saneLabel($entry);
3432
        delete $versions{$entry}{svnVersion};
3500
        delete $versions{$entry}{svnVersion};
3433
        delete $versions{$entry}{svnBranchTip};
3501
        delete $versions{$entry}{svnBranchTip};
Line 3441... Line 3509...
3441
        {
3509
        {
3442
            $versions{$entry}{svnBranchTip} = $svnData{tips}{$import_label};
3510
            $versions{$entry}{svnBranchTip} = $svnData{tips}{$import_label};
3443
        }
3511
        }
3444
    }
3512
    }
3445
 
3513
 
3446
    Message ( 'Trunk used: ' . (exists $svnData{branches}{trunk} ? 'Yes' : 'No') );
3514
    Message ( 'Trunk used: ' . (exists $svnData{'max'}{trunk} ? 'Yes' : 'No') );
3447
    Message ( 'Labels    : ' . scalar keys %{$svnData{tags}} );
3515
    Message ( 'Labels    : ' . scalar keys %{$svnData{tags}} );
3448
    Message ( 'Branches  : ' . scalar keys %{$svnData{branches}} );
3516
    Message ( 'Branches  : ' . scalar keys %{$svnData{'max'}} );
3449
}
3517
}
3450
 
3518
 
3451
#-------------------------------------------------------------------------------
3519
#-------------------------------------------------------------------------------
3452
# Function        : ProcessSvnLog
3520
# Function        : ProcessSvnLog
3453
#
3521
#
Line 3504... Line 3572...
3504
    #
3572
    #
3505
    #   Return 0 to keep on going
3573
    #   Return 0 to keep on going
3506
    return 0;
3574
    return 0;
3507
}
3575
}
3508
 
3576
 
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
#-------------------------------------------------------------------------------
3577
#-------------------------------------------------------------------------------
3586
# Function        : saveData
3578
# Function        : saveData
3587
#
3579
#
3588
# Description     : Save essential data
3580
# Description     : Save essential data
3589
#
3581
#