Changeset 316
- Timestamp:
- 06/26/2007 07:02:16 PM
- Files:
-
- trunk/script/Vss2Svn/Dumpfile.pm (modified) (7 diffs)
- trunk/script/devnotes.txt (modified) (1 diff)
- trunk/script/vss2svn.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/script/Vss2Svn/Dumpfile.pm
r312 r316 11 11 12 12 use File::Copy; 13 use Digest::MD5; 14 use Data::UUID; 13 15 14 16 our %gHandlers = … … 32 34 our %gDeleted = (); 33 35 our %gVersion = (); 36 our $gTmpDir; 37 38 ############################################################################### 39 # SetTempDir 40 ############################################################################### 41 sub SetTempDir { 42 my($class, $dir) = @_; 43 44 $gTmpDir = $dir; 45 } # End SetTempDir 34 46 35 47 ############################################################################### … … 37 49 ############################################################################### 38 50 sub new { 39 my($class, $fh, $autoprops ) = @_;51 my($class, $fh, $autoprops, $md5) = @_; 40 52 41 53 my $self = … … 48 60 repository => Vss2Svn::Dumpfile::SanityChecker->new(), 49 61 auto_props => $autoprops, 62 do_md5 => $md5, 50 63 }; 51 64 … … 58 71 59 72 print $fh "SVN-fs-dump-format-version: 2\n\n"; 73 74 my $ug = new Data::UUID; 75 my $uuid = $ug->to_string( $ug->create() ); 76 77 print $fh "UUID: $uuid\n\n"; 60 78 61 79 $self = bless($self, $class); … … 770 788 } 771 789 790 my $md5; 791 $md5 = Digest::MD5->new if $self->{do_md5}; 792 793 # convert CRLF -> LF before calculating the size and compute the md5 794 if(!defined $text && defined $file) { 795 my ($input, $output); 796 my $style = $props->{'svn:eol-style'}; 797 if (defined $style && $style eq 'native') { 798 open ($input, "<:crlf", $file); 799 my $tmpFile = "$gTmpDir/crlf_to_lf.tmp.txt"; 800 open ($output, ">", $tmpFile); 801 binmode ($output); 802 803 while(<$input>) { 804 $md5->add($_) if $self->{do_md5}; 805 print $output $_; 806 } 807 808 close $input; 809 close $output; 810 $file = $tmpFile; 811 } 812 else { 813 open ($input, "<", $file); 814 binmode ($input); 815 $md5->addfile($input) if $self->{do_md5}; 816 close $input; 817 } 818 } else { 819 $md5->add($text) if $self->{do_md5}; 820 } 821 822 my $digest = $md5->hexdigest if $self->{do_md5}; 823 # print "digest: $digest\n"; 824 772 825 if(!defined $text && defined $file) { 773 826 $textlen = -s $file; … … 783 836 if ($textlen > 0) { 784 837 print $fh "Text-content-length: $textlen\n"; 838 print $fh "Text-content-md5: $digest\n" if $self->{do_md5}; 785 839 } 786 840 trunk/script/devnotes.txt
r293 r316 13 13 Config::Ini 14 14 Text::Glob 15 Digest::MD5 16 Data::UUID 15 17 16 18 SQLITE SCHEMA trunk/script/vss2svn.pl
r315 r316 71 71 # Merge data from move actions 72 72 MERGEMOVEDATA => {handler => \&MergeMoveData, 73 next => 'BUILDACTIONHIST'}, 73 next => 'REMOVETMPCHECKIN'}, 74 75 # Remove temporary check ins 76 REMOVETMPCHECKIN => {handler => \&RemoveTemporaryCheckIns, 77 next => 'MERGEUNPINPIN'}, 78 79 # Remove unnecessary Unpin/pin activities 80 MERGEUNPINPIN => {handler => \&MergeUnpinPinData, 81 next => 'BUILDACTIONHIST'}, 74 82 75 83 # Take the history of physical actions and convert them to VSS … … 774 782 775 783 ############################################################################### 784 # RemoveTemporaryCheckIns 785 # remove temporary checkins that where create to detect MS VSS capabilities 786 ############################################################################### 787 sub RemoveTemporaryCheckIns { 788 my($sth, $rows, $row); 789 $sth = $gCfg{dbh}->prepare('SELECT * FROM PhysicalAction ' 790 . 'WHERE comment = "Temporary file created by Visual Studio .NET to detect Microsoft Visual SourceSafe capabilities."' 791 . ' AND actiontype = "ADD"' 792 . ' AND itemtype = 2'); # only delete files, not projects 793 $sth->execute(); 794 795 # need to pull in all recs at once, since we'll be updating/deleting data 796 $rows = $sth->fetchall_arrayref( {} ); 797 798 foreach $row (@$rows) { 799 my $physname = $row->{physname}; 800 801 my $sql = 'SELECT * FROM PhysicalAction WHERE physname = ?'; 802 my $update = $gCfg{dbh}->prepare($sql); 803 804 $update->execute( $physname ); 805 806 # need to pull in all recs at once, since we'll be updating/deleting data 807 my $recs = $update->fetchall_arrayref( {} ); 808 809 foreach my $rec (@$recs) { 810 print "Remove action_id $rec->{action_id}, $rec->{physname}, $rec->{actiontype}, $rec->{itemname}\n"; 811 print " $rec->{comment}\n" if defined ($rec->{comment}); 812 &DeleteChildRec($rec->{action_id}); 813 } 814 } 815 816 1; 817 } 818 819 ############################################################################### 820 # MergeUnpinPinData 821 ############################################################################### 822 sub MergeUnpinPinData { 823 my($sth, $rows, $row, $r, $next_row); 824 my $sql = 'SELECT * FROM PhysicalAction ORDER BY timestamp ASC, ' 825 . 'itemtype ASC, priority ASC, parentdata ASC, sortkey ASC, action_id ASC'; 826 $sth = $gCfg{dbh}->prepare($sql); 827 $sth->execute(); 828 829 # need to pull in all recs at once, since we'll be updating/deleting data 830 $rows = $sth->fetchall_arrayref( {} ); 831 832 return if ($rows == -1); 833 return if (@$rows < 2); 834 835 my @delchild = (); 836 837 for $r (0 .. @$rows-2) { 838 $row = $rows->[$r]; 839 $next_row = $rows->[$r+1]; 840 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}); 852 } 853 854 } 855 856 my $id; 857 foreach $id (@delchild) { 858 &DeleteChildRec($id); 859 } 860 861 1; 862 863 } # End MergeUnpinPinData 864 865 ############################################################################### 776 866 # DeleteChildRec 777 867 ############################################################################### … … 951 1041 952 1042 my $autoprops = Vss2Svn::Dumpfile::AutoProps->new($gCfg{auto_props}) if $gCfg{auto_props}; 953 my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops); 1043 my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{do_md5}); 1044 Vss2Svn::Dumpfile->SetTempDir($gCfg{tempdir}); 954 1045 955 1046 REVISION: … … 1074 1165 Dumpfile : $gCfg{dumpfile} 1075 1166 VSS Encoding : $gCfg{encoding} 1167 Auto Props : $gCfg{auto_props} 1168 1076 1169 1077 1170 VSS2SVN ver : $VERSION … … 1707 1800 GetOptions(\%gCfg,'vssdir=s','tempdir=s','dumpfile=s','resume','verbose', 1708 1801 'debug','timing+','task=s','revtimerange=i','ssphys=s', 1709 'encoding=s','trunkdir=s','auto_props=s' );1802 'encoding=s','trunkdir=s','auto_props=s', 'md5'); 1710 1803 1711 1804 &GiveHelp("Must specify --vssdir") if !defined($gCfg{vssdir}); … … 1868 1961 --task <task> : specify the task to resume; task is one of the following 1869 1962 INIT, LOADVSSNAMES, FINDDBFILES, GETPHYSHIST, 1870 MERGEPARENTDATA, BUILDACTIONHIST, IMPORTSVN 1963 MERGEPARENTDATA, MERGEMOVEDATA, REMOVETMPCHECKIN, 1964 MERGEUNPINPIN, BUILDACTIONHIST, IMPORTSVN 1871 1965 1872 1966 --verbose : Print more info about the items being processed … … 1878 1972 converted repository (default = "/") 1879 1973 --auto_props : Specify an autoprops ini file to use, e.g. 1880 --auto_props="c:/Dokumente und Einstellungen/user/Anwendungsdaten/Subversion/config" 1974 --auto_props="c:/Dokumente und Einstellungen/user/Anwendungsdaten/Subversion/config" 1975 --md5 : generate md5 checksums 1881 1976 EOTXT 1882 1977
