Subversion Repositories DevTools

Rev

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

Rev 2616 Rev 2652
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_nodelete;
542
    my $opt_mergePaths;
543
 
543
 
544
    #
544
    #
545
    #   Other globals
545
    #   Other globals
546
    #
546
    #
547
    my $url_label;
547
    my $url_label;
548
    my $url_branch;
548
    my $url_branch;
549
 
549
 
550
    my $filesBase = 0;                  # Files in Base workspace
550
    my $filesBase = 0;                  # Files in Base workspace
551
    my $filesDeleted = 0;               # Files Deleted
551
    my $filesDeleted = 0;               # Files Deleted
552
    my $filesAdded = 0;                 # Files Added
552
    my $filesAdded = 0;                 # Files Added
-
 
553
    my $filesTransferred = 0;           # Files Copied
553
    my $dirsDeleted = 0;                # Directories Deleted
554
    my $dirsDeleted = 0;                # Directories Deleted
554
    my $dirsAdded = 0;                  # Directories Added
555
    my $dirsAdded = 0;                  # Directories Added
-
 
556
    my $dirsTransferred = 0;            # Directories Copied
555
    
557
    
556
 
558
 
557
    #
559
    #
558
    #   Configuration options
560
    #   Configuration options
559
    #
561
    #
Line 573... Line 575...
573
                    'author=s'      => \$opt_author,
575
                    'author=s'      => \$opt_author,
574
                    'date=s'        => \$opt_date,
576
                    'date=s'        => \$opt_date,
575
                    'log=s'         => \$opt_log,
577
                    'log=s'         => \$opt_log,
576
                    'datafile=s'    => \$opt_datafile,
578
                    'datafile=s'    => \$opt_datafile,
577
                    'commit!'       => \$opt_commit,
579
                    'commit!'       => \$opt_commit,
578
                    'nodelete=s'    => \$opt_nodelete,
580
                    'mergePaths=s'  => \$opt_mergePaths,
579
 
581
 
580
                    #
582
                    #
581
                    #   Update documentation at the end of the file
583
                    #   Update documentation at the end of the file
582
                    #
584
                    #
583
                    ) || Error ("Invalid command line" );
585
                    ) || Error ("Invalid command line" );
Line 741... Line 743...
741
        $common{$_} = 1;
743
        $common{$_} = 1;
742
        delete $ws{$_};
744
        delete $ws{$_};
743
        delete $dir{$_};
745
        delete $dir{$_};
744
    }
746
    }
745
 
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
    #
746
    #DebugDumpData( 'WS', \%ws );
754
    #DebugDumpData( 'WS', \%ws );
747
    #DebugDumpData( 'DIR', \%dir );
755
    #DebugDumpData( 'DIR', \%dir );
748
    #DebugDumpData( 'COMMON', \%common );
756
    #DebugDumpData( 'COMMON', \%common );
749
 
757
 
-
 
758
 
750
    #
759
    #
751
    #   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
752
    #   and visa-versa. Delete files and directories first.
761
    #   and visa-versa. Delete files and directories first.
753
    #
762
    #
754
    #
763
    #
Line 756... Line 765...
756
    #   Sort in reverse. This will ensure that we process directory
765
    #   Sort in reverse. This will ensure that we process directory
757
    #   contents before directories
766
    #   contents before directories
758
    #
767
    #
759
    
768
    
760
    my @rm_files = reverse sort keys %ws;
769
    my @rm_files = reverse sort keys %ws;
761
    my @noDelete = split(',', $opt_nodelete);
-
 
762
    if ( @rm_files )
770
    if ( @rm_files )
