Subversion Repositories DevTools

Rev

Rev 249 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 249 Rev 251
Line 39... Line 39...
39
#
39
#
40
 
40
 
41
#
41
#
42
# Update this:
42
# Update this:
43
#
43
#
44
my $VERSION = "1.0.3";                      
44
my $VERSION = "1.1.0";
45
 
45
 
46
#
46
#
47
#  Globals that can be set immediately
47
#  Globals that can be set immediately
48
#
48
#
49
my $ats = "@@";
49
my $ats = "@@";
Line 229... Line 229...
229
#   Locate all files for the two areas
229
#   Locate all files for the two areas
230
#
230
#
231
{
231
{
232
    my %initialFilePaths;
232
    my %initialFilePaths;
233
 
233
 
234
    files_from_view( $oldLabelVob, $oldLabel, 1, $oldDirectory, %initialFilePaths );
234
    files_from_view( $oldLabelVob, $oldLabel, 1, $oldDirectory, %initialFilePaths ) if ($opt_old);
235
    files_from_view( $newLabelVob, $newLabel, 2, $newDirectory, %initialFilePaths );
235
    files_from_view( $newLabelVob, $newLabel, 2, $newDirectory, %initialFilePaths );
236
    #DebugDumpData ("initialFilePaths", \%initialFilePaths );
236
    #DebugDumpData ("initialFilePaths", \%initialFilePaths );
237
 
237
 
238
    populateFilesArray( $oldLabel, 1, $oldDirectory, %initialFilePaths);
238
    populateFilesArray( $oldLabel, 1, $oldDirectory, %initialFilePaths);
239
    populateFilesArray( $newLabel, 2, $newDirectory, %initialFilePaths);
239
    populateFilesArray( $newLabel, 2, $newDirectory, %initialFilePaths);
240
    #DebugDumpData ("Files", \%files );
240
    #DebugDumpData ("Files", \%files );
241
}
241
}
242
 
242
 
243
 
-
 
244
#
243
#
245
#   Have a structure that contains files for both the old and new labels
244
#   Have a structure that contains files for both the old and new labels
246
#   Scan the list locating files that are different
245
#   Scan the list locating files that are different
247
#
246
#
248
my @no_text;
247
my @no_text;
Line 310... Line 309...
310
 
309
 
311
#
310
#
312
#   Summary information
311
#   Summary information
313
#
312
#
314
Information ("Summary Information",
313
Information ("Summary Information",
315
             "Old:               : " . $oldLabel ? $oldLabel : $oldDirectory,
314
             "Old:               : " . ($oldLabel ? $oldLabel : $oldDirectory || 'None' ),
316
             "New:               : " . $newLabel ? $newLabel : $newDirectory,
315
             "New:               : " . ($newLabel ? $newLabel : $newDirectory),
317
             "Files different    : $ndiffs",
316
             "Files different    : $ndiffs",
318
             "Files added        : $added",
317
             "Files added        : $added",
319
             "Files deleted      : $deleted",
318
             "Files deleted      : $deleted",
320
             "Files not in report: " . scalar(@no_text),
319
             "Files not in report: " . scalar(@no_text),
321
             "Output file        : $opt_outfile"
320
             "Output file        : $opt_outfile"
Line 386... Line 385...
386
        $opt_old = shift @ARGV;
385
        $opt_old = shift @ARGV;
387
        $opt_new = shift @ARGV;
386
        $opt_new = shift @ARGV;
388
    }
387
    }
389
 
388
 
390
    Error ("Need to provide the 'new' label/directory") unless ( $opt_new );
389
    Error ("Need to provide the 'new' label/directory") unless ( $opt_new );
391
    Error ("Need to provide the 'old' label/directory") unless ( $opt_old );
-
 
392
 
390
 
393
    parseTag($opt_old, $oldLabel, $oldDirectory);
391
    parseTag($opt_old, $oldLabel, $oldDirectory) if ( $opt_old );
394
    parseTag($opt_new, $newLabel, $newDirectory);
392
    parseTag($opt_new, $newLabel, $newDirectory);
395
 
393
 
396
    Error("Cannot compare two directories") if( $oldDirectory && $newDirectory );
394
    Error("Cannot compare two directories") if( $oldDirectory && $newDirectory );
397
}
395
}
398
 
396
 
