Subversion Repositories DevTools

Rev

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

Rev 2429 Rev 2764
Line 537... Line 537...
537
    my $opt_log = '';
537
    my $opt_log = '';
538
    my $opt_branch;
538
    my $opt_branch;
539
    my $opt_datafile;
539
    my $opt_datafile;
540
    my $opt_printfiles;
540
    my $opt_printfiles;
541
    my $opt_commit = 1;
541
    my $opt_commit = 1;
-
 
542
    my $opt_mergePaths;
542
 
543
 
543
    #
544
    #
544
    #   Other globals
545
    #   Other globals
545
    #
546
    #
546
    my $url_label;
547
    my $url_label;
547
    my $url_branch;
548
    my $url_branch;
548
 
549
 
-
 
550
    my $filesBase = 0;                  # Files in Base workspace
-
 
551
    my $filesDeleted = 0;               # Files Deleted
-
 
552
    my $filesAdded = 0;                 # Files Added
-
 
553
    my $filesTransferred = 0;           # Files Copied
-
 
554
    my $dirsDeleted = 0;                # Directories Deleted
-
 
555
    my $dirsAdded = 0;                  # Directories Added
-
 
556
    my $dirsTransferred = 0;            # Directories Copied
-
 
557
    
-
 
558
 
549
    #
559
    #
550
    #   Configuration options
560
    #   Configuration options
551
    #
561
    #
552
    my $result = GetOptions (
562
    my $result = GetOptions (
553
                    'help:+'        => \$opt_help,
563
                    'help:+'        => \$opt_help,
Line 565... Line 575...
565
                    'author=s'      => \$opt_author,
575
                    'author=s'      => \$opt_author,
566
                    'date=s'        => \$opt_date,
576
                    'date=s'        => \$opt_date,
567
                    'log=s'         => \$opt_log,
577
                    'log=s'         => \$opt_log,
568
                    'datafile=s'    => \$opt_datafile,
578
                    'datafile=s'    => \$opt_datafile,
569
                    'commit!'       => \$opt_commit,
579
                    'commit!'       => \$opt_commit,
-
 
580
                    'mergePaths=s'  => \$opt_mergePaths,
570
 
581
 
571
                    #
582
                    #
572
                    #   Update documentation at the end of the file
583
                    #   Update documentation at the end of the file
573
                    #
584
                    #
574
                    ) || Error ("Invalid command line" );
585
                    ) || Error ("Invalid command line" );
Line 683... Line 694...
683
 
694
 
684
    #
695
    #
685
    #   Scan for a source file
696
    #   Scan for a source file
686
    #   Trying to detect empty views
697
    #   Trying to detect empty views
687
    #   Look for file, not directory
698
    #   Look for file, not directory
-
 
699
    #       Keep a count for reporting
688
    #
700
    #
