Subversion Repositories DevTools

Rev

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

Rev 7320 Rev 7323
Line 724... Line 724...
724
#                   Only allow a 'copy' if the local workspace is
724
#                   Only allow a 'copy' if the local workspace is
725
#                   up to date with respect with the repo. It possible
725
#                   up to date with respect with the repo. It possible
726
#                   to do a 'commit' and then a 'copy' (tag) and have
726
#                   to do a 'commit' and then a 'copy' (tag) and have
727
#                   unexpected results as the workspace has not been
727
#                   unexpected results as the workspace has not been
728
#                   updated. This is a trap.
728
#                   updated. This is a trap.
-
 
729
#                   
-
 
730
#                   Only allow a 'copy' if the local workspace NOT a
-
 
731
#                   mixed workspace. A mixed workspace will have 
-
 
732
#                   unexpected results - files will be added/deleted/moved
-
 
733
#                   on 'tags' but not appear on the source branch. 
-
 
734
#                   This is a trap.
729
#
735
#
730
#
736
#
731
# Inputs          : $self        - Instance data
737
# Inputs          : $self               - Instance data
732
#                   A hash of named arguments
738
#                   A hash of named arguments
733
#                       path     - Path to local workspace
739
#                       path            - Path to local workspace
734
#                       target   - Location within the repository to copy to
740
#                       target          - Location within the repository to copy to
735
#                       comment  - Commit comment
741
#                       comment         - Commit comment
736
#                       modified - Array of files that are allowed to
742
#                       modified        - Array of files that are allowed to
737
#                                  be modified in the workspace.
743
#                                         be modified in the workspace.
738
#                       noswitch        - True: Don't switch to the new URL
744
#                       noswitch        - True: Don't switch to the new URL
739
#                       replace         - True: Delete existing tag if present
745
#                       replace         - True: Delete existing tag if present
740
#                       allowLocalMods  - True: Allow complex tagging
746
#                       allowLocalMods  - True: Allow complex tagging
741
#                       noupdatecheck   - True: Do not check that the WS is up to date
747
#                       noupdatecheck   - True: Do not check that the WS is up to date
742
#
748
#
Line 766... Line 772...
766
    #   Cannot have a 'peg'
772
    #   Cannot have a 'peg'
767
    #
773
    #
768
    Error ("SvnCopyWs: Target contains a Peg: ($1)", $target)
774
    Error ("SvnCopyWs: Target contains a Peg: ($1)", $target)
769
        if ( $target =~ m~(@\d+)\s*$~ );
775
        if ( $target =~ m~(@\d+)\s*$~ );
770
 
776
 
-
 
777
 
-
 
778
    #
-
 
779
    #   Ensure the workspace is not Mixed
-
 
780
    #   Perform an svn info -R and ensure that all files are at the same 'Revision'
-
 
781
    #       Note: can't use the --show-item option as not all versions of svn support this
-
 
782
    #   
-
 
783
    unless ( $opt{allowLocalMods} )
-
 
784
    {
-
 
785
        Verbose "Ensure workspace does not contain Mixed Revisions";
-
 
786
        $rv = $self->SvnCmd ( 'info', '-R' , $path
-
 
787
                            , { 'process' => \&ProcessMixedRev,
-
 
788
                                'nosavedata' => 1,
-
 
789
                                'printdata' => 0,
-
 
790
                                 }
-
 
791
                            );
-
 
792
        if ($rv)
-
 
793
        {
-
 
794
            my @err1 = @{$self->{ERROR_LIST}};
-
 
795
            Error ("SvnCopyWs: Check Mixed Versions", @err1);
-
 
796
        }
-
 
797
 
-
 
798
        if ($self->{'MixedRev'} )
-
 
799
        {
-
 
800
            Error ('SvnCopyWs: The Workspace contains mixed revision.',
-
 
801
                   'This will result in file changes being made on the \'tags\' path and not',
-
 
802
                   'correctly represented on the branch/trunk.',
-
 
803
                   'Update the workspace and try again.');
-
 
804
        }
-
 
805
    }
-
 
806
 
771
    #
807
    #
772
    #   Ensure the Workspace is up to date
808
    #   Ensure the Workspace is up to date
773
    #       Determine the state of the Repo and the Workspace
809
    #       Determine the state of the Repo and the Workspace
774
    #
810
    #
775
    unless ( $opt{noupdatecheck} )
811
    unless ( $opt{noupdatecheck} )
Line 822... Line 858...
822
                        , $target
858
                        , $target
823
                        , '--parents'
859
                        , '--parents'
824
                        , '-m', SvnComment( $opt{'comment'}, 'Created by SvnCopyWs' ),
860
                        , '-m', SvnComment( $opt{'comment'}, 'Created by SvnCopyWs' ),
