Changeset 225

Show
Ignore:
Timestamp:
05/22/2006 06:07:52 PM
Author:
luedi
Message:

added support for MOVE action

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Dirk/pin_handler/Vss2Svn/ActionHandler.pm

    r215 r225  
    364364    # name 
    365365    my $physname = $row->{physname}; 
    366     my $itempaths = $self->_get_current_item_paths(); 
    367  
    368     my $physinfo = $gPhysInfo{$physname}; 
    369  
     366    my $physinfo = $gPhysInfo{$physname}; 
     367   
    370368    if (!defined $physinfo) { 
    371         $self->{errmsg} .= "Attempt to rename unknown item '$physname':\n" 
     369        $self->{errmsg} .= "Attempt to move unknown item '$physname':\n" 
    372370            . "$self->{physname_seen}\n"; 
    373371 
     
    375373    } 
    376374 
    377     # Only projects can have true "moves", and projects don't have shares, so 
    378     # we don't need to worry about any shared paths 
    379     $physinfo->{parentphys} = $row->{parentphys}; 
    380  
    381 # TODO: How do we "delete" the old parent? We don not know the physical name of it. 
    382 # TODO: same as for shares, we must add the itempath to our map 
    383  
    384     # 'itempaths' has the original path; 'info' has the new 
    385     $self->{itempaths} = $itempaths; 
    386     $self->{info} = $self->_get_current_item_paths(1)->[0]; 
     375    # '$sourceinfo' is the path for the old location (the move source); 
     376    my $parentpath = $self->_get_current_parent_path (); 
     377    my $sourceinfo = $parentpath . $row->{itemname}; 
     378 
     379    # '$itempath' contains the move target path 
     380    my $itempath = $self->_get_parent_path ($row->{info}) . $row->{itemname}; 
     381 
     382    if (!defined($sourceinfo)) { 
     383        # We can't figure out the path for the parent that this move came from, 
     384        # so it was either destroyed or corrupted. That means that this isn't 
     385        # a move anymore; it's a new add. 
     386 
     387        $self->{action} = 'ADD'; 
     388#        $self->{version} = $version; 
     389#        return $self->_add_handler(); 
     390    } 
     391    else { 
     392        # set the old parent inactive 
     393        $physinfo->{parents}->{$row->{parentphys}}->{deleted} = 1; 
     394    } 
     395 
     396    # track the addition of the new parent 
     397    $self->_add_parent ($physname, $row->{info}); 
     398     
     399    $self->{itempaths} = [$sourceinfo]; 
     400    $self->{info} = $itempath; 
     401 
     402    # the move target is now also a valid "copy from" itempath 
     403#    $self->_track_item_path ($physname, $row->{parentphys}, $version, $itempath); 
    387404 
    388405    return 1; 
    389  
    390406}  #  End _move_handler 
    391407 
     
    439455    } 
    440456 
    441     # set the parent inactive 
    442     $physinfo->{parents}->{$row->{parentphys}}->{deleted} = 1; 
    443457 
    444458    $self->{itempaths} = $itempaths; 
  • branches/Dirk/pin_handler/Vss2Svn/Dumpfile.pm

    r224 r225  
    627627 
    628628#    $self->track_modified($data->{physname}, $data->{revision_id}, $newpath); 
    629     $self->track_version ($data->{physname}, $data->{version}, $newpath); 
     629#    $self->track_version ($data->{physname}, $data->{version}, $newpath); 
    630630 
    631631    $node = Vss2Svn::Dumpfile::Node->new(); 
  • branches/Dirk/pin_handler/vss2svn.pl

    r223 r225  
    6464            # Merge data from parent records into child records where possible 
    6565            MERGEPARENTDATA => {handler => \&MergeParentData, 
     66                                next    => 'MERGEMOVEDATA'}, 
     67 
     68            # Merge data from move actions  
     69            MERGEMOVEDATA => {handler => \&MergeMoveData, 
    6670                                next    => 'BUILDACTIONHIST'}, 
    6771 
     
    522526############################################################################### 
    523527sub GetChildRecs { 
    524     my($parentrec) = @_; 
     528    my($parentrec, $parentdata) = @_; 
    525529 
    526530    # Here we need to find any child rows which give us additional info on the 
     
    531535    # we don't get the wrong row. 
    532536 
     537    $parentdata = 0 unless defined $parentdata; 
     538     
    533539    my $sql = <<"EOSQL"; 
    534540SELECT 
     
    537543    PhysicalAction 
    538544WHERE 
    539     parentdata = 0 
     545    parentdata = ? 
    540546    AND physname = ? 
    541547    AND actiontype = ? 
     
    547553 
    548554    my $sth = $gCfg{dbh}->prepare($sql); 
    549     $sth->execute( @{ $parentrec }{qw(physname actiontype timestamp author)} ); 
     555    $sth->execute( $parentdata, @{ $parentrec }{qw(physname actiontype timestamp author)} ); 
    550556 
    551557    return $sth->fetchall_arrayref( {} ); 
     
    586592 
    587593}  #  End UpdateParentRec 
     594 
     595############################################################################### 
     596#  MergeMoveData 
     597############################################################################### 
     598sub MergeMoveData { 
     599    # Similar to the MergeParentData, the MergeMove Data combines two the src 
     600    # and target move actions into one move action. Since both items are parents 
     601    # the MergeParentData function can not deal with this specific problem 
     602 
     603    my($sth, $rows, $row); 
     604    $sth = $gCfg{dbh}->prepare('SELECT * FROM PhysicalAction ' 
     605                               . 'WHERE actiontype = "MOVE_FROM"'); 
     606    $sth->execute(); 
     607 
     608    # need to pull in all recs at once, since we'll be updating/deleting data 
     609    $rows = $sth->fetchall_arrayref( {} ); 
     610 
     611    my($childrecs, $child, $id); 
     612    my @delchild = (); 
     613 
     614    foreach $row (@$rows) { 
     615        $row->{actiontype} = 'MOVE'; 
     616        $childrecs = &GetChildRecs($row, 1); 
     617 
     618        if (scalar @$childrecs > 1) { 
     619            &ThrowWarning("Multiple chidl recs for parent MOVE rec " 
     620                          . "'$row->{action_id}'"); 
     621        } 
     622 
     623        foreach $child (@$childrecs) { 
     624            my $update; 
     625            $update = $gCfg{dbh}->prepare('UPDATE PhysicalAction SET info = ?' 
     626                                          . 'WHERE action_id = ?'); 
     627             
     628            $update->execute( $row->{parentphys}, $child->{action_id} ); 
     629        } 
     630         
     631        push(@delchild, $row->{action_id}); 
     632    } 
     633 
     634    foreach $id (@delchild) { 
     635        &DeleteChildRec($id); 
     636    } 
     637 
     638    1; 
     639 
     640}  #  End MergeMoveData 
    588641 
    589642############################################################################### 
     
    12011254    } 
    12021255 
    1203     $gCfg{ssphys} = 'SSPHYS.exe' if !defined($gCfg{ssphys}); 
     1256    $gCfg{ssphys} = 'ssphys' if !defined($gCfg{ssphys}); 
    12041257    $gCfg{vssdatadir} = "$gCfg{vssdir}/data"; 
    12051258 
     
    14851538    mkdir $gCfg{vssdata}; 
    14861539 
    1487     $gCfg{ssphys} ||= 'SSPHYS.exe'; 
     1540    $gCfg{ssphys} ||= 'ssphys'; 
    14881541    $gCfg{svn} ||= 'SVN.exe'; 
    14891542 
     
    15461599AddedProject    1       ADD 
    15471600RenamedProject  1       RENAME 
    1548 MovedProjectTo  1       IGNOR
    1549 MovedProjectFrom        1       MOVE 
     1601MovedProjectTo  1       MOV
     1602MovedProjectFrom        1       MOVE_FROM 
    15501603DeletedProject  1       DELETE 
    15511604DestroyedProject        1       DELETE 

These ads are automatically generated by Google based on the content of this page. Revenue from these ads helps to pay for hosting fees of this site; however, these ads do not constitute an endorsement by PumaCode.org.