Subversion Repositories DevTools

Rev

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

Rev 7040 Rev 7213
Line 21... Line 21...
21
use Pod::Usage;
21
use Pod::Usage;
22
use Getopt::Long;
22
use Getopt::Long;
23
 
23
 
24
use JatsError;
24
use JatsError;
25
use JatsSystem;
25
use JatsSystem;
-
 
26
use JatsRmApi;
-
 
27
use DBI;
26
use FileUtils;
28
use FileUtils;
27
use Cwd;
29
use Cwd;
28
 
30
 
29
my $VERSION = "1.0.0";                      # Update this
31
my $VERSION = "1.0.0";                      # Update this
30
 
32
 
Line 32... Line 34...
32
#   Options
34
#   Options
33
#
35
#
34
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
36
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
35
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
37
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
36
my $opt_help = 0;
38
my $opt_help = 0;
37
my $opt_manual = 0;
-
 
38
my $opt_new_label;
39
my $opt_new_label;
39
my $opt_old_label;
40
my $opt_old_label;
40
my $opt_md5check;
41
my $opt_md5check;
41
my $opt_mode;
42
my $opt_mode;
42
my $opt_diff;
43
my $opt_diff;
-
 
44
my $opt_rtag_id;
-
 
45
my $opt_package_name;
43
my @opt_options;
46
my @opt_options;
44
 
47
 
45
#
48
#
46
#   Globals - Provided by the JATS environment
49
#   Globals - Provided by the JATS environment
47
#
50
#
Line 59... Line 62...
59
my $DiffWait;
62
my $DiffWait;
60
my @view_tags;
63
my @view_tags;
61
my @view_commands;
64
my @view_commands;
62
my @cleanFiles;
65
my @cleanFiles;
63
 
66
 
-
 
67
my $RM_DB;                      # Database interface
-
 
68
my $package_name;               # Selected package name.
-
 
69
my $package_ver;                # Selected package version.
-
 
70
my $package_vcs;                # Selected package VCS tag.
-
 
71
my $package_vcs_base;           # Selected package base path.
-
 
72
my $package_release_branch;     # Selected package release branch or nul if released on trunk.
-
 
73
 
64
 
74
 
65
#-------------------------------------------------------------------------------
75
#-------------------------------------------------------------------------------
66
# Function        : Mainline Entry Point
76
# Function        : Mainline Entry Point
67
#
77
#
68
# Description     :
78
# Description     :
Line 72... Line 82...
72
 
82
 
73
#
83
#
74
#   Parse the user options
84
#   Parse the user options
75
#
85
#
76
my $result = GetOptions (
86
my $result = GetOptions (
77
                "help+"         => \$opt_help,              # Help level
87
                'help|h:+'          => \$opt_help,              # Help Level
78
                "manual"        => \$opt_manual,            # Help level
88
                'manual:3'          => \$opt_help,              # Help Level
79
                "verbose:+"     => \$opt_verbose,           # Verbosity
89
                "verbose:+"         => \$opt_verbose,           # Verbosity
80
                "debug:+"       => \$opt_debug,             # Debug Verbosity
90
                "debug:+"           => \$opt_debug,             # Debug Verbosity
81
                "new=s"         => \$opt_new_label,         # Path1
91
                "new=s"             => \$opt_new_label,         # Path1
82
                "old=s"         => \$opt_old_label,         # Path2
92
                "old=s"             => \$opt_old_label,         # Path2
83
                'check'         => \$opt_md5check,          # Force MD5 Check
93
                'check'             => \$opt_md5check,          # Force MD5 Check
84
                'diff!'         => \$opt_diff,              # Force use of diff
94
                'diff!'             => \$opt_diff,              # Force use of diff
-
 
95
                "rtagid|rtag_id=s"  => \$opt_rtag_id,           # Release tag needed for release extractions
-
 
96
                "package=s"         => \$opt_package_name,      # Name of the package to query
85
                'option=s'      => \@opt_options,           # User options
97
                'option=s'          => \@opt_options,           # User options
86
                );
98
                );
87
 
99
 
88
                #
100
                #
89
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
101
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
90
                #
102
                #
