Subversion Repositories DevTools

Rev

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

Rev 285 Rev 299
Line 360... Line 360...
360
#
360
#
361
#   Create a clearcase view to be used for the view
361
#   Create a clearcase view to be used for the view
362
#
362
#
363
$VIEWPATH = "$view_prefix$opt_viewname";
363
$VIEWPATH = "$view_prefix$opt_viewname";
364
$VIEWDIR = "$VIEWDIR_ROOT/$VIEWPATH";
364
$VIEWDIR = "$VIEWDIR_ROOT/$VIEWPATH";
-
 
365
$VIEWDIR =~ tr~\\/~/~s;
365
Verbose( "Hostname: $MACHINENAME" );
366
Verbose( "Hostname: $MACHINENAME" );
366
Verbose( "Viewtag: $VIEWTAG" );
367
Verbose( "Viewtag: $VIEWTAG" );
367
Verbose( "Viewpath: $VIEWPATH" );
368
Verbose( "Viewpath: $VIEWPATH" );
368
Verbose( "Viewdir : $VIEWDIR" );
369
Verbose( "Viewdir : $VIEWDIR" );
369
 
370
 
Line 398... Line 399...
398
 
399
 
399
#
400
#
400
#   If the view currently exists then it will be deleted if allowed
401
#   If the view currently exists then it will be deleted if allowed
401
#
402
#
402
delete_view()
403
delete_view()
403
    unless ( $opt_reuse || $opt_extract_files );
404
    unless ( $opt_reuse );
-
 
405
 
404
 
406
 