Line 400... Line 398...
400
#-------------------------------------------------------------------------------
398
#-------------------------------------------------------------------------------
401
# Function        : parseTags
399
# Function        : parseTags
402
#
400
#
403
# Description     : Worker function for getTags() - parses a "-new"/"-old" option
401
# Description     : Worker function for getTags() - parses a "-new"/"-old" option
404
#
402
#
405
# Inputs          : $retOpt - reference to the command line argument
403
# Inputs          : $retOpt         - reference to the command line argument
406
#                   $refLabel - reference to the label variable that may be initialised
404
#                   $refLabel       - reference to the label variable that may be initialised
407
#                   $refDirectory - reference to the directory variable that may be initialised
405
#                   $refDirectory   - reference to the directory variable that may be initialised
408
#
406
#
409
# Returns         : 
407
# Returns         : 
410
#
408
#
411
sub parseTag(\$\$\$)
409
sub parseTag(\$\$\$)
412
{
410
{
Line 486... Line 484...
486
 
484
 
487
        push @initialFilePaths, $initialFilePath 
485
        push @initialFilePaths, $initialFilePath 
488
            if( $$refInitialFilePaths{$initialFilePath}{$tag} );
486
            if( $$refInitialFilePaths{$initialFilePath}{$tag} );
489
    }
487
    }
490
 
488
 
491
    #######################
-
 
492
    # Step 2: Call cleartool dump on each of these initial filenames and get the ids
-
 
493
    # Then populate the %files array
-
 
494
    #
489
    #
-
 
490
    #   If this is a part of a 'directory' comparison, then we need to
495
    #   In practice this will only be used when one side of the comarison
491
    #   convert the filename into vob extended pathnames - as seen within the
496
    #   is a directory. Should be able to use this knowledge
492
    #   administration_view. This is slow, so we don't do it if its a part
-
 
493
    #   of a label-label comparison.
497
    #
494
    #
-
 
495
    if ( $directory )
-
 
496
    {
-
 
497
        #
-
 
498
        #   Convert the list of files into a list of vob extended pathnames
-
 
499
        #   Done as a block for speed
-
 
500
        #
-
 
501
#DebugDumpData ("Initial Paths", @initialFilePaths);
498
    my @ids = getIds( $tag, @initialFilePaths );
502
        @initialFilePaths = getIds( $tag, @initialFilePaths );
499
#DebugDumpData ("IDS", \@ids);
503
#DebugDumpData ("Final Paths", @initialFilePaths);
-
 
504
    }
500
 
505
 
501
    #
506
    #
502
    #   Populate the 'files' hash
507
    #   Populate the $files hash with information
503
    #   Keys are: element number and tag
508
    #   key1 - name, without version
504
    #   This groups files that are the same element together
-
 
505
    #   They may be different versions of the element
-
 
506
    #
509
    #   key2 - tag
507
    #   The value is the vob extended pathname within the admin vob
510
    #   value - Vob extended path name
508
    #   This can be used to extract the file in any view
-
 
509
    #
511
    #
510
    foreach my $datap ( @ids )
512
    foreach my $pn ( @initialFilePaths )
511
    {
513
    {
512
        my $pname = $datap->{pname};
514
        my $key = $pn;
513
        my $element = $datap->{element};
515
        $key =~ s~@@[^@]*$~~;
-
 
516
        Error ("Internal. Expected path with embedded @@", "Got: $pn") unless $key;
514
        $files{$element}{$tag} = $pname;
517
        $files{$key}{$tag} = $pn;
515
    }
518
    }
-
 
519
#DebugDumpData ("FILES", \%files);
516
}
520
}
517
 
521
 
518
 
522
 
519
#-------------------------------------------------------------------------------
523
#-------------------------------------------------------------------------------
520
# Function        : files_from_view
524
# Function        : files_from_view
Line 549... Line 553...
549
 
553
 
550
        foreach my $initialFilePath (@initialFilePaths)
554
        foreach my $initialFilePath (@initialFilePaths)
551
        {
555
        {
552
            $$refInitialFilePaths{$initialFilePath}{$tag} = 1;
556
            $$refInitialFilePaths{$initialFilePath}{$tag} = 1;
553
        }
557
        }
554
    }    
558
    }
555
    else
559
    else