Line 92... Line 104...
92
#
104
#
93
#   Process help and manual options
105
#   Process help and manual options
94
#
106
#
95
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result );
107
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result );
96
pod2usage(-verbose => 1)  if ($opt_help == 2 );
108
pod2usage(-verbose => 1)  if ($opt_help == 2 );
97
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
109
pod2usage(-verbose => 2)  if ($opt_help > 2 );
98
 
110
 
99
InitFileUtils();
111
InitFileUtils();
100
 
112
 
101
#
113
#
102
#   Configure the error reporting process now that we have the user options
114
#   Configure the error reporting process now that we have the user options
Line 184... Line 196...
184
Error ("TMP not found or not a directory")
196
Error ("TMP not found or not a directory")
185
    unless ( $TMP && -d $TMP );
197
    unless ( $TMP && -d $TMP );
186
$TMP = "$TMP/$$";
198
$TMP = "$TMP/$$";
187
 
199
 
188
#
200
#
-
 
201
#   Translate special label names.
-
 
202
#
-
 
203
$opt_old_label = translateSpecialLabelName( "old", $opt_old_label );
-
 
204
$opt_new_label = translateSpecialLabelName( "new", $opt_new_label );
-
 
205
 
-
 
206
#
189
#   Create views for the two views
207
#   Create views for the two views
190
#   Verify that the view are present
208
#   Verify that the view are present
191
#
209
#
192
Message ("Constructing views");
210
Message ("Constructing views");
-
 
211
Message ("  old = $opt_old_label" );
-
 
212
Message ("  new = $opt_new_label" );
193
my $path1 = create_view( $opt_old_label, 1 );
213
my $path1 = create_view( $opt_old_label, 1 );
194
my $path2 = create_view( $opt_new_label, 2 );
214
my $path2 = create_view( $opt_new_label, 2 );
195
 
215
 
196
Error ("Cannot locate view directory: $path1" ) unless (-d $path1);
216
Error ("Cannot locate view directory: $path1" ) unless (-d $path1);
197
Error ("Cannot locate view directory: $path2" ) unless (-d $path2);
217
Error ("Cannot locate view directory: $path2" ) unless (-d $path2);
Line 444... Line 464...
444
    Error ("BeyondCompare program not found", "Prog: $DiffProg")
464
    Error ("BeyondCompare program not found", "Prog: $DiffProg")
445
        unless ( -x $DiffProg );
465
        unless ( -x $DiffProg );
446
}
466
}
447
 
467
 
448
#-------------------------------------------------------------------------------
468
#-------------------------------------------------------------------------------
-
 
469
# Function        : findReleaseManagerPackage
-
 
470
#
-
 
471
# Description     : Find the package information by looking up its existing in 
-
 
472
#                   a given release.
-
 
473
#
-
 
474
# Inputs          : label_name
-
 
475
#                   label_value
-
 
476
#                   rtag_id
-
 
477
#                   package_name
-
 
478
#
-
 
479
# Returns         : 
-
 
480
#
-
 
481
sub findReleaseManagerPackage
-
 
