Subversion Repositories DevTools

Rev

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

Rev 385 Rev 1329
Line 77... Line 77...
77
# Inputs          : $self               - Instance data
77
# Inputs          : $self               - Instance data
78
#                   $RepoPath           - Within the repository
78
#                   $RepoPath           - Within the repository
79
#                   $Path               - Local path
79
#                   $Path               - Local path
80
#                   Options             - Options
80
#                   Options             - Options
81
#                           --Export    - Export Only
81
#                           --Export    - Export Only
-
 
82
#                           --NoPrint   - Don't print files exported
82
#
83
#
83
# Returns         : Nothing
84
# Returns         : Nothing
84
#
85
#
85
sub SvnCo
86
sub SvnCo
86
{
87
{
87
    my ($self, $RepoPath, $path, @opts) = @_;
88
    my ($self, $RepoPath, $path, @opts) = @_;
88
    my $export = grep (/^--Export/, @opts );
89
    my $export = grep (/^--Export/, @opts );
-
 
90
    $self->{PRINTDATA} = ! grep (/^--NoPrint/, @opts );
89
    Debug ("SvnCo", $RepoPath, $path);
91
    Debug ("SvnCo", $RepoPath, $path);
90
 
92
 
91
    #
93
    #
92
    #   Ensure that the output path does not exist
94
    #   Ensure that the output path does not exist
93
    #   Do not allow the user to create a local work space
95
    #   Do not allow the user to create a local work space
Line 101... Line 103...
101
    #
103
    #
102
    my @args = $export ? 'export' : 'checkout';
104
    my @args = $export ? 'export' : 'checkout';
103
    push @args, qw( --ignore-externals );
105
    push @args, qw( --ignore-externals );
104
    push @args, $RepoPath, $path;
106
    push @args, $RepoPath, $path;
105
 
107
 
-
 
108
 
106
    my @co_list;
109
    my @co_list;
107
    if ( $self->SvnCmd ( @args,
110
    if ( $self->SvnCmd ( @args,
108
                            {
111
                            {
109
                                'process' => \&ProcessCo,
112
                                'process' => \&ProcessCo,
110
                                'data' => \@co_list,
113
                                'data' => \@co_list,
Line 123... Line 126...
123
        Verbose2 ("Remove WorkSpace: $path");
126
        Verbose2 ("Remove WorkSpace: $path");
124
        rmtree( $path, IsVerbose(3) );
127
        rmtree( $path, IsVerbose(3) );
125
        rmtree( $path, IsVerbose(3) );
128
        rmtree( $path, IsVerbose(3) );
126
        Error ("Checking out Workspace", @{$self->{ERROR_LIST}}, @co_list );
129
        Error ("Checking out Workspace", @{$self->{ERROR_LIST}}, @co_list );
127
    }
130
    }
-
 
131
    $self->{PRINTDATA} = 0;
128
    return;
132
    return;
129
 
133
 
130
    #
134
    #
131
    #   Internal routine to scan each the checkout
135
    #   Internal routine to scan each the checkout
132
    #
136
    #
Line 141... Line 145...
141
    #
145
    #
142
    #
146
    #
143
    sub ProcessCo
147
    sub ProcessCo
144
    {
148
    {
145
        my $self = shift;
149
        my $self = shift;
-
 
150
        my $data = shift;
-
 
151
 
-
 
152
        if ( $self->{PRINTDATA} )
-
 
153
        {
-
 
154
            #
-
 
155
            #   Pretty display for user
-
 
156
            #
-
 
157
            Information1 ("Extracting: $data");
-
 
158
        }
-
 
159
 
146
        if (  m~((/)(tags|branches|trunk)(/|$))~ )
160
        if (  $data =~ m~((/)(tags|branches|trunk)(/|$))~ )
147
        {
161
        {
148
            my $bad_dir = $1;
162
            my $bad_dir = $1;
149
            push @{$self->{ERROR_LIST}}, "Checkout does not describe the root of a package. Contains: $bad_dir";
163
            push @{$self->{ERROR_LIST}}, "Checkout does not describe the root of a package. Contains: $bad_dir";
150
            return 1;
164
            return 1;
151
        }
165
        }
Line 186... Line 200...
186
    Debug ("SvnCi");
200
    Debug ("SvnCi");
187
    Error ("SvnCi: Odd number of args") unless ((@_ % 2) == 0);
201
    Error ("SvnCi: Odd number of args") unless ((@_ % 2) == 0);
188
 
202
 
189
    #
203
    #
190
    #   Validate the source path
204
    #   Validate the source path
191
    #   Note: populates @{$self->{RESULT_LIST}} with 'info' commands
205
    #   Note: populates %{$self->{InfoWs}} with 'info' data
192
    #
206
    #
193
    my $path = SvnValidateWs ($self, 'SvnCi');
207
    my $path = SvnValidateWs ($self, 'SvnCi');
194
 
208
 
195
    #
209
    #
196
    #   Scan the @{$self->{RESULT_LIST}}, which has the results of an 'info'
210
    #   Examine %{$self->{InfoWs}}, which has the results of an 'info'
197
    #   command the locate the URL.
211
    #   command the locate the URL.
198
    #
212
    #
199
    #   This contains the target view space
213
    #   This contains the target view space
200
    #   Sanity test. Don't allow Checkin to a /tags/ area
214
    #   Sanity test. Don't allow Checkin to a /tags/ area
201
    #
215
    #
202
    foreach ( @{$self->{RESULT_LIST}})
216
    $status_url = $self->{InfoWs}{URL};
203
    {
-
 
204
        if ( m~^URL:\s+(.+)~ ) {
-
 
205
            $status_url = $1;
217
    $ws_rev = $self->{InfoWs}{Revision};
206
        } elsif ( m~^Revision:\s+(\d+)~ ) {
-
 
207
            $ws_rev = $1;
-
 
208
        }
-
 
209
 
-
 
210
        last if ( defined $status_url && defined $ws_rev );
-
 
211
    }
-
 
212
 
218
 
213
    Error ("SvnCi: Cannot determine Repositoty URL")
219
    Error ("SvnCi: Cannot determine Repositoty URL")
214
        unless ( $status_url );
220
        unless ( $status_url );
215
 
221
 
216
    Error ("SvnCi: Not allowed to commit to a 'tags' area", "URL: $status_url")
222
    Error ("SvnCi: Not allowed to commit to a 'tags' area", "URL: $status_url")
217
        if ( $status_url =~ m~/tags(/|$)~ );
223
        if ( $status_url =~ m~/tags(/|$)~ );
218
 
224
 
219
    #
225
    #
220
    #   Commit
226
    #   Commit
-
 
227
    #   Will modify Repo, so kill the cached Info
-
 
228
    #   Will only be a real issue if we tag in the same session
221
    #
229
    #
-
 
230
    delete $self->{'InfoWs'};
-
 
231
    delete $self->{'InfoRepo'};
-
 
232
 
222
    $self->SvnCmd ( 'commit', $path
233
    $self->SvnCmd ( 'commit', $path
223
                    , '-m', SvnComment( $opt{'comment'}, 'Created by SvnCi' ),
234
                    , '-m', SvnComment( $opt{'comment'}, 'Created by SvnCi' ),
224
                    , { 'credentials' => 1,
235
                    , { 'credentials' => 1,
225
                        'process' => \&ProcessRevNo,
236
                        'process' => \&ProcessRevNo,
226
                        'error' => "SvnCi: Copy Error",
237
                        'error' => "SvnCi: Copy Error",
Line 547... Line 558...
547
#                   copied. This is a trap.
558
#                   copied. This is a trap.
548
#
559
#
549
#                   Only allow a 'copy' if there are no modified
560
#                   Only allow a 'copy' if there are no modified
550
#                   files in the work space (unless overridden)
561
#                   files in the work space (unless overridden)
551
#
562
#
-
 
563
#                   Only allow a 'copy' if the local workspace is
-
 
564
#                   up to date with respect with the repo. It possible
-
 
565
#                   to do a 'commit' and then a 'copy' (tag) and have
-
 
566
#                   unexpected results as the workspace has not been
-
 
567
#                   updated. This is a trap.
-
 
568
#
552
#
569
#
553
# Inputs          : $self        - Instance data
570
# Inputs          : $self        - Instance data
554
#                   A hash of named arguments
571
#                   A hash of named arguments
555
#                       path     - Path to local workspace
572
#                       path     - Path to local workspace
556
#                       target   - Location within the repository to copy to
573
#                       target   - Location within the repository to copy to
Line 588... Line 605...
588
    #
605
    #
589
    Error ("SvnCopyWs: Target contains a Peg: ($1)", $target)
606
    Error ("SvnCopyWs: Target contains a Peg: ($1)", $target)
590
        if ( $target =~ m~(@\d+)\s*$~ );
607
        if ( $target =~ m~(@\d+)\s*$~ );
591
 
608
 
592
    #
609
    #
-
 
610
    #   Ensure the Workspace is up to date
-
 
611
    #       Determine the state of the Repo and the Workspace
-
 
612
    #
-
 
613
    $self->SvnInfo( $self->{WS} , 'InfoWs' );
-
 
614
    $self->SvnInfo( $self->FullWs, 'InfoRepo' );
-
 
615
 
-
 
616
    my $wsLastChangedRev = $self->{'InfoWs'}{'Last Changed Rev'} || Error ("SvnCopyWs: Bad info for Workspace");
-
 
617
    my $repoLastChangedRev = $self->{'InfoRepo'}{'Last Changed Rev'} || Error ("SvnCopyWs: Bad info for Repository");
-
 
618
 
-
 
619
    Verbose("WS Rev  : $wsLastChangedRev");
-
 
620
    Verbose("Repo Rev: $repoLastChangedRev");
-
 
621
 
-
 
622
    Error ('SvnCopyWs: The repository has been modified since the workspace was last updated.',
-
 
623
           'Possibly caused by a commit without an update.',
-
 
624
           'Update the workspace and try again.',
-
 
625
           "Last Changed Rev. Repo: $repoLastChangedRev. Ws:$wsLastChangedRev") if ( $repoLastChangedRev > $wsLastChangedRev );
-
 
626
 
-
 
627
    #
593
    #   Examine the workspace and ensure that there are no modified
628
    #   Examine the workspace and ensure that there are no modified
594
    #   files - unless they are expected
629
    #   files - unless they are expected
595
    #
630
    #
596
    $self->SvnWsModified ( 'cmd' => 'SvnCopyWs', %opt );
631
    $self->SvnWsModified ( 'cmd' => 'SvnCopyWs', %opt );
597
 
632
 
Line 606... Line 641...
606
                        'comment' => 'Deleted by SvnCopyWs'
641
                        'comment' => 'Deleted by SvnCopyWs'
607
                        );
642
                        );
608
 
643
 
609
    #
644
    #
610
    #   Copy source to destination
645
    #   Copy source to destination
611
    #   It would appear that even though the source is a WorkSpace, the copy
646
    #   Assuming the WorkSpace is up to date then, even though the source is a
612
    #   does not transfer data from the WorkSpace. It appears as though its all
647
    #   WorkSpace, the copy does not transfer data from the WorkSpace.
613
    #   done on the server. This is good - and fast.
648
    #   It appears as though its all done on the server. This is good - and fast.
-
 
649
    #
-
 
650
    #   If the Workspace is not up to date, then files that SVN thinks have not
-
 
651
    #   been transferred will be transferred - hence the need to update after
-
 
652
    #   a commit.
614
    #
653
    #
615
    #   Moreover, files that are modified in the local workspace will
654
    #   Moreover, files that are modified in the local workspace will
616
    #   be copied and checked into the target, but this is not nice.
655
    #   be copied and checked into the target, but this is not nice.
617
    #
656
    #
618
    $self->{PRINTDATA} = 1;
657
    $self->{PRINTDATA} = 1;
Line 748... Line 787...
748
            #
787
            #
749
            #   Extract filename from line
788
            #   Extract filename from line
750
            #       First 8 chars are status
789
            #       First 8 chars are status
751
            #       Remove WS path too
790
            #       Remove WS path too
752
            #
791
            #
-
 
792
            if ( length $entry >= 8 + $path_length)
-
 
793
            {
753
            my $file = substr ( $entry, 8 + $path_length );
794
                my $file = substr ( $entry, 8 + $path_length );
754
            next if ( $allowed{$file} );
795
                next if ( $allowed{$file} );
-
 
796
            }
755
 
797
 
756
            #
798
            #
757
            #   Examine the first char and rule out funny things
799
            #   Examine the first char and rule out funny things
758
            #
800
            #
759
            my $f1 =  substr ($entry, 0,1 );
801
            my $f1 =  substr ($entry, 0,1 );
Line 988... Line 1030...
988
#                   $user           - Optional prefix for error messages
1030
#                   $user           - Optional prefix for error messages
989
#                   $test           - True: Just test, Else Error
1031
#                   $test           - True: Just test, Else Error
990
#
1032
#
991
# Returns         : Will not return if not a workspace
1033
# Returns         : Will not return if not a workspace
992
#                   Returns the users path
1034
#                   Returns the users path
993
#                   @{$self->{RESULT_LIST}} will be populated with info about the
-
 
994
#                   item requested as per an 'info' call
1035
#                   Populates the hash: $self->{InfoWs}
995
#
1036
#
996
sub SvnValidateWs
1037
sub SvnValidateWs
997
{
1038
{
998
    my ($self, $user, $test) = @_;
1039
    my ($self, $user, $test) = @_;
999
    Debug ("SvnValidateWs");
1040
    Debug ("SvnValidateWs");
1000
 
1041
 
1001
    $user = "Invalid Subversion Workspace" unless ( $user );
1042
    $user = "Invalid Subversion Workspace" unless ( $user );
1002
    my $path = $self->{WS} ;
1043
    my $path = $self->{WS};
1003
 
1044
 
1004
    #
1045
    #
1005
    #   Only validate it one
1046
    #   Only validate it once
1006
    #
1047
    #
1007
    return $path if ( $self->{WS_VALIDATED} );
1048
    return $path if ( $self->{WS_VALIDATED} );
1008
 
1049
 
1009
    #
1050
    #
1010
    #   Validate the source path
1051
    #   Validate the source path
Line 1021... Line 1062...
1021
    } else {
1062
    } else {
1022
        #
1063
        #
1023
        #   Determine the source path is an fact a view
1064
        #   Determine the source path is an fact a view
1024
        #   The info command can do this. Use depth empty to limit the work done
1065
        #   The info command can do this. Use depth empty to limit the work done
1025
        #
1066
        #
1026
        $self->SvnCmd ('info', $path, '--depth', 'empty' );
1067
        $self->SvnInfo($path, 'InfoWs');
1027
 
1068
 
1028
        #
1069
        #
1029
        #   Error. Prepend nice message
1070
        #   Error. Prepend nice message
1030
        #
1071
        #
1031
        unshift @{$self->{ERROR_LIST}}, "$user: Path is not a WorkSpace: $path"
1072
        unshift @{$self->{ERROR_LIST}}, "$user: Path is not a WorkSpace: $path"
Line 1210... Line 1251...
1210
    my $self = NewSession();
1251
    my $self = NewSession();
1211
    $self->{WS} = $path;
1252
    $self->{WS} = $path;
1212
 
1253
 
1213
    #
1254
    #
1214
    #   Validate the path provided
1255
    #   Validate the path provided
1215
    #   In the process populate the @{$self->{RESULT_LIST}} with information
1256
    #   In the process populate $self->{InfoWs} with info about the workspace.
1216
    #   about the workspace.
-
 
1217
    #
1257
    #
1218
    if ($self->SvnValidateWs ( undef, 1) )
1258
    if ($self->SvnValidateWs ( undef, 1) )
1219
    {
1259
    {
1220
        return $self if ( $test );
1260
        return $self if ( $test );
1221
        Error ( @{$self->{ERROR_LIST}} );
1261
        Error ( @{$self->{ERROR_LIST}} );
Line 1224... Line 1264...
1224
    #
1264
    #
1225
    #   Extract useful info
1265
    #   Extract useful info
1226
    #       URL: svn://auperaws996vm21/test/MixedView/trunk
1266
    #       URL: svn://auperaws996vm21/test/MixedView/trunk
1227
    #       Repository Root: svn://auperaws996vm21/test
1267
    #       Repository Root: svn://auperaws996vm21/test
1228
    #
1268
    #
1229
    my $url;
1269
    my $url = $self->{'InfoWs'}{'URL'};
1230
    my $reporoot;
1270
    my $reporoot = $self->{'InfoWs'}{'Repository Root'};
1231
    my $repoVersion;
1271
    my $repoVersion = $self->{'InfoWs'}{'Revision'};
1232
 
1272
 
1233
    foreach ( @{$self->{RESULT_LIST}} )
-
 
1234
    {
-
 
1235
        $url = $1 if ( m~^URL:\s+(.+)~ );
-
 
1236
        $reporoot = $1 if ( m~^Repository Root:\s+(.+)~ );
-
 
1237
        $repoVersion = $1 if ( m~^Revision:\s+(.+)~ );
-
 
1238
        last if ( $url && $reporoot && $repoVersion);
-
 
1239
    }
-
 
1240
    Error ("JatsSvn Internal error. Can't parse info")
1273
    Error ("JatsSvn Internal error. Can't parse info")
1241
        unless ( $url && $reporoot );
1274
        unless ( $url && $reporoot );
1242
 
1275
 
1243
    #
1276
    #
1244
    #   Need the length of the path to the repository
1277
    #   Need the length of the path to the repository
Line 1411... Line 1444...
1411
            $url = $1;
1444
            $url = $1;
1412
            $pkgroot = $4;
1445
            $pkgroot = $4;
1413
        }
1446
        }
1414
        elsif ($SVN_URLS{''} )
1447
        elsif ($SVN_URLS{''} )
1415
        {
1448
        {
-
 
1449
            if ( exists $ENV{'GBE_ABT'} && $ENV{'GBE_ABT'})
-
 
1450
            {
-
 
1451
                Error ("Attempt to use default repository within automated build", "Path: " . $rpath);
-
 
1452
            }
1416
            $url = $SVN_URLS{''};
1453
            $url = $SVN_URLS{''};
1417
            $pkgroot = $rpath;
1454
            $pkgroot = $rpath;
1418
        }
1455
        }
1419
        else
1456
        else
1420
        {
1457
        {