763
    {
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
 
764
        my @processedFiles;
785
        my @processedFiles;
765
        foreach my $file ( @rm_files  )
786
        foreach my $file ( @rm_files  )
766
        {
787
        {
767
            #
788
            #
768
            #   Detect items that are to be retained
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
769
            #
792
            #
770
            if ( $opt_nodelete )
793
            if ( $opt_mergePaths )
771
            {
794
            {
772
                my $keep = 0;
795
                my $keep = 0;
773
                foreach ( @noDelete )
796
                foreach ( @newTldPaths )
774
                {
797
                {
775
                    if ( $file =~ m~(^|/)$_(/|$)~ )
798
                    if ( $file =~ m~^$_/~ )
776
                    {
799
                    {
777
#                        Verbose0("Not deleting: $file");
800
                        Verbose("Not deleting: $file");
778
                        $keep = 1;
801
                        $keep = 1;
779
                        last;
802
                        last;
780
                    }
803
                    }
781
                }
804
                }
782
                next if ($keep);
805
                next if ($keep);
Line 817... Line 840...
817
    #   This will ensure we process parent directories first
840
    #   This will ensure we process parent directories first
818
    #
841
    #
819
    my @added = sort keys %dir;
842
    my @added = sort keys %dir;
820
    if ( @added )
843
    if ( @added )
821
    {
844
    {
-
 
845
        my @processedFiles;
822
        foreach my $file ( @added  )
846
        foreach my $file ( @added  )
823
        {
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 ( $file =~ m~^$_/~ )
-
 
858
                    {
-
 
859
                        $discard = 0;
-
 
860
                        last;
-
 
861
                    }
-
 
862
                }
-
 
863
                Verbose("Not Importing: $file") if ( $discard ) ;
-
 
864
                next if ( $discard );
-
 
865
            }
-
 
866
 
824
            my $src = "$opt_dir/$file";
867
            my $src = "$opt_dir/$file";
825
            my $target = "$opt_workdir/$file";
868
            my $target = "$opt_workdir/$file";
826
            $filesAdded++ unless ( $file =~ m~/$~ );
869
            $filesAdded++ unless ( $file =~ m~/$~ );
827
            $dirsAdded++ if ( $file =~ m~/$~ );
870
            $dirsAdded++ if ( $file =~ m~/$~ );
-
 
871
            push @processedFiles, $file;
828
 
872
 
829
            if ( -d $src )
873
            if ( -d $src )
830
            {
874
            {
831
                Verbose ("Adding directory: $file");
875
                Verbose ("Adding directory: $file");
832
                mkdir ( $target ) unless (-d $target);
876
                mkdir ( $target ) unless (-d $target);
Line 842... Line 886...
842
                {
886
                {
843
                    Error("Failed to transfer file [$file]: $!");
887
                    Error("Failed to transfer file [$file]: $!");
844
                }
888
                }
845
            }
889
            }
846
        }
890
        }
-
 
891
        @added = @processedFiles;
847
 
892
        
848
        #
893
        #
849
        #   Inform Subversion about the added files
894
        #   Inform Subversion about the added files
850
        #   The command line does have a finite length, so add them 200 at a
895
        #   The command line does have a finite length, so add them 200 at a
851
        #   time.
896
        #   time.
852
        #
897
        #
Line 877... Line 922...
877
    foreach my $file ( sort keys %common  )
922
    foreach my $file ( sort keys %common  )
878
    {
923
    {
879
        my $src = "$opt_dir/$file";
924
        my $src = "$opt_dir/$file";
880
        my $target = "$opt_workdir/$file";
925
        my $target = "$opt_workdir/$file";
881
 
926
 
-
 
927
        $filesTransferred++ unless ( $file =~ m~/$~ );
-
 
928
        $dirsTransferred++ if ( $file =~ m~/$~ );
-
 
929
        
882
        next if ( -d $src );
930
        next if ( -d $src );
883
        if ( File::Compare::compare ($src, $target) )
931
        if ( File::Compare::compare ($src, $target) )
884
        {
932
        {
885
            Verbose ("Transfer $file");
933
            Verbose ("Transfer $file");
886
            unlink $target;
934
            unlink $target;
Line 890... Line 938...
890
                      "Src: $src",
938
                      "Src: $src",
891
                      "Tgt: $target");
939
                      "Tgt: $target");
892
            }
940
            }
893
        }
941
        }
894
    }
942
    }
-
 
943
    Message ("Update the workspace: Transferred $filesTransferred Files, $dirsTransferred directories")
-
 
944
        if ($filesTransferred);
895
 
945
 
896
    #
946
    #
897
    #   Commit the workspace
947
    #   Commit the workspace
898
    #   This will go back onto the trunk
948
    #   This will go back onto the trunk
899
    #
949
    #
Line 1907... Line 1957...
1907
    -date=dateString        - Force date of changes
1957
    -date=dateString        - Force date of changes
1908
    -log=text               - Append text to the commit message
1958
    -log=text               - Append text to the commit message
1909
    -datafile=path          - Export tag data for automation
1959
    -datafile=path          - Export tag data for automation
1910
    -[no]commit             - Prevent chnages being commited. Default:Yes
1960
    -[no]commit             - Prevent chnages being commited. Default:Yes
1911
    -printfiles=n           - Control commit verbosity
1961
    -printfiles=n           - Control commit verbosity
1912
    -nodelete=dirList       - Comma separated list of directores to retain
1962
    -mergePaths=dirList     - Comma separated list of directores to merge
1913
 
1963
 
1914
=head2 ARGUMENTS
1964
=head2 ARGUMENTS
1915
 
1965
 
1916
The command takes one argument: The URL of the desired package.
1966
The command takes one argument: The URL of the desired package.
1917
This may be be:
1967
This may be be:
Line 2032... Line 2082...
2032
This option controls commit verbosity. The default operation is to display
2082
This option controls commit verbosity. The default operation is to display
2033
the files added and removed during the commit.
2083
the files added and removed during the commit.
2034
 
2084
 
2035
Suitable numbers are: None, 0 (No Display) and 1 (Full Display).
2085
Suitable numbers are: None, 0 (No Display) and 1 (Full Display).
2036
 
2086
 
2037
=item -nodelete=dirList
2087
=item -mergePaths=dirList
2038
 
2088
 
2039
This option specifies a Comma separated list of directores to be retained
2089
This option specifies a Comma separated list of directores to be merged
2040
during the import process. This works as via the following mechanism:
2090
during the import process. This works as via the following mechanism:
2041
 
2091
 
2042
If the named directory exists in the 'new' image it will replace that in the
2092
If the named directory exists in the 'new' image it will replace that in the
2043
'initial' workspace.
2093
'initial' workspace.
2044
 
2094
 
2045
If the named directory does not exist in the 'new' image, but does exist in the
2095
If the named directory does not exist in the 'new' image, but does exist in the
2046
'initial' image then it will be retained in the 'final' image.
2096
'initial' image then it will be retained in the 'final' image.
2047
 
2097
 
-
 
2098
Directories other than those named will not be imported.
-
 
2099
 
2048
=back
2100
=back
2049
 
2101
 
2050
=head2 DESCRIPTION
2102
=head2 DESCRIPTION
2051
 
2103
 
2052
Import a new version of a package to the trunk of the package. The utility
2104
Import a new version of a package to the trunk of the package. The utility