689
    {
701
    {
-
 
702
        foreach ( @ws )
-
 
703
        {
-
 
704
            $filesBase++ unless ( m~/$~ );
-
 
705
        }
-
 
706
 
690
        my $fileFound = 0;
707
        my $fileFound = 0;
691
        foreach ( @dir )
708
        foreach ( @dir )
692
        {
709
        {
693
            next if ( m~/$~ );
710
            next if ( m~/$~ );
694
            $fileFound++;
711
            $fileFound = 1;
695
            last;
712
            last;
696
        }
713
        }
697
 
714
 
698
        unless ( $fileFound )
715
        unless ( $fileFound )
699
        {
716
        {
Line 726... Line 743...
726
        $common{$_} = 1;
743
        $common{$_} = 1;
727
        delete $ws{$_};
744
        delete $ws{$_};
728
        delete $dir{$_};
745
        delete $dir{$_};
729
    }
746
    }
730
 
747
 
-
 
748
    #
-
 
749
    #   Now have:
-
 
750
    #       %ws     - Hash of paths that are only in the Workspace
-
 
751
    #       %dir    - Hash of paths that are only in New Import
-
 
752
    #       %common - Hash of paths that are common to both
-
 
753
    #
731
    #DebugDumpData( 'WS', \%ws );
754
    #DebugDumpData( 'WS', \%ws );
732
    #DebugDumpData( 'DIR', \%dir );
755
    #DebugDumpData( 'DIR', \%dir );
733
    #DebugDumpData( 'COMMON', \%common );
756
    #DebugDumpData( 'COMMON', \%common );
734
 
757
 
-
 
758
 
735
    #
759
    #
736
    #   Need to consider the case where a file has been replaced with a directory
760
    #   Need to consider the case where a file has been replaced with a directory
737
    #   and visa-versa. Delete files and directories first.
761
    #   and visa-versa. Delete files and directories first.
738
    #
762
    #
739
    #
763
    #
740
    #   Remove files
764
    #   Remove files
741
    #   Sort in reverse. This will ensure that we process directory
765
    #   Sort in reverse. This will ensure that we process directory
742
    #   contents before directories
766
    #   contents before directories
743
    #
767
    #
-
 
768
    
744
    my @rm_files = reverse sort keys %ws;
769
    my @rm_files = reverse sort keys %ws;
745
    if ( @rm_files )
770
    if ( @rm_files )
746
    {
771
    {
-
 
772
        #
-
 
773
        #   Calculate new top level paths
-
 
774
        #   These are of the form xxxxx/
-
 
775
        #
-
 
776
        my @newTldPaths;
-
 
777
        if ( $opt_mergePaths )
-
 
778
        {
-
 
779
            foreach  ( @rm_files)
-
 
780
            {
-
 
781
                push (@newTldPaths, $1 ) if ( m~^([^/]+)/$~ );
-
 
782
            }
-
 
783
        }
-
 
784
 
-
 
785
        my @processedFiles;
747
        foreach my $file ( @rm_files  )
786
        foreach my $file ( @rm_files  )
748
        {
787
        {
-
 
788
            #
-
 
789
            #   Detect items that are to be retained
-
 
790
            #   Do not delete items that are a part of a top level path that
-
 
791
            #   is not present in the New Import
-
 
792
            #
-
 
793
            if ( $opt_mergePaths )
-
 
794
            {
-
 
795
                my $keep = 0;
-
 
796
                foreach ( @newTldPaths )
-
 
797
                {
-
 
798
                    if ( $file =~ m~^$_/~ )
-
 
799
                    {
-
 
800
                        Verbose("Not deleting: $file");
-
 
801
                        $keep = 1;
-
 
802
                        last;
-
 
803
                    }
-
 
804
                }
-
 
805
                next if ($keep);
-
 
806
            }
-
 
807
 
749
            Verbose ("Removing $file");
808
            Verbose ("Removing $file");
-
 
809
            $filesDeleted++ unless ( $file =~ m~/$~ );
-
 
810
            $dirsDeleted++ if ( $file =~ m~/$~ );
750
            unlink "$opt_workdir/$file";
811
            unlink "$opt_workdir/$file";
-
 
812
            push @processedFiles, $file;
751
        }
813
        }
-
 
814
        @rm_files = @processedFiles;
752
 
815
 
753
        #
816
        #
754
        #   Inform Subversion about the removed files
817
        #   Inform Subversion about the removed files
755
        #
818
        #
756
        my $base = 0;
819
        my $base = 0;
757
        my $num = $#rm_files;
820
        my $num = $#rm_files;
758
        Message ("Update the workspace: Removed " . ($num + 1) . " Files");
821
        Message ("Update the workspace: Removed $filesDeleted Files, $dirsDeleted directories");
759
 
822
 
760
        while ( $base <= $num )
823
        while ( $base <= $num )
761
        {
824
        {
762
            my $end = $base + 200;
825
            my $end = $base + 200;
763
            $end = $num if ( $end > $num );
826
            $end = $num if ( $end > $num );
Line 777... Line 840...
777
    #   This will ensure we process parent directories first
840
    #   This will ensure we process parent directories first
778
    #
841
    #
779
    my @added = sort keys %dir;
842
    my @added = sort keys %dir;
780
    if ( @added )
843
    if ( @added )
781
    {
844
    {
-
 
845
        my @processedFiles;
782
        foreach my $file ( @added  )
846
        foreach my $file ( @added  )
783
        {
847
        {
-
 
848
            #
-
 
849
            #   Detect items that are to be merged
-
 
850
            #   Only specified top level paths are to be imported
-
 
851
            #
-
 
852
            if ( $opt_mergePaths )
-
 
853
            {
-
 
854
                my $discard = 1;
-
 
855
                foreach ( split(',', $opt_mergePaths) )
-
 
856
                {
-
 
857
                    if ( $_ eq '+' )
-
 
858
                    {
-
 
859
                        if ( ($file =~ tr~/~/~) eq 0 )
-
 
860
                        {
-
 
861
                            $discard = 0;
-
 
862
                            last;
-
 
863
                        }
-
 
864
                    }
-
 
865
                    elsif ( $file =~ m~^$_/~ )
-
 
866
                    {
-
 
867
                        $discard = 0;
-
 
868
                        last;
-
 
869
                    }
-
 
870
                }
-
 
871
                Verbose0("Not Importing: $file") if ( $discard ) ;
-
 
872
                next if ( $discard );
-
 
873
            }
-
 
874
 
784
            my $src = "$opt_dir/$file";
875
            my $src = "$opt_dir/$file";
785
            my $target = "$opt_workdir/$file";
876
            my $target = "$opt_workdir/$file";
-
 
877
            $filesAdded++ unless ( $file =~ m~/$~ );
-
 
878
            $dirsAdded++ if ( $file =~ m~/$~ );
-
 
879
            push @processedFiles, $file;
786
 
880
 
787
            if ( -d $src )
881
            if ( -d $src )
788
            {
882
            {
789
                Verbose ("Adding directory: $file");
883
                Verbose ("Adding directory: $file");
790
                mkdir ( $target ) unless (-d $target);
884
                mkdir ( $target ) unless (-d $target);
Line 800... Line 894...
800
                {
894
                {
801
                    Error("Failed to transfer file [$file]: $!");
895
                    Error("Failed to transfer file [$file]: $!");
802
                }
896
                }
803
            }
897
            }
804
        }
898
        }
-
 
899
        @added = @processedFiles;
805
 
900
        
806
        #
901
        #
807
        #   Inform Subversion about the added files
902
        #   Inform Subversion about the added files
808
        #   The command line does have a finite length, so add them 200 at a
903
        #   The command line does have a finite length, so add them 200 at a
809
        #   time.
904
        #   time.
810
        #
905
        #
811
 
906
 
812
        my $base = 0;
907
        my $base = 0;
813
        my $num = $#added;
908
        my $num = $#added;
814
        Message ("Update the workspace: Added " . (1 + $num) . " files");
909
        Message ("Update the workspace: Added $filesAdded Files, $dirsAdded directories");
815
 
910
 
816
        while ( $base <= $num )
911
        while ( $base <= $num )
817
        {
912
        {
818
            my $end = $base + 200;
913
            my $end = $base + 200;
819
            $end = $num if ( $end > $num );
914
            $end = $num if ( $end > $num );
Line 835... Line 930...
835
    foreach my $file ( sort keys %common  )
930
    foreach my $file ( sort keys %common  )
836
    {
931
    {
837
        my $src = "$opt_dir/$file";
932
        my $src = "$opt_dir/$file";
838
        my $target = "$opt_workdir/$file";
933
        my $target = "$opt_workdir/$file";
839
 
934
 
-
 
935
        $filesTransferred++ unless ( $file =~ m~/$~ );
-
 
936
        $dirsTransferred++ if ( $file =~ m~/$~ );
-
 
937
        
840
        next if ( -d $src );
938
        next if ( -d $src );
841
        if ( File::Compare::compare ($src, $target) )
939
        if ( File::Compare::compare ($src, $target) )
842
        {
940
        {
843
            Verbose ("Transfer $file");
941
            Verbose ("Transfer $file");
844
            unlink $target;
942
            unlink $target;
Line 848... Line 946...
848
                      "Src: $src",
946
                      "Src: $src",
849
                      "Tgt: $target");
947
                      "Tgt: $target");
850
            }
948
            }
851
        }
949
        }
852
    }
950
    }
-
 
951
    Message ("Update the workspace: Transferred $filesTransferred Files, $dirsTransferred directories")
-
 
952
        if ($filesTransferred);
853
 
953
 
854
    #
954
    #
855
    #   Commit the workspace
955
    #   Commit the workspace
856
    #   This will go back onto the trunk
956
    #   This will go back onto the trunk
857
    #
957
    #
Line 914... Line 1014...
914
        $data->setProperty('Command'        , 'ImportPackage');
1014
        $data->setProperty('Command'        , 'ImportPackage');
915
        $data->setProperty('Label'          , $opt_label);
1015
        $data->setProperty('Label'          , $opt_label);
916
        $data->setProperty('subversion.url' , $svn->RmRef);
1016
        $data->setProperty('subversion.url' , $svn->RmRef);
917
        $data->setProperty('subversion.tag' , $svn->SvnTag);
1017
        $data->setProperty('subversion.tag' , $svn->SvnTag);
918
 
1018
 
-
 
1019
        $data->setProperty('files.base'     , $filesBase);
-
 
1020
        $data->setProperty('files.removed'  , $filesDeleted);
-
 
1021
        $data->setProperty('files.added'    , $filesAdded);
-
 
1022
 
919
        $data->Dump('InfoFile') if ($opt_verbose);
1023
        $data->Dump('InfoFile') if ($opt_verbose);
920
        $data->store( $opt_datafile );
1024
        $data->store( $opt_datafile );
921
    }
1025
    }
922
 
1026
 
923
    $opr_done = 1;
1027
    $opr_done = 1;
Line 1861... Line 1965...
1861
    -date=dateString        - Force date of changes
1965
    -date=dateString        - Force date of changes
1862
    -log=text               - Append text to the commit message
1966
    -log=text               - Append text to the commit message
1863
    -datafile=path          - Export tag data for automation
1967
    -datafile=path          - Export tag data for automation
1864
    -[no]commit             - Prevent chnages being commited. Default:Yes
1968
    -[no]commit             - Prevent chnages being commited. Default:Yes
1865
    -printfiles=n           - Control commit verbosity
1969
    -printfiles=n           - Control commit verbosity
-
 
1970
    -mergePaths=dirList     - Comma separated list of directores to merge
1866
 
1971
 
1867
=head2 ARGUMENTS
1972
=head2 ARGUMENTS
1868
 
1973
 
1869
The command takes one argument: The URL of the desired package.
1974
The command takes one argument: The URL of the desired package.
1870
This may be be:
1975
This may be be:
Line 1985... Line 2090...
1985
This option controls commit verbosity. The default operation is to display
2090
This option controls commit verbosity. The default operation is to display
1986
the files added and removed during the commit.
2091
the files added and removed during the commit.
1987
 
2092
 
1988
Suitable numbers are: None, 0 (No Display) and 1 (Full Display).
2093
Suitable numbers are: None, 0 (No Display) and 1 (Full Display).
1989
 
2094
 
-
 
2095
=item -mergePaths=dirList
-
 
2096
 
-
 
2097
This option specifies a Comma separated list of directores to be merged
-
 
2098
during the import process. This works as via the following mechanism:
-
 
2099
 
-
 
2100
If the named directory exists in the 'new' image it will replace that in the
-
 
2101
'initial' workspace.
-
 
2102
 
-
 
2103
If the named directory does not exist in the 'new' image, but does exist in the
-
 
2104
'initial' image then it will be retained in the 'final' image.
-
 
2105
 
-
 
2106
Directories other than those named will not be imported.
-
 
2107
 
1990
=back
2108
=back
1991
 
2109
 
1992
=head2 DESCRIPTION
2110
=head2 DESCRIPTION
1993
 
2111
 
1994
Import a new version of a package to the trunk of the package. The utility
2112
Import a new version of a package to the trunk of the package. The utility