Changeset 319
- Timestamp:
- 07/09/2007 04:25:25 PM
- Files:
-
- trunk/script/Vss2Svn/ActionHandler.pm (modified) (2 diffs)
- trunk/script/Vss2Svn/Dumpfile.pm (modified) (5 diffs)
- trunk/script/Vss2Svn/Dumpfile/LabelMapper.pm (added)
- trunk/script/vss2svn.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/script/Vss2Svn/ActionHandler.pm
r305 r319 642 642 my $parentinfo = \%{$physinfo->{parents}->{$row->{parentphys}}}; 643 643 644 # depending on the version number of the PIN/UNPIN action, we don't have 645 # to convert this action into a real commit. In this case we only have to 646 # track, the state. 647 my $change_action = 1; 648 644 649 my $version = $row->{version}; 645 650 if (!defined $row->{version}) { 646 651 # this is the unpin handler 652 653 # is this the unpin version and the last version identically? 654 $change_action = 0 if (defined $parentinfo->{pinned} 655 && $parentinfo->{pinned} == $physinfo->{last_version} ); 656 647 657 undef $parentinfo->{pinned}; 648 658 $version = $physinfo->{last_version}; 649 659 } 650 660 else { 661 # is this the pin version and the last version identically? 662 # since the UNPIN/PIN merge, it is possible, that the item can still be 663 # in a pinned state: 664 $change_action = 0 if ($row->{version} == $physinfo->{last_version} 665 && !defined $parentinfo->{pinned}); 666 651 667 $parentinfo->{pinned} = $row->{version}; 652 668 } … … 660 676 $self->_track_item_path ($physname, $row->{parentphys}, $version, $itempath); 661 677 662 return 1;678 return $change_action; 663 679 } # End _pin_handler 664 680 trunk/script/Vss2Svn/Dumpfile.pm
r316 r319 4 4 use Vss2Svn::Dumpfile::SanityChecker; 5 5 use Vss2Svn::Dumpfile::AutoProps; 6 use Vss2Svn::Dumpfile::LabelMapper; 6 7 7 8 require Time::Local; … … 49 50 ############################################################################### 50 51 sub new { 51 my($class, $fh, $autoprops, $md5 ) = @_;52 my($class, $fh, $autoprops, $md5, $labelmapper) = @_; 52 53 53 54 my $self = … … 61 62 auto_props => $autoprops, 62 63 do_md5 => $md5, 64 label_mapper => $labelmapper, 63 65 }; 64 66 … … 568 570 # if one of the necessary copy from attributes are unavailable we fall back 569 571 # to a complete checkin 570 if (!defined $copyrev || !defined $copypath) { 572 if (defined $copyrev && defined $copypath) { 573 $data->{comment} = "ported from $copypath r$copyrev"; 574 } 575 # if (!defined $copyrev || !defined $copypath) { 571 576 return $self->_commit_handler ($itempath, $nodes, $data, $expdir); 572 }577 # } 573 578 574 579 my $node = Vss2Svn::Dumpfile::Node->new(); … … 605 610 # as a valid share source. 606 611 if (defined ($label)) { 612 my $labeldir = $main::gCfg{labeldir}; 613 614 if (defined $self->{label_mapper}) { 615 $labeldir = $self->{label_mapper}->remap ($main::gCfg{labeldir}, $label); 616 } 617 $labeldir =~ s:\\:/:g; 618 $labeldir =~ s:/$::; 619 607 620 $label =~ s![\\/:*?"<>|]!_!g; 608 621 609 622 my $vssitempath = $itempath; 610 623 $vssitempath =~ s/^$main::gCfg{trunkdir}//; 611 my $labelpath = "$ main::gCfg{labeldir}/$label$vssitempath";624 my $labelpath = "$labeldir/$label$vssitempath"; 612 625 613 626 $self->_create_svn_path ($nodes, $labelpath); trunk/script/vss2svn.pl
r316 r319 79 79 # Remove unnecessary Unpin/pin activities 80 80 MERGEUNPINPIN => {handler => \&MergeUnpinPinData, 81 next => 'BUILDCOMMENTS'}, 82 83 # Rebuild possible missing comments 84 BUILDCOMMENTS => {handler => \&BuildComments, 81 85 next => 'BUILDACTIONHIST'}, 82 86 … … 445 449 $vernum = $action->{PinnedToVersion} if (defined $action->{PinnedToVersion}); 446 450 # } 451 452 # for unpin actions also remeber the unpinned version 453 $info = $action->{UnpinnedFromVersion} if (defined $action->{UnpinnedFromVersion}); 447 454 448 455 $priority -= 4 if $actiontype eq 'ADD'; # Adds are always first … … 632 639 $sth->execute( $depth, $row->{action_id} ); 633 640 634 } # End Update ParentRec641 } # End UpdateDepth 635 642 636 643 ############################################################################### … … 837 844 for $r (0 .. @$rows-2) { 838 845 $row = $rows->[$r]; 839 $next_row = $rows->[$r+1];840 846 841 if ($row->{actiontype} eq 'PIN' 842 && !defined $row->{version} # UNPIN 843 && $next_row->{actiontype} eq 'PIN' 844 && defined $next_row->{version} # PIN 845 && $row->{physname} eq $next_row->{physname} 846 && $row->{parentphys} eq $next_row->{parentphys} 847 && $next_row->{timestamp} - $row->{timestamp} < 60 848 && $next_row->{action_id} - $row->{action_id} == 1) { 849 print "found UNPIN/PIN combination for $row->{parentphys}/$row->{physname}" 850 . "($row->{itemname}) @ ID $row->{action_id}\n" if $gCfg{verbose}; 851 push (@delchild, $row->{action_id}); 847 if ($row->{actiontype} eq 'PIN' && !defined $row->{version}) # UNPIN 848 { 849 # Search for a matching pin action 850 my $u; 851 for ($u = $r+1; $u <= @$rows-2; $u++) { 852 $next_row = $rows->[$u]; 853 854 if ( $next_row->{actiontype} eq 'PIN' 855 && defined $next_row->{version} # PIN 856 && $row->{physname} eq $next_row->{physname} 857 && $row->{parentphys} eq $next_row->{parentphys} 858 # && $next_row->{timestamp} - $row->{timestamp} < 60 859 # && $next_row->{action_id} - $row->{action_id} == 1 860 ) { 861 print "found UNPIN/PIN combination for $row->{parentphys}/$row->{physname}" 862 . "($row->{itemname}) @ ID $row->{action_id}\n" if $gCfg{verbose}; 863 864 # if we have a unpinFromVersion number copy this one to the PIN handler 865 if (defined $row->{info}) 866 { 867 my $sql2 = "UPDATE PhysicalAction SET info = ? WHERE action_id = ?"; 868 my $sth2 = $gCfg{dbh}->prepare($sql2); 869 $sth2->execute($row->{info}, $next_row->{action_id}); 870 } 871 872 push (@delchild, $row->{action_id}); 873 } 874 875 # if the next action is anything else than a pin stop the search 876 $u = @$rows if ($next_row->{actiontype} ne 'PIN' ); 852 877 } 853 878 } 854 879 } 855 880 … … 862 887 863 888 } # End MergeUnpinPinData 889 890 ############################################################################### 891 # BuildComments 892 ############################################################################### 893 sub BuildComments { 894 my($sth, $rows, $row, $r, $next_row); 895 my $sql = 'SELECT * FROM PhysicalAction WHERE actiontype="PIN" AND itemtype=2 ORDER BY physname ASC'; 896 $sth = $gCfg{dbh}->prepare($sql); 897 $sth->execute(); 898 899 # need to pull in all recs at once, since we'll be updating/deleting data 900 $rows = $sth->fetchall_arrayref( {} ); 901 902 foreach $row (@$rows) { 903 904 # technically we have the following situations: 905 # PIN only: we come from the younger version and PIN to a older one: the 906 # younger version is the currenty version of the timestamp of the PIN action 907 # UNPIN only: we unpin from a older version to the current version, the 908 # timestamp of the action will again define the younger version 909 # UNPIN/PIN with known UNPIN version: we merge from UNPIN version to PIN version 910 # UNPIN/PIN with unknown UNPIN version: we are lost in this case and we 911 # can not distinguish this case from the PIN only case. 912 913 my $sql2; 914 915 # PIN only 916 if ( defined $row->{version} # PIN version number 917 && !defined $row->{info}) { # no UNPIN version number 918 $sql2 = 'SELECT * FROM PhysicalAction' 919 . ' WHERE physname="' . $row->{physname} . '"' 920 . ' AND parentphys ISNULL' 921 . ' AND itemtype=2' 922 . ' AND version>=' . $row->{version} 923 . ' AND timestamp<=' . $row->{timestamp} 924 . ' ORDER BY version DESC'; 925 } 926 927 # UNPIN only 928 if ( !defined $row->{version} # no PIN version number 929 && defined $row->{info}) { # UNPIN version number 930 $sql2 = 'SELECT * FROM PhysicalAction' 931 . ' WHERE physname="' . $row->{physname} . '"' 932 . ' AND parentphys ISNULL' 933 . ' AND itemtype=2' 934 . ' AND timestamp<=' . $row->{timestamp} 935 . ' AND version>' . $row->{info} 936 . ' ORDER BY version ASC'; 937 } 938 939 # PIN/UNPIN 940 if ( defined $row->{version} # no PIN version number 941 && defined $row->{info}) { # UNPIN version number 942 $sql2 = 'SELECT * FROM PhysicalAction' 943 . ' WHERE physname="' . $row->{physname} . '"' 944 . ' AND parentphys ISNULL' 945 . ' AND itemtype=2' 946 . ' AND version>' . $row->{info} 947 . ' AND version<=' . $row->{version} 948 . ' ORDER BY version ASC'; 949 } 950 951 next if !defined $sql2; 952 953 my $sth2 = $gCfg{dbh}->prepare($sql2); 954 $sth2->execute(); 955 956 my $comments = $sth2->fetchall_arrayref( {} ); 957 my $comment; 958 print "merging comments for $row->{physname}" if $gCfg{verbose}; 959 print " from $row->{info}" if ($gCfg{verbose} && defined $row->{info}); 960 print " to $row->{version}" if ($gCfg{verbose} && defined $row->{version}); 961 print "\n" if $gCfg{verbose}; 962 963 foreach my $c(@$comments) { 964 print " $c->{version}: $c->{comment}\n" if $gCfg{verbose}; 965 $comment .= $c->{comment} . "\n"; 966 $comment =~ s/^\n+//; 967 $comment =~ s/\n+$//; 968 } 969 970 if (defined $comment && !defined $row->{comment}) { 971 $comment =~ s/"/""/g; 972 my $sql3 = 'UPDATE PhysicalAction SET comment="' . $comment . '" WHERE action_id = ' . $row->{action_id}; 973 my $sth3 = $gCfg{dbh}->prepare($sql3); 974 $sth3->execute(); 975 } 976 } 977 1; 978 979 } # End BuildComments 864 980 865 981 ############################################################################### … … 1041 1157 1042 1158 my $autoprops = Vss2Svn::Dumpfile::AutoProps->new($gCfg{auto_props}) if $gCfg{auto_props}; 1043 my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{do_md5}); 1159 my $labelmapper = Vss2Svn::Dumpfile::LabelMapper->new($gCfg{label_mapper}) if $gCfg{label_mapper}; 1160 my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{do_md5}, $labelmapper); 1044 1161 Vss2Svn::Dumpfile->SetTempDir($gCfg{tempdir}); 1045 1162 … … 1166 1283 VSS Encoding : $gCfg{encoding} 1167 1284 Auto Props : $gCfg{auto_props} 1168 1285 trunk dirk : $gCfg{trunkdir} 1286 label dir : $gCfg{labeldir} 1287 label mapper : $gCfg{labelmapper} 1169 1288 1170 1289 VSS2SVN ver : $VERSION … … 1564 1683 DestroyedFile => {type => 2, action => 'DELETE'}, 1565 1684 RecoveredFile => {type => 2, action => 'RECOVER'}, 1566 ArchiveVersionsofFile => {type => 2, action => 'RESTORE'}, 1685 ArchiveVersionsofFile => {type => 2, action => 'ADD'}, 1686 ArchiveVersionsofProject => {type => 1, action => 'ADD'}, 1567 1687 ArchiveFile => {type => 2, action => 'DELETE'}, 1568 1688 RestoredFile => {type => 2, action => 'RESTORE'}, … … 1800 1920 GetOptions(\%gCfg,'vssdir=s','tempdir=s','dumpfile=s','resume','verbose', 1801 1921 'debug','timing+','task=s','revtimerange=i','ssphys=s', 1802 'encoding=s','trunkdir=s','auto_props=s', ' md5');1922 'encoding=s','trunkdir=s','auto_props=s', 'label_mapper=s', 'md5'); 1803 1923 1804 1924 &GiveHelp("Must specify --vssdir") if !defined($gCfg{vssdir}); … … 1974 2094 --auto_props="c:/Dokumente und Einstellungen/user/Anwendungsdaten/Subversion/config" 1975 2095 --md5 : generate md5 checksums 2096 --label_mapper : INI style file to map labels to different locataions 1976 2097 EOTXT 1977 2098
