Changeset 313

Show
Ignore:
Timestamp:
06/11/2007 10:46:05 PM
Author:
toby
Message:

patch from David Finnie to fix edge case error with project order; see: <http://www.mail-archive.com/vss2svn-users@lists.pumacode.org/msg01037.html>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/script/vss2svn.pl

    r308 r313  
    527527    my($sth, $rows, $row); 
    528528    $sth = $gCfg{dbh}->prepare('SELECT * FROM PhysicalAction ' 
    529                                . 'WHERE parentdata = 1'); 
     529                               . 'WHERE parentdata > 0'); 
    530530    $sth->execute(); 
    531531 
     
    533533    $rows = $sth->fetchall_arrayref( {} ); 
    534534 
    535     my($childrecs, $child, $id); 
     535    my($childrecs, $child, $id, $depth); 
    536536    my @delchild = (); 
    537537 
     
    544544        } 
    545545 
     546        $depth = &GetPathDepth($row); 
     547 
    546548        foreach $child (@$childrecs) { 
    547549            &UpdateParentRec($row, $child); 
     
    557559 
    558560}  #  End MergeParentData 
     561 
     562############################################################################### 
     563#  GetPathDepth 
     564############################################################################### 
     565sub GetPathDepth { 
     566    my($row) = @_; 
     567 
     568    # If we've already worked out the depth of this row, return it immediately 
     569    if ($row->{parentdata} > 1) { 
     570        return $row->{parentdata}; 
     571    } 
     572 
     573    my($maxParentDepth, $depth, $parents, $parent); 
     574 
     575    # Get the row(s) corresponding to the parent(s) of this row, and work out 
     576    # the maximum depth 
     577     
     578    my $sql = <<"EOSQL"; 
     579SELECT 
     580    * 
     581FROM 
     582    PhysicalAction 
     583WHERE 
     584    parentdata > 0 
     585    AND physname = ? 
     586    AND actiontype = ? 
     587EOSQL 
     588 
     589    my $sth = $gCfg{dbh}->prepare($sql); 
     590    $sth->execute( @{ $row }{qw(parentphys actiontype)} ); 
     591 
     592    $parents =  $sth->fetchall_arrayref( {} ); 
     593    $maxParentDepth = 0; 
     594    foreach $parent (@$parents) { 
     595        $depth = &GetPathDepth($parent); 
     596        $maxParentDepth = ($depth > $maxParentDepth) ? $depth : $maxParentDepth; 
     597    } 
     598 
     599    # Depth of this path becomes one more than the maximum parent depth 
     600    $depth = $maxParentDepth + 1; 
     601 
     602    # Update the row for this record 
     603    &UpdateDepth($row, $depth); 
     604 
     605    return $depth; 
     606}  #  End GetPathDepth 
     607 
     608############################################################################### 
     609#  UpdateDepth 
     610############################################################################### 
     611sub UpdateDepth { 
     612    my($row, $depth) = @_; 
     613 
     614    my $sql = <<"EOSQL"; 
     615UPDATE 
     616    PhysicalAction 
     617SET 
     618    parentdata = ? 
     619WHERE 
     620    action_id = ? 
     621EOSQL 
     622 
     623    my $sth = $gCfg{dbh}->prepare($sql); 
     624    $sth->execute( $depth, $row->{action_id} ); 
     625 
     626}  #  End UpdateParentRec 
    559627 
    560628############################################################################### 
     
    740808 
    741809    my $sql = 'SELECT * FROM PhysicalAction ORDER BY timestamp ASC, ' 
    742             . 'itemtype ASC, priority ASC, sortkey ASC, action_id ASC'; 
     810            . 'itemtype ASC, priority ASC, parentdata ASC, sortkey ASC, action_id ASC'; 
    743811 
    744812    $sth = $gCfg{dbh}->prepare($sql); 

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.