825
                        , { 'process' => \&ProcessRevNo,
861
                        , { 'process' => \&ProcessRevNo,
826
                            'credentials' => 1,
862
                            'credentials' => 1,
827
                            'printdata' => 1,
863
                            'printdata' => 0,
828
                             }
864
                             }
829
                        );
865
                        );
830
    if ($rv)
866
    if ($rv)
831
    {
867
    {
832
        #
868
        #
Line 867... Line 903...
867
    #Message ("Tag is: " . $self->{RMREF} );
903
    #Message ("Tag is: " . $self->{RMREF} );
868
    return $self->{RMREF} ;
904
    return $self->{RMREF} ;
869
}
905
}
870
 
906
 
871
#-------------------------------------------------------------------------------
907
#-------------------------------------------------------------------------------
-
 
908
# Function        : ProcessMixedRev 
-
 
909
#
-
 
910
# Description     : Process svn output looking for mixed revisions in the workspace
-
 
911
#                   Just interested in the 'Revision:' of each file
-
 
912
#                   Really just want to know if there is more than one revision
-
 
913
#                   workspace.
-
 
914
#
-
 
915
# Inputs          : $self           - Class Data
-
 
916
#                   $line           - Input data to parse
-
 
917
#
-
 
918
# Returns         : 0 - Do not terminate input command
-
 
919
#
-
 
920
sub ProcessMixedRev
-
 
921
{
-
 
922
    my ($self, $line ) = @_;
-
 
923
    Message ( $line ) if $self->{PRINTDATA};
-
 
924
 
-
 
925
    $line =~ s~\s+$~~;
-
 
926
    return 0 unless ( $line );
-
 
927
    return 0 unless ($line =~ m~^Revision:\s*(\d+)~);
-
 
928
    my $revNo = $1;
-
 
929
 
-
 
930
     my $revNoStash =  \%{$self->{revNoStash}};
-
 
931
     $revNoStash->{$revNo}++;
-
 
932
 
-
 
933
     if (scalar keys %{$revNoStash} > 1 ) {
-
 
934
         $self->{'MixedRev'} = 1;
-
 
935
         return 1;
-
 
936
     }
-
 
937
    return 0;
-
 
938
}
-
 
939
 
-
 
940
 
-
 
941
#-------------------------------------------------------------------------------
872
# Function        : SvnWsModified
942
# Function        : SvnWsModified
873
#
943
#
874
# Description     : Test a Workspace for modified files
944
# Description     : Test a Workspace for modified files
875
#                   Allow some files to be modified
945
#                   Allow some files to be modified
876
#
946
#
Line 1124... Line 1194...
1124
{
1194
{
1125
    my ($self, $test) = @_;
1195
    my ($self, $test) = @_;
1126
    my @path;
1196
    my @path;
1127
    my $path = $self->{WS};
1197
    my $path = $self->{WS};
1128
    my $found;
1198
    my $found;
-
 
1199
    my $rv;
1129
 
1200
 
1130
    Debug ("SvnLocateWsRoot");
1201
    Debug ("SvnLocateWsRoot");
1131
    Error ("SvnLocateWsRoot: No Workspace") unless ( $path  );
1202
    Error ("SvnLocateWsRoot: No Workspace") unless ( $path  );
1132
    Verbose2 ("SvnLocateWsRoot: Start in $path");
1203
    Verbose2 ("SvnLocateWsRoot($test): Start in $path");
1133
 
1204
 
1134
    #
1205
    #
1135
    #   Validate the source path
1206
    #   Validate the source path
1136
    #
1207
    #
1137
    if ( SvnValidateWs ($self, 'SvnLocateWsRoot', $test) )
1208
    $rv = SvnValidateWs ($self, 'SvnLocateWsRoot', $test);
-
 
1209
    if ( $test && $rv )
1138
    {
1210
    {
-
 
1211
        Verbose2("SvnLocateWsRoot: Invalid path: $rv");
1139
        return undef;
1212
        return undef;
1140
    }
1213
    }
1141
 
1214
 
1142
    #
1215
    #
1143
    #   Under Subversion 1.7 the process is a lot easier
1216
    #   Under Subversion 1.7 the process is a lot easier
Line 2270... Line 2343...
2270
        }
2343
        }
2271
    }
2344
    }
2272
 
2345
 
2273
    #
2346
    #
2274
    #   Return 0 to keep on going
2347
    #   Return 0 to keep on going
-
 
2348
    return 0;
-
 
2349
}
-
 
2350
 
-
 
2351
#-------------------------------------------------------------------------------
-
 
2352
# Function        :  
-
 
2353
#
-
 
2354
# Description     : Examine the current workspace and exact information about its
-
 
2355
#                   parent.
-
 
2356
#                   
-
 
2357
#                   Does not extract the entire log history - just the last copyfrom
-
 
2358
#
-
 
2359
# Inputs          : $self
-
 
2360
#
-
 