556
    {
560
    {
557
        my $nfilesStartedWith = scalar(keys %$refInitialFilePaths);
561
        my $nfilesStartedWith = scalar(keys %$refInitialFilePaths);
558
        my @checkedout;
562
        my @checkedout;
559
 
563
 
Line 588... Line 592...
588
                my $rule = $2;
592
                my $rule = $2;
589
 
593
 
590
                $files =~ tr{\\/}{/}s;  # Replace \ and / with /
594
                $files =~ tr{\\/}{/}s;  # Replace \ and / with /
591
                (my $actualFilePath = $files) =~ s~${ats}.*~~;
595
                (my $actualFilePath = $files) =~ s~${ats}.*~~;
592
 
596
 
593
                if ( $rule =~ m/CHECKEDOUT/ )
597
                #
594
                {
598
                #   These are not good
595
                    push @checkedout, $actualFilePath;
599
                #   Remember  the names and generate an error later
596
                }
600
                #
-
 
601
                push @checkedout, $actualFilePath if ( $rule =~ m/CHECKEDOUT/ );
597
 
602
 
598
                #
603
                #
599
                #   Don't want to know about directories
604
                #   Don't want to know about directories
600
                #
605
                #
601
                next if( -d $actualFilePath );
606
                next if( -d $actualFilePath );
602
 
607
 
603
                #
608
                #
-
 
609
                #   lost+found can be a problem too
-
 
610
                #   These report: [not loaded, no version selected]
-
 
611
                #
-
 
612
                next if ( $files =~ m{/lost\+found\@\@} );
-
 
613
 
-
 
614
                #
604
                #   Save files name, with embedded version
615
                #   Save files name, with embedded version
605
                #
616
                #
606
                $$refInitialFilePaths{$files}{$tag} = 1;
617
                $$refInitialFilePaths{$files}{$tag} = 1;
607
            }
618
            }
608
        }
619
        }
Line 657... Line 668...
657
        Verbose2 ("ctf: $_");
668
        Verbose2 ("ctf: $_");
658
        push @outputLines, $_;
669
        push @outputLines, $_;
659
    }
670
    }
660
    close(CMD);
671
    close(CMD);
661
 
672
 
662
    Message("There are " . scalar(@outputLines) . " files in $opt_drive/$opt_viewname/$vpath");
673
    Message("There are " . scalar(@outputLines) . " files in $opt_drive/$opt_viewname$vpath");
663
    
674
    
664
    return @outputLines;
675
    return @outputLines;
665
}
676
}
666
 
677
 
667
 
678
 
Line 688... Line 699...
688
    #   Change to the directory that contains the admin view
699
    #   Change to the directory that contains the admin view
689
    #   This will ensure that the 2nd line of the dump comamnd contains
700
    #   This will ensure that the 2nd line of the dump comamnd contains
690
    #   the vob extended pathname within that view. This will be used
701
    #   the vob extended pathname within that view. This will be used
691
    #   to simplify the pairing of files
702
    #   to simplify the pairing of files
692
    #
703
    #
-
 
704
    Verbose2 ("getIds: chdir: $view_path");
693
    chdir ($view_path) || Error ("Did not chdir to $view_path" );
705
    chdir ($view_path) || Error ("Did not chdir to $view_path" );
694
    
706
    
695
    while( @initialFilePaths )
707
    while( @initialFilePaths )
