Changeset 305
- Timestamp:
- 03/16/2007 08:24:35 PM
- Files:
-
- trunk/script/Vss2Svn/ActionHandler.pm (modified) (11 diffs)
- trunk/script/Vss2Svn/Dumpfile.pm (modified) (6 diffs)
- trunk/script/vss2svn.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/script/Vss2Svn/ActionHandler.pm
r299 r305 252 252 } 253 253 254 # # if this is not a share+pin action, then add this item to the sharedphys255 # # list. Otherwise, this item is pinned to a specific version and does not256 # # participate in shared actions257 # if (!defined $row->{version}) {258 # push @{ $physinfo->{sharedphys} }, $row->{parentphys};259 # }260 261 254 my $version = $row->{version}; 262 255 $version = $physinfo->{last_version} if (!defined $version); … … 284 277 } 285 278 279 # if this is a share from orphan, and not a share+pin action either, we can treat it as a move 280 elsif (!defined $row->{version} && # share+pin? 281 defined $physinfo->{orphaned} # orphaned? 282 # scalar @{$physinfo->{order}} == 1 # only one parent? 283 ) { 284 $physinfo->{parents}->{'_' . $row->{physname}}->{deleted} = 1; 285 undef $physinfo->{orphaned}; 286 $self->{action} = 'MOVE'; 287 } 288 286 289 # track the addition of the new parent 287 290 $self->_add_parent ($physname, $row->{parentphys}); … … 290 293 if (defined $row->{version}) { 291 294 $physinfo->{parents}->{$row->{parentphys}}->{pinned} = $row->{version}; 292 } 295 } 293 296 294 297 $self->{itempaths} = [$itempath]; … … 411 414 my $row = $self->{row}; 412 415 413 # Get the existing paths before the move; parent sub will get the new414 # name415 416 my $physname = $row->{physname}; 416 417 my $physinfo = $gPhysInfo{$physname}; … … 423 424 } 424 425 425 if (!defined $row->{parentphys}) { 426 # row->{info} contains the source parent 427 # row->{parentphys} contains the target parent 428 429 # check the source path 430 if (!defined $row->{info}) { 426 431 # Check if this is an orphaned item 427 if (scalar @{$physinfo->{order}} == 1) { 428 $row->{parentphys} = $physinfo->{order}[0]; 432 if (defined $physinfo->{orphaned}) { 433 $row->{info} = '_' . $physname; 434 undef $physinfo->{orphaned}; 429 435 } else { 430 436 # Don't know from where to move. Share it there instead 431 $row->{parentphys} = $row->{info};432 $row->{info} = undef;433 437 $self->{action} = 'SHARE'; 434 438 return $self->_share_handler(); … … 437 441 438 442 # '$sourceinfo' is the path for the old location (the move source); 439 my $parentpath = $self->_get_current_parent_path (); 440 my $sourceinfo = $parentpath . $physinfo->{name}; # $row->{itemname}; 441 442 if (!defined ($row->{info})) { 443 my $sourceparent = $self->_get_parent_path ($row->{info}); 444 my $sourceinfo = $sourceparent . $row->{itemname}; 445 446 447 # check the target path 448 if (!defined ($row->{parentphys})) { 443 449 # the target directory was destroyed, so there is no apropriate move 444 450 # target information. Fall back to a move to the orphaned cache 445 $row->{info} = '_' . $row->{physname}; 451 $physinfo->{orphaned} = 1; 452 $row->{parentphys} = '_' . $row->{physname}; 446 453 } 447 454 448 455 # '$itempath' contains the move target path 449 my $itempath = $self->_get_parent_path ($row->{info}) . $row->{itemname}; 450 451 if (!defined($parentpath)) { 456 my $parentpath = $self->_get_current_parent_path (); 457 my $itempath = $parentpath . $physinfo->{name}; # $row->{itemname}; 458 459 460 if (!defined($sourceparent)) { 452 461 # We can't figure out the path for the parent that this move came from, 453 462 # so it was either destroyed or corrupted. That means that this isn't … … 455 464 456 465 $self->{action} = 'ADD'; 457 # $self->{version} = $version; 458 # return $self->_add_handler(); 459 460 # we need to swap the source and the target path 461 $sourceinfo = $itempath; 462 undef $itempath; 466 undef $sourceinfo; 463 467 } 464 468 else { 465 469 # set the old parent inactive 466 $physinfo->{parents}->{$row->{ parentphys}}->{deleted} = 1;470 $physinfo->{parents}->{$row->{info}}->{deleted} = 1; 467 471 } 468 472 … … 471 475 472 476 # track the addition of the new parent 473 $self->_add_parent ($physname, $row->{ info});474 475 $self->{itempaths} = [$ sourceinfo];476 $self->{info} = $ itempath;477 $self->_add_parent ($physname, $row->{parentphys}); 478 479 $self->{itempaths} = [$itempath]; 480 $self->{info} = $sourceinfo; 477 481 478 482 # the move target is now also a valid "copy from" itempath … … 746 750 } 747 751 748 #todo: make the behavoir of orphaned file tracking configurable749 # if ($physinfo->{orphaned}) {750 # return undef;751 # }752 753 752 $self->{physname_seen} .= "$physname, "; 754 753 … … 878 877 return undef; 879 878 } 880 881 #todo: make the behavoir of orphaned file tracking configurable882 # if ($physinfo->{orphaned})883 # {884 # return undef;885 # }886 879 887 880 $self->{physname_seen} .= "$physname, "; … … 1170 1163 1171 1164 my $physinfo = $gPhysInfo{$physname}; 1172 if (!defined $physinfo) { 1173 return undef; 1174 } 1165 1175 1166 # 1. check the parent requested, if there was an item name for this version 1176 1167 # we can use this item name, since it was valid in that time trunk/script/Vss2Svn/Dumpfile.pm
r301 r305 393 393 # moving in SVN is the same as renaming; add the new and delete the old 394 394 395 my $ newpath = $data->{info};396 397 if ($self->{repository}->exists ($ newpath)) {398 $self->add_error("Attempt to move item '$ itempath' to '$newpath' at "395 my $oldpath = $data->{info}; 396 397 if ($self->{repository}->exists ($itempath)) { 398 $self->add_error("Attempt to move item '$oldpath' to '$itempath' at " 399 399 . "revision $data->{revision_id}, but destination already exists: possibly " 400 400 . "missing delete; skipping"); … … 402 402 } 403 403 404 if (!$self->{repository}->exists ($ itempath)) {405 $self->add_error("Attempt to move item '$ itempath' to '$newpath' at "404 if (!$self->{repository}->exists ($oldpath)) { 405 $self->add_error("Attempt to move item '$oldpath' to '$itempath' at " 406 406 . "revision $data->{revision_id}, but source doesn't exists: possibly " 407 407 . "missing recover; skipping"); … … 410 410 411 411 my $node = Vss2Svn::Dumpfile::Node->new(); 412 $node->set_initial_props($ newpath, $data);412 $node->set_initial_props($itempath, $data); 413 413 $node->{action} = 'add'; 414 414 … … 416 416 417 417 $copyrev = $data->{revision_id} - 1; 418 $copypath = $ itempath;418 $copypath = $oldpath; 419 419 420 420 $node->{copyrev} = $copyrev; … … 423 423 push @$nodes, $node; 424 424 425 # $self->track_modified($data->{physname}, $data->{revision_id}, $newpath); 426 # $self->track_version ($data->{physname}, $data->{version}, $newpath);425 # the new move target is a valid path. 426 $self->track_version ($data->{physname}, $data->{version}, $itempath); 427 427 428 428 $node = Vss2Svn::Dumpfile::Node->new(); 429 $node->set_initial_props($ itempath, $data);429 $node->set_initial_props($oldpath, $data); 430 430 $node->{action} = 'delete'; 431 431 $node->{hideprops} = 1; 432 433 # Deleted tracking is only necessary to be able to recover the item. But a move 434 # does not set a recover point, so we don't need to track the delete here. Additionally 435 # we do not have enough information for this operation. 436 # $self->track_deleted($data->{oldparentphys}, $data->{physname}, 437 # $data->{revision_id}, $oldpath); 432 438 433 439 push @$nodes, $node; … … 567 573 if (defined ($label)) { 568 574 $label =~ s:/:_:g; 569 575 570 576 my $vssitempath = $itempath; 571 577 $vssitempath =~ s/^$main::gCfg{trunkdir}//; trunk/script/vss2svn.pl
r304 r305 612 612 613 613 my($childrecs, $child, $id); 614 my @delchild = ();615 614 616 615 foreach $row (@$rows) { 617 $row->{actiontype} = 'MOVE ';616 $row->{actiontype} = 'MOVE_TO'; 618 617 $childrecs = &GetChildRecs($row, 1); 619 618 619 my $source = undef; 620 my $target = $row->{parentphys}; 621 620 622 if (scalar @$childrecs > 1) { 621 &ThrowWarning("Multiple chi dlrecs for parent MOVE rec "623 &ThrowWarning("Multiple child recs for parent MOVE rec " 622 624 . "'$row->{action_id}'"); 623 625 } 624 626 625 foreach $child (@$childrecs) { 626 my $update; 627 $update = $gCfg{dbh}->prepare('UPDATE PhysicalAction SET info = ?' 628 . 'WHERE action_id = ?'); 629 630 $update->execute( $row->{parentphys}, $child->{action_id} ); 631 } 632 633 if (scalar @$childrecs == 0) { 634 my $sql = <<"EOSQL"; 627 if (scalar @$childrecs >= 1) { 628 # only merge MOVE records that have the same timestamp 629 if ($row->{timestamp} == @$childrecs[0]->{timestamp}) { 630 $source = @$childrecs[0]->{parentphys}; 631 &DeleteChildRec(@$childrecs[0]->{action_id}); 632 } 633 } 634 635 my $sql = <<"EOSQL"; 635 636 UPDATE 636 637 PhysicalAction 637 638 SET 639 actiontype = 'MOVE', 638 640 parentphys = ?, 639 actiontype = 'MOVE',640 641 info = ? 641 642 WHERE 642 643 action_id = ? 643 644 EOSQL 644 my $update; 645 $update = $gCfg{dbh}->prepare($sql); 646 $update->execute( undef, $row->{parentphys}, 647 $row->{action_id}); 648 } else { 649 push(@delchild, $row->{action_id}); 650 } 651 } 652 653 foreach $id (@delchild) { 654 &DeleteChildRec($id); 655 } 645 my $update; 646 $update = $gCfg{dbh}->prepare($sql); 647 648 $update->execute( $target, $source, $row->{action_id}); 649 } 650 651 652 # change all remaining MOVE_TO records into MOVE records and swap the src and target 653 $sth = $gCfg{dbh}->prepare('SELECT * FROM PhysicalAction ' 654 . 'WHERE actiontype = "MOVE_TO"'); 655 $sth->execute(); 656 $rows = $sth->fetchall_arrayref( {} ); 657 658 foreach $row (@$rows) { 659 my $update; 660 $update = $gCfg{dbh}->prepare('UPDATE PhysicalAction SET ' 661 . 'actiontype = "MOVE", ' 662 . 'parentphys = ?, ' 663 . 'info = ? ' 664 . 'WHERE action_id = ?'); 665 $update->execute($row->{info}, $row->{parentphys}, $row->{action_id}); 666 } 667 656 668 657 669 1; … … 765 777 # RENAME: the new name (without path) 766 778 # SHARE: the source path which was shared 767 # MOVE: the newpath779 # MOVE: the old path 768 780 # PIN: the path of the version that was pinned 769 781 # LABEL: the name of the label … … 1334 1346 RestoredProject => {type => 1, action => 'RESTOREDPROJECT'}, 1335 1347 RenamedProject => {type => 1, action => 'RENAME'}, 1336 MovedProjectTo => {type => 1, action => 'MOVE '},1348 MovedProjectTo => {type => 1, action => 'MOVE_TO'}, 1337 1349 MovedProjectFrom => {type => 1, action => 'MOVE_FROM'}, 1338 1350 DeletedProject => {type => 1, action => 'DELETE'},