482
{
-
 
483
    my ($label_name, $label_value) = @_;
-
 
484
    my (@row);
-
 
485
    my $found=0;
-
 
486
 
-
 
487
    if ( !$opt_rtag_id || !$opt_package_name )
-
 
488
    {
-
 
489
        Error( "Must specify -rtagid and -package options when the '$label_name' tag has the value '$label_value'" );
-
 
490
    }
-
 
491
    
-
 
492
    if ( !$package_vcs )
-
 
493
    {
-
 
494
 
-
 
495
        connectRM(\$RM_DB) unless ($RM_DB);
-
 
496
 
-
 
497
        # First get details from pv_id; split the package version and extension.
-
 
498
        my $pkg_ext;
-
 
499
        my $pkg_name;
-
 
500
        if ( $opt_package_name =~ m/(.*)\.(\w*)$/ )
-
 
501
        {
-
 
502
            $pkg_name = $1;
-
 
503
            $pkg_ext = $2;
-
 
504
        }
-
 
505
        else
-
 
506
        {
-
 
507
            $pkg_name = $opt_package_name;
-
 
508
        }
-
 
509
 
-
 
510
        my $m_sqlstr = "SELECT pv.PV_ID, pv.PKG_VERSION, release_manager.PK_RMAPI.return_vcs_tag(pv.PV_ID)".
-
 
511
                       " FROM RELEASE_MANAGER.RELEASE_CONTENT rc, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
-
 
512
                       " WHERE rc.RTAG_ID = $opt_rtag_id AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID AND pkg.PKG_NAME = '$pkg_name'";
-
 
513
        if ( $pkg_ext )
-
 
514
        {
-
 
515
            $m_sqlstr .= " AND pv.V_EXT='.$pkg_ext'";
-
 
516
        }
-
 
517
        Verbose2( $m_sqlstr );
-
 
518
        my $sth = $RM_DB->prepare($m_sqlstr);
-
 
519
        if ( defined($sth) )
-
 
520
        {
-
 
521
            if ( $sth->execute( ) )
-
 
522
            {
-
 
523
                if ( $sth->rows )
-
 
524
                {
-
 
525
                    while ( @row = $sth->fetchrow_array )
-
 
526
                    {
-
 
527
                        my $pv_id = $row[0];
-
 
528
                        my $ver = $row[1];
-
 
529
                        my $vcs = $row[2];
-
 
530
                        
-
 
531
                        Verbose( "findReleaseManagerPackage: [$opt_rtag_id, $opt_package_name] ==> [ $pv_id, $ver, $vcs]" );
-
 
532
                        
-
 
533
                        $package_name = $opt_package_name;
-
 
534
                        $package_ver  = $ver;
-
 
535
                        $package_vcs  = $vcs;
-
 
536
                        
-
 
537
                        # Most packages are released of trunk...
-
 
538
                        my $match = '^(SVN::.*)\/trunk::.*$';
-
 
539
                        if ( $package_vcs =~ m/$match/ )
-
 
540
                        {
-
 
541
                            $package_vcs_base = $1;
-
 
542
                            Verbose( "findReleaseManagerPackage: base on trunk ==> $package_vcs_base" );
-
 
543
                        }
-
 
544
                        else
-
 
545
                        {
-
 
546
                            # ...but some are released of branches.
-
 
547
                            $match = '^(SVN::.*)\/branches\/([^:]+)::.*$';
-
 
548
                            if ( $package_vcs =~ m/$match/ )
-
 
549
                            {
-
 
550
                                $package_vcs_base = $1;
-
 
551
                                $package_release_branch = $2;
-
 
552
                                Verbose( "findReleaseManagerPackage: base on branch $package_release_branch ==> $package_vcs_base" );
-
 
553
                            }
-
 
554
                            else
-
 
555
                            {
-
 
556
                                Error ( "Unable to determine base path from VCS: $package_vcs" );
-
 
557
                            }
-
 
558
                        }
-
 
559
                        $found++;
-
 
560
                    }
-
 
561
                }
-
 
562
                $sth->finish();
-
 
563
            }
-
 
564
        }
-
 
565
        else
-
 
566
        {
-
 
567
            Error( "findReleaseManagerPackage:Prepare failure" );
-
 
568
        }
-
 
569
        
-
 
570
        if ( $found == 0 )
-
 
571
        {
-
 
572
            Error( "No package named $opt_package_name found in the release with rtag ID $opt_rtag_id" );
-
 
573
        }
-
 
574
        elsif ( $found > 1 )
-
 
575
        {
-
 
576
            Error( "Multiple packages named $opt_package_name found in the release with rtag ID $opt_rtag_id" );
-
 
577
        }
-
 
578
    }
-
 
579
}
-
 
580
 
-
 
581
#-------------------------------------------------------------------------------
-
 
582
# Function        : translateSpecialLabelName
-
 
583
#
-
 
584
# Description     : Translates the name of a label (-old or -new argument) 
-
 
585
#                   if it is one of the special values.
-
 
586
#
-
 
587
# Inputs          : label_name
-
 
588
#                   label_value
-
 
589
#
-
 
590
# Returns         : new label_value
-
 
591
#
-
 
592
sub translateSpecialLabelName
-
 