696
    {
708
    {
697
        #
709
        #
Line 700... Line 712...
700
        #   If short ( ie 1 ), then the call overhead is very high
712
        #   If short ( ie 1 ), then the call overhead is very high
701
        #
713
        #
702
        my @filesToDump = splice( @initialFilePaths, 0, $nfilesPerCallToDump);
714
        my @filesToDump = splice( @initialFilePaths, 0, $nfilesPerCallToDump);
703
 
715
 
704
        #
716
        #
705
        #   The dump command provides two useful bits of information
717
        #   The dump command provides two really useful peice of  information
-
 
718
        #       1) Line1: The input file name
706
        #       1) Line1: The vob extended pathname of the files as
719
        #       2) Line2: The vob extended pathname of the files as
707
        #                 seen in the current view, together with some junk
720
        #                 seen in the current view, together with some junk
708
        #                 The line contains two @@ which is used by codestriker
-
 
709
        #                 Line2 would be better, but doesn't work with
-
 
710
        #                 Codestriker
-
 
711
        #
-
 
712
        #       2) element number
-
 
713
        #           This will be the same for all versions of an element
-
 
714
        #           This allows files from two views to be correlated
-
 
715
        #
721
        #
-
 
722
        #   The line is of the form
-
 
723
        #           path_to_vob@@vob_extended_pathname
-
 
724
        #
-
 
725
        #   Unfortunately CodeStriker needs something of the form
-
 
726
        #           path_to_vob@@mangled_pathname
-
 
727
        #   Where the mangled pathname contains 2 @@ sequences
-
 
728
        #       1) After the path_to_vob (good)
-
 
729
        #       2) One after the name of the file (bad)
-
 
730
        #   Code striker uses this to make a prety display
-
 
731
        #
-
 
732
        #   Luckily The input has the location of the 2nd @@
-
 
733
        #   Create a mangled reference by merging the input line
-
 
734
        #   and line-1
716
        #
735
        #
717
 
736
 
718
        my $cmd2 = QuoteCommand( "cleartool", "dump", @filesToDump);
737
        my $cmd2 = QuoteCommand( "cleartool", "dump", @filesToDump);
719
        my @newids;
738
        my @newids;
720
        my %data;
-
 
721
        my $line = 0;
739
        my $line = 0;
-
 
740
        my $user_path;
722
 
741
 
723
        Verbose2("Cleartool: getting unique identifiers for " . scalar(@filesToDump) . " files");
742
        Verbose2("Cleartool: getting unique identifiers for " . scalar(@filesToDump) . " files");
724
 
743
 
725
        open(CCI, "$cmd2 2>&1 |") || Error "Can't run command: $!";
744
        open(CCI, "$cmd2 2>&1 |") || Error "Can't run command: $!";
726
        while( <CCI> )
745
        while( <CCI> )
727
        {
746
        {
-
 
747
 
728
            s~[\n\r]+$~~;
748
            s~[\n\r]+$~~;
-
 
749
            Verbose3 ("ctd: Data: $_");
729
 
750
 
730
            #
751
            #
731
            #   Blank entry signals new package
752
            #   Blank entry signals new package
732
            #
753
            #
733
            unless ( $_ )
754
            unless ( $_ )
734
            {
755
            {
735
                $line = 0;
756
                $line = 0;
736
                %data = ();
-
 
737
                next;
757
                next;
738
            }
758
            }
739
            $line++;
759
            $line++;
740
 
760
 
741
            #
761
            #
742
            #   Line-1:
762
            #   Line-1:
743
            #   Path to package as seen from current view
763
            #   Path to package as seen from current view
-
 
764
            #   Extract and save the user file name
744
            #
765
            #
745
            if ( $line == 1 )
766
            if ( $line == 1 )
746
            {
767
            {
747
                s{\\}{/}g;
768
                s{\\}{/}g;
748
                s{\s+\(.+\)$}{};
769
                s{\s+\(.+\)$}{};
749
                $data{pname} = $_;
770
                $user_path = $_;
750
                Verbose2 ("ctd: pname: $_");
-
 
751
                next;
771
                next;
752
            }
772
            }
753
 
773
 
754
            #
774
            #
755
            #   Extract the element number
775
            #   Line-2
756
            #   This will be common for each file, independent of the version of the
-
 
757
            #   file. This allows files from different views to be correlated
-
 
758
            #   Line is of the form:
776
            #   Vob Extended Pathname
759
            #   elem=596638  branch=596639  ver num=3  line count=526
777
            #   Mangle with user pathname
760
            #
778
            #
761
            if ( m{^(elem=\d+)} )
779
            if ( $line == 2 )
762
            {
780
            {
-
 
781
                s{\\}{/}g;
-
 
782
                $user_path =~ m{\@\@([^@]+)$};
763
                $data{element} = $1;
783
                my $suffix = $1;
-
 
784
                my $suffix_len = length $suffix;
-
 
785
 
-
 
786
                my $mpn = substr ($_, 0, - $suffix_len ) . '@@' . $suffix;
-
 
787
                push @newids, $mpn;
-
 
788
 
764
                Verbose2 ("ctd: elem: $1");
789
                Verbose2 ("ctd: Line2: $_");
765
                push @newids, {%data};
790
                Verbose2 ("ctd: VEPN : $_");
-
 
791
                Verbose2 ("ctd: OUT  : $mpn");
766
            }
792
            }
-
 
793
 
767
        }
794
        }
768
        close(CCI);
795
        close(CCI);
769
 
796
 
770
        Error("Internal error in getIds(): Only retrieved " . scalar(@newids) . 
797
        Error("Internal error in getIds(): Only retrieved " . scalar(@newids) . 
771
              " IDs from a cleartool dump command for " . scalar(@filesToDump) . " files")
798
              " IDs from a cleartool dump command for " . scalar(@filesToDump) . " files",
-
 
799
              @filesToDump)
772
            if( scalar(@newids) != scalar(@filesToDump) );
800
            if( scalar(@newids) != scalar(@filesToDump) );
773
 
801
 
774
        push @ids, @newids;
802
        push @ids, @newids;
775
    }
803
    }
776
 
804
 
Line 1025... Line 1053...
1025
Prints the manual page and exits.
1053
Prints the manual page and exits.
1026
 
1054
 
1027
=item B<-old=label>
1055
=item B<-old=label>
1028
 
1056
 
1029
This option specifies the old, or base, label for the difference report. This
1057
This option specifies the old, or base, label for the difference report. This
1030
label is mandatory for the difference report.
1058
option is optional for the difference report. If not provided then a one-sided
-
 
1059
difference report will be generated. This is of use for new packages.
1031
 
1060
 
1032
The old and new labels may be provided on the command line, or via named
1061
The old and new labels may be provided on the command line, or via named
1033
options, but not both.
1062
options, but not both.
1034
 
1063
 
1035
The label may be of the form dir=path to force the utility to use a local
1064
The label may be of the form dir=path to force the utility to use a local