405
#
407
#
406
#   If the user is simply deleting the view then all has been done
408
#   If the user is simply deleting the view then all has been done
407
#
409
#
408
exit 0
410
exit 0
Line 851... Line 853...
851
{
853
{
852
    my $cofound = 0;
854
    my $cofound = 0;
853
    my $uuid;
855
    my $uuid;
854
 
856
 
855
    #
857
    #
856
    #   If the view physically exists then attempt to phyically remove it
858
    #   Simple delete
857
    #
859
    #
-
 
860
    if ( $opt_extract_files )
-
 
861
    {
858
    if ( -d $VIEWDIR )
862
        if ( -d $VIEWDIR )
-
 
863
        {
-
 
864
            Message("Remove extracted files: $VIEWTAG");
-
 
865
            rmtree( $VIEWDIR );
-
 
866
        }
-
 
867
    }
-
 
868
    else
859
    {
869
    {
860
        #
870
        #
861
        #   Determine if there are any checked out files in the view
871
        #   If the view physically exists then attempt to phyically remove it
862
        #
872
        #
863
        Message("Remove the view: $VIEWTAG");
-
 
864
        Verbose("Look for checked out files");
-
 
865
 
-
 
866
        chdir ( $VIEWDIR );
873
        if ( -d $VIEWDIR )
867
        foreach my $file ( glob ('*') )
-
 
868
        {
874
        {
869
            next if ( $file =~ m~local_dpkg_archive~ );
-
 
870
            next if ( $file =~ m~^view\.~ );
875
            #
871
            if ( -d $file )
876
            #   Determine if there are any checked out files in the view
872
            {
877
            #
873
                Verbose ("Examine $file for checked out files");
878
            Message("Remove the view: $VIEWTAG");
874
                chdir "$VIEWDIR/$file";
879
            Verbose("Look for checked out files");
875
 
880
 
-
 
881
            chdir ( $VIEWDIR );
-
 
882
            foreach my $file ( glob ('*') )
-
 
883
            {
876
                my $cmd = ClearToolCmd('lsco', '-cview', '-rec' );
884
                next if ( $file =~ m~local_dpkg_archive~ );
877
                open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
885
                next if ( $file =~ m~^view\.~ );
878
                while (<CMD>)
886
                if ( -d $file )
879
                {
887
                {
880
                    #
-
 
881
                    #   Filter output from the user
888
                    Verbose ("Examine $file for checked out files");
882
                    #
889
                    chdir "$VIEWDIR/$file";
-
 
890
 
883
                    chomp;
891
                    my $cmd = ClearToolCmd('lsco', '-cview', '-rec' );
884
                    Verbose("lsco: $_");
892
                    open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
885
                    if ( m~checkout version~ )
893
                    while (<CMD>)
886
                    {
894
                    {
-
 
895
                        #
-
 
896
                        #   Filter output from the user
-
 
897
                        #
-
 
898
                        chomp;
-
 
899
                        Verbose("lsco: $_");
-
 
900
                        if ( m~checkout version~ )
-
 
901
                        {
887
                        $cofound++ ;
902
                            $cofound++ ;
888
                        Warning ("Checked out file: $_");
903
                            Warning ("Checked out file: $_");
-
 
904
                        }
889
                    }
905
                    }
-
 
906
                    close(CMD);
890
                }
907
                }
891
                close(CMD);
-
 
892
            }
908
            }
893
        }
-
 
894
 
909
 
895
        Error ("Will not delete view. Checked out files exist")
910
            Error ("Will not delete view. Checked out files exist")
896
            if ( $cofound );
911
                if ( $cofound );
897
 
912
 
898
        #
913
            #
899
        #   Get out of the view
914
            #   Get out of the view
900
        #   Cannot delete the view if we are in it.
915
            #   Cannot delete the view if we are in it.
901
        #
916
            #
902
        chdir ( $user_cwd );
917
            chdir ( $user_cwd );
903
 
918
 
904
        #
919
            #
905
        #   Static views should be removed by dirname, not by tag
920
            #   Static views should be removed by dirname, not by tag
906
        #
921
            #
907
        ClearTool( 'rmview', $VIEWDIR );
922
            ClearTool( 'rmview', $VIEWDIR );
908
 
923
 
909
        #
924
            #
910
        #   Now try to delete the directory
925
            #   Now try to delete the directory
911
        #
926
            #
912
        rmtree( $VIEWDIR );
927
            rmtree( $VIEWDIR );
913
    }
928
        }
914
 
929
 
915
    #
-
 
916
    #   If the view tag still exists then delete the view the hard way
-
 
917
    #   Use 'lsview' to locate the views uuid
-
 
918
    #
-
 
919
    Verbose("Look for View Tag");
-
 
920
    my $cmd = ClearToolCmd ('lsview', '-long', $VIEWTAG );
-
 
921
    open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
-
 
922
    while (<CMD>)
-
 
923
    {
-
 
924
        #
930
        #
-
 
931
        #   If the view tag still exists then delete the view the hard way
925
        #   Filter output from the user
932
        #   Use 'lsview' to locate the views uuid
926
        #
933
        #
-
 
934
        Verbose("Look for View Tag");
-
 
935
        my $cmd = ClearToolCmd ('lsview', '-long', $VIEWTAG );
-
 
936
        open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
-
 
937
        while (<CMD>)
-
 
938
        {
-
 
939
            #
-
 
940
            #   Filter output from the user
-
 
941
            #
927
        chomp;
942
            chomp;
928
        Verbose("lsview: $_");
943
            Verbose("lsview: $_");
929
        $uuid = $1 if ( m~^View uuid:\s+(.*)~ );
944
            $uuid = $1 if ( m~^View uuid:\s+(.*)~ );
930
    }
945
        }
931
    close(CMD);
946
        close(CMD);
932
 
947
 
933
    if ( $uuid )
948
        if ( $uuid )
934
    {
949
        {
935
        Warning ("Deleting view - the hard way");
950
            Warning ("Deleting view - the hard way");
936
        ClearTool( '--Quiet', 'rmview', '-force', '-all', '-uuid', $uuid );
951
            ClearTool( '--Quiet', 'rmview', '-force', '-all', '-uuid', $uuid );
937
        ClearTool( '--Quiet', 'unregister', '-view', '-uuid', $uuid );
952
            ClearTool( '--Quiet', 'unregister', '-view', '-uuid', $uuid );
938
        ClearTool( '--Quiet', 'rmtag','-view', '-all', $VIEWTAG );
953
            ClearTool( '--Quiet', 'rmtag','-view', '-all', $VIEWTAG );
-
 
954
        }
939
    }
955
    }
940
 
956
 
941
 
-
 
942
    Error ("View was not deleted")
957
    Error ("View was not deleted")
943
        if ( -d $VIEWDIR );
958
        if ( -d $VIEWDIR );
944
}
959
}
945
 
960
 
946
#-------------------------------------------------------------------------------
961
#-------------------------------------------------------------------------------