593
{
-
 
594
    my ($label_name, $label_value) = @_;
-
 
595
    
-
 
596
    if ( $label_value eq "released" )
-
 
597
    {
-
 
598
        #
-
 
599
        #   Get the exact version released in Release Manager.
-
 
600
        #
-
 
601
        findReleaseManagerPackage( $label_name, $label_value );
-
 
602
        return $package_vcs;
-
 
603
    }
-
 
604
    elsif ( $label_value eq "head" )
-
 
605
    {
-
 
606
        #
-
 
607
        #   Get the 'head' of the released branch in release manager; this is the trunk
-
 
608
        #   if the package is released off trunk or a branch if the package is getting
-
 
609
        #   released from a branch in this release area.
-
 
610
        #
-
 
611
        findReleaseManagerPackage( $label_name, $label_value );
-
 
612
        if ( $package_release_branch )
-
 
613
        {
-
 
614
            return $package_vcs_base . '/branches/' . $package_release_branch;
-
 
615
        }
-
 
616
        else
-
 
617
        {
-
 
618
            return $package_vcs_base . '/trunk'
-
 
619
        }
-
 
620
    }
-
 
621
    elsif ( $label_value =~ m/^branch=(.*)/ )
-
 
622
    {
-
 
623
        #
-
 
624
        #   Get a named branch for this package.
-
 
625
        #
-
 
626
        my $branch_name = $1;
-
 
627
        findReleaseManagerPackage( $label_name, $label_value );
-
 
628
        return $package_vcs_base . '/branches/' . $branch_name;
-
 
629
    }
-
 
630
    elsif ( $label_value eq "trunk" )
-
 
631
    {
-
 
632
        #
-
 
633
        #   Get the true trunk of this package.
-
 
634
        #
-
 
635
        findReleaseManagerPackage( $label_name, $label_value );
-
 
636
        return $package_vcs_base . '/trunk';
-
 
637
    }
-
 
638
    
-
 
639
    return $label_value;
-
 
640
}
-
 
641
 
-
 
642
 
-
 
643
#-------------------------------------------------------------------------------
449
# Function        : END
644
# Function        : END
450
#
645
#
451
# Description     : This function will be called as the program exits
646
# Description     : This function will be called as the program exits
452
#                   It will also be called under error conditions
647
#                   It will also be called under error conditions
453
#                   Close down stuff we created
648
#                   Close down stuff we created
Line 504... Line 699...
504
    -help -help         - Detailed help message
699
    -help -help         - Detailed help message
505
    -man                - Full documentation
700
    -man                - Full documentation
506
    -check              - Perform MD5SUM over both views
701
    -check              - Perform MD5SUM over both views
507
    -[no]diff           - Force the use of a 'diff' utility
702
    -[no]diff           - Force the use of a 'diff' utility
508
    -option=opt1,...    - Add user options to the command line
703
    -option=opt1,...    - Add user options to the command line
509
    -old=tag            - Old VcsTag (or dir=path)
704
    -old=tag            - Old VcsTag (or path or vcs keyword)
510
    -new=tag            - New VcsTag (or dir=path)
705
    -new=tag            - New VcsTag (or path or vcs keyword)
-
 
706
    -rtagid=xxx         - Specify the Release to process
-
 
707
    -package=xxx        - Specify the package to query from Release Manager
511
 
708
 
512
=head1 OPTIONS
709
=head1 OPTIONS
513
 
710
 
514
=over 8
711
=over 8
515
 
712
 
Line 571... Line 768...
571
options, but not both.
768
options, but not both.
572
 
769
 
573
The tag may be of the form dir=path to force the utility to use a local
770
The tag may be of the form dir=path to force the utility to use a local
574
view or path.
771
view or path.
575
 
772
 
-
 
773
Additional tag values are available when generating differences against packages
-
 
774
that are released in Release Manager.  In order to do this specific -rtagid and
-
 
775
-package to specify the Release Manager package version.  Once
-
 
776
these are specified the following tags can be used:
-
 
777
 
-
 
778
=over 4
-
 
779
 
-
 
780
=item * released
-
 
781
 
-
 
782
Use the current released package version in Release Manager.
-
 
783
 
-
 
784
=item * head
-
 