2361
# Returns         : Nothing
-
 
2362
#                   Will add {InfoWsExtra} to the session handle
-
 
2363
#
-
 
2364
sub getWsExtraInfo
-
 
2365
{
-
 
2366
    my $self = shift;
-
 
2367
#DebugDumpData("getWsExtraInfo", $self);
-
 
2368
 
-
 
2369
    my $path;
-
 
2370
    if (exists $self->{InfoWs}{Path}) {
-
 
2371
        $path = $self->{InfoWs}{Path}; 
-
 
2372
    } else {
-
 
2373
        $path = $self->Full();
-
 
2374
    }
-
 
2375
 
-
 
2376
 
-
 
2377
    #
-
 
2378
    #   Determine the source of the merge
-
 
2379
    #   Create a hash entry to store working data
-
 
2380
    # 
-
 
2381
    $self->{btData} = {};
-
 
2382
    $self->SvnCmd ( 'log', '-v', '--xml', '--stop-on-copy', '--limit', '1', '-r0:HEAD', $path
-
 
2383
                    , { 'process' => \&ProcessWsExtraInfo,
-
 
2384
                        'credentials' => 1
-
 
2385
                         }
-
 
2386
                        );
-
 
2387
 
-
 
2388
    # Grab the first entry of the log array - should only be one
-
 
2389
    #
-
 
2390
    $self->{InfoWsExtra} = $self->{btData}{Data}[0];
-
 
2391
    delete $self->{btData};
-
 
2392
}
-
 
2393
 
-
 
2394
#-------------------------------------------------------------------------------
-
 
2395
# Function        : ProcessWsExtraInfo
-
 
2396
#
-
 
2397
# Description     :
-
 
2398
#                   Parse
-
 
2399
#                       <logentry
-
 
2400
#                          revision="24272">
-
 
2401
#                       <author>bivey</author>
-
 
2402
#                       <date>2005-07-25T15:45:35.000000Z</date>
-
 
2403
#                       <paths>
-
 
2404
#                       <path
-
 
2405
#                          prop-mods="false"
-
 
2406
#                          text-mods="false"
-
 
2407
#                          kind="dir"
-
 
2408
#                          copyfrom-path="/enqdef/branches/Stockholm"
-
 
2409
#                          copyfrom-rev="24271"
-
 
2410
#                          action="A">/enqdef/tags/enqdef_24.0.1.sls</path>
-
 
2411
#                       </paths>
-
 
2412
#                       <msg>COTS/enqdef: Tagged by Jats Svn Import</msg>
-
 
2413
#                       </logentry>
-
 
2414
#
-
 
2415
# Inputs          : 
-
 
2416
#
-
 
2417
# Returns         : 
-
 
2418
#
-
 
2419
sub  ProcessWsExtraInfo
-
 
2420
{
-
 
2421
    my ($self, $line ) = @_;
-
 
2422
    my $data = $self->{btData};
-
 
2423
    $data->{Mode} = '' unless ( defined $data->{Mode} );
-
 
2424
    return unless ( $line );
-
 
2425
#print "----- ($data->{Mode}) $line\n";
-
 
2426
 
-
 
2427
    if ( $line =~ m~^<logentry~ ) {
-
 
2428
        $data->{Item} = ();
-
 
2429
        $data->{Mode} = 'A';
-
 
2430
 
-
 
2431
    } elsif ( ($line =~ s~\s*(.+?)="(.*)">(.*)</path>$~~) && ($data->{Mode} eq 'A') ) {
-
 
2432
        #
-
 
2433
        #   Last entry has two items
-
 
2434
        #       Attribute
-
 
2435
        #       Data Item
-
 
2436
        #
-
 
2437
        $data->{Item}->{$1} = $2;
-
 
2438
        $data->{Item}->{target} = $3;
-
 
2439
 
-
 
2440
    } elsif ( ($line =~ m~\s*(.*?)="(.*)"~) && ($data->{Mode} eq 'A') ) {
-
 
2441
        #
-
 
2442
        #   Attribute
-
 
2443
        #
-
 
2444
        $data->{Item}->{$1} = $2;
-
 
2445
 
-
 
2446
    } elsif ( $line =~ m~</logentry~ ) {
-
 
2447
        $data->{Mode} = '';
-
 
2448
        if ( exists $data->{Item}->{'copyfrom-path'} )
-
 
2449
        {
-
 
2450
            #DebugDumpData("Data", $data->{Item});
-
 
2451
            push @{$data->{Data}}, $data->{Item};
-
 
2452
        }
-
 
2453
    }
-
 
2454
 
-
 
2455
    #
-
 
2456
    #   Return 0 to keep on going
2275
    return 0;
2457
    return 0;
2276
}
2458
}
2277
 
2459
 
2278
#------------------------------------------------------------------------------
2460
#------------------------------------------------------------------------------
2279
1;
2461
1;