785
 
-
 
786
Use the Subversion HEAD of the Release Manager release path.
-
 
787
 
-
 
788
=item * trunk
-
 
789
 
-
 
790
Use the HEAD of the Subversion trunk.
-
 
791
 
-
 
792
=item * branch=xxx
-
 
793
 
-
 
794
Use the HEAD of the Subversion branch named xxx.
-
 
795
 
-
 
796
=back
-
 
797
 
576
=item B<-new=tag>
798
=item B<-new=tag>
577
 
799
 
578
This option specifies the new, or current, VcsTag for the difference report. This
800
This option specifies the new, or current, VcsTag for the difference report. This
579
tag is mandatory.
801
tag is mandatory.
580
 
802
 
581
The old and new tags may be provided on the command line, or via named
803
Other than that, it has the same form as the -old tag described above.
582
options, but not both.
-
 
583
 
804
 
-
 
805
=item B<-rtagid=xxx>
-
 
806
 
584
The tag may be of the form dir=path to force the utility to use a local
807
This option specified an RTAG_ID that must be determined from Release Manager.
-
 
808
 
-
 
809
The RTAG_ID uniquely identifies a Release. The value can be read from the URL
-
 
810
used to view the release. ie:
-
 
811
 
-
 
812
 https://auawsaweb005/ManagerSuite/Release_Manager/dependencies.asp?rtag_id=17223
-
 
813
 
585
view or path.
814
=item B<-package=xxx>
-
 
815
 
-
 
816
Specifies the name of the package to query from Release Manager.  This can be
-
 
817
in the form of <package_name> or alternatly <package_name>.<ext> where <ext>
-
 
818
is the project-specific extension for that package.  The <package_name>.<ext>
-
 
819
variant is required when there is more than one package with the same name
-
 
820
in the release given by -rtagid.
586
 
821
 
587
=back
822
=back
588
 
823
 
589
=head1 DESCRIPTION
824
=head1 DESCRIPTION
590
 
825
 
Line 648... Line 883...
648
 
883
 
649
If one of the Vcs Tags is of the form:
884
If one of the Vcs Tags is of the form:
650
 
885
 
651
=over 8
886
=over 8
652
 
887
 
653
=item *
888
=item * current
654
 
889
 
655
current
890
=item * current=path
656
 
891
 
657
=item *
892
=item * dir=path
658
 
893
 
659
current=path
894
=back
660
 
895
 
-
 
896
Then the tag will be treated as a directory and will be used for one side
-
 
897
of the comparison.
-
 
898
 
-
 
899
If a Vcs Tag is of the form:
-
 
900
 
-
 
901
=over 8
-
 
902
 
-
 
903
=item * released
-
 
904
 
661
=item *
905
=item * head
662
 
906
 
663
dir=path
907
=item * trunk
-
 
908
 
-
 
909
=item * branch=xxx
664
 
910
 
665
=back
911
=back
666
 
912
 
667
Then the tag will be treated as a directory and will be used for one side
913
Then the source code is checked out of source control based on a Release Manager
668
of the comparison.
914
rtagid (-rtagid option) and package name (-package) option.
669
 
915
 
670
Two directories views will be created. These should be deleted by this program,
916
Two directories views will be created. These should be deleted by this program,
671
but may remain if the command line program is terminated.
917
but may remain if the command line program is terminated.
672
 
918
 
673
=head1 EXAMPLE
919
=head1 EXAMPLE
Line 678... Line 924...
678
 
924
 
679
The following command will compare a Subversion View with a local directory
925
The following command will compare a Subversion View with a local directory
680
 
926
 
681
    jats vcsdiff SVN::AUPERASVN02/COTS/crc/tags/crc_26.4.0000.cr dir=crc
927
    jats vcsdiff SVN::AUPERASVN02/COTS/crc/tags/crc_26.4.0000.cr dir=crc
682
 
928
 
-
 
929
The following command will compare the release version of the ct-spa package from Pulse 2.7.0 with the current head of that package
-
 
930
 
-
 
931
    jats vcsdiff -rtagid=38970 -package=ct-spa released head
-
 
932
 
683
=cut
933
=cut
684
 
934