From vss2svn-commits at lists.pumacode.org Mon Jul 9 16:07:14 2007 From: vss2svn-commits at lists.pumacode.org (vss2svn-commits@lists.pumacode.org) Date: Mon Jul 9 16:07:17 2007 Subject: r318 - luedi: /trunk/script/Vss2Svn/SvnRevHandler.pm Message-ID: <20070709200715.09EFE15CDDD@cp.thetahost.com> Author: luedi Date: Mon Jul 9 16:07:13 2007 New Revision: 318 Log: fixed * #57: detect recursive share activities with comments * #58: detect recursive share activities with shared items Modified: trunk/script/Vss2Svn/SvnRevHandler.pm Modified: trunk/script/Vss2Svn/SvnRevHandler.pm ============================================================================== --- trunk/script/Vss2Svn/SvnRevHandler.pm (original) +++ trunk/script/Vss2Svn/SvnRevHandler.pm Mon Jul 9 16:07:13 2007 @@ -45,7 +45,9 @@ $self->{timestamp} = undef; $self->{author} = undef; $self->{comment} = undef; + $self->{lastcommentaction} = undef; $self->{seen} = {}; + $self->{last_action} = {}; } # End _init @@ -57,8 +59,8 @@ my($physname, $itemtype, $actiontype, $timestamp, $author, $comment) = @{ $data }{qw( physname itemtype actiontype timestamp author comment )}; - my($prevtimestamp, $prevauthor, $prevcomment) = - @{ $self }{qw( timestamp author comment )}; + my($prevtimestamp, $prevauthor, $prevcomment, $prevaction) = + @{ $self }{qw( timestamp author comment actiontype)}; # Any of the following cause a new SVN revision: # * same file touched more than once @@ -67,8 +69,25 @@ # * any action on a directory other than add my $wasseen = $self->{seen}->{$physname}; + my $last_action = $self->{last_action}->{$physname}; - + # in case the current action is the same as the last action + if ($actiontype eq 'SHARE' && $wasseen && $last_action eq $actiontype) { + $wasseen = 0; + } + + # if an add is followed by a share we omit the check for the comment. In most + # cases this is a bulk share started with a project. But the comment is + # only recorded for the project ADDs and not for the files SHARES + if ($actiontype eq 'SHARE' && !defined $comment + && defined $self->{lastcommentaction} + && $self->{lastcommentaction} eq 'ADD') { + $comment = $prevcomment; + } + else { + $self->{lastcommentaction} = $actiontype; + } + no warnings 'uninitialized'; if(($author ne $prevauthor) || ($comment ne $prevcomment) || $wasseen || ($timestamp - $prevtimestamp > $gCfg{revtimerange}) || @@ -90,9 +109,10 @@ $self->{commitPending} = ($itemtype == 1 && $actiontype ne 'ADD') || ($self->{revnum} == 0); $self->{seen}->{$physname}++; + $self->{last_action}->{$physname} = $actiontype;; - @{ $self }{qw( timestamp author comment)} = - ($timestamp, $author, $comment); + @{ $self }{qw( timestamp author comment actiontype)} = + ($timestamp, $author, $comment, $actiontype); } # End check @@ -105,6 +125,7 @@ $self->{svncache}->add( @{ $data }{qw(timestamp author comment)} ); $self->{revnum} = $self->{svncache}->{pkey}; $self->{seen} = {}; + $self->{last_action} = {}; $self->{commitPending} = undef; } # End new_revision From vss2svn-commits at lists.pumacode.org Mon Jul 9 16:25:25 2007 From: vss2svn-commits at lists.pumacode.org (vss2svn-commits@lists.pumacode.org) Date: Mon Jul 9 16:25:29 2007 Subject: r319 - luedi: in /trunk/script: ./ Vss2Svn/ Vss2Svn/Dumpfile/ Message-ID: <20070709202526.4AC8315CDDD@cp.thetahost.com> Author: luedi Date: Mon Jul 9 16:25:25 2007 New Revision: 319 Log: * #59: added a possibility to allow for fine grained label mapping * #60: treat UNPIN/PIN activities as commit and not as copy from * #60: assign a correct comment to an UNPIN/PIN activity * #61: don't create a subversion action if the PIN/UNPIN does not change the state of the file * #62: detect multiple interwoven UNPIN/PIN activities Added: trunk/script/Vss2Svn/Dumpfile/LabelMapper.pm Modified: trunk/script/Vss2Svn/ActionHandler.pm trunk/script/Vss2Svn/Dumpfile.pm trunk/script/vss2svn.pl Modified: trunk/script/Vss2Svn/ActionHandler.pm ============================================================================== --- trunk/script/Vss2Svn/ActionHandler.pm (original) +++ trunk/script/Vss2Svn/ActionHandler.pm Mon Jul 9 16:25:25 2007 @@ -641,13 +641,29 @@ my $parentinfo = \%{$physinfo->{parents}->{$row->{parentphys}}}; + # depending on the version number of the PIN/UNPIN action, we don't have + # to convert this action into a real commit. In this case we only have to + # track, the state. + my $change_action = 1; + my $version = $row->{version}; if (!defined $row->{version}) { # this is the unpin handler + + # is this the unpin version and the last version identically? + $change_action = 0 if (defined $parentinfo->{pinned} + && $parentinfo->{pinned} == $physinfo->{last_version} ); + undef $parentinfo->{pinned}; $version = $physinfo->{last_version}; } else { + # is this the pin version and the last version identically? + # since the UNPIN/PIN merge, it is possible, that the item can still be + # in a pinned state: + $change_action = 0 if ($row->{version} == $physinfo->{last_version} + && !defined $parentinfo->{pinned}); + $parentinfo->{pinned} = $row->{version}; } @@ -659,7 +675,7 @@ # the unpinned target is now also a valid "copy from" itempath $self->_track_item_path ($physname, $row->{parentphys}, $version, $itempath); - return 1; + return $change_action; } # End _pin_handler ############################################################################### Modified: trunk/script/Vss2Svn/Dumpfile.pm ============================================================================== --- trunk/script/Vss2Svn/Dumpfile.pm (original) +++ trunk/script/Vss2Svn/Dumpfile.pm Mon Jul 9 16:25:25 2007 @@ -3,6 +3,7 @@ use Vss2Svn::Dumpfile::Node; use Vss2Svn::Dumpfile::SanityChecker; use Vss2Svn::Dumpfile::AutoProps; +use Vss2Svn::Dumpfile::LabelMapper; require Time::Local; @@ -48,7 +49,7 @@ # new ############################################################################### sub new { - my($class, $fh, $autoprops, $md5) = @_; + my($class, $fh, $autoprops, $md5, $labelmapper) = @_; my $self = { @@ -60,6 +61,7 @@ repository => Vss2Svn::Dumpfile::SanityChecker->new(), auto_props => $autoprops, do_md5 => $md5, + label_mapper => $labelmapper, }; # prevent perl from doing line-ending conversions @@ -567,9 +569,12 @@ # if one of the necessary copy from attributes are unavailable we fall back # to a complete checkin - if (!defined $copyrev || !defined $copypath) { + if (defined $copyrev && defined $copypath) { + $data->{comment} = "ported from $copypath r$copyrev"; + } +# if (!defined $copyrev || !defined $copypath) { return $self->_commit_handler ($itempath, $nodes, $data, $expdir); - } +# } my $node = Vss2Svn::Dumpfile::Node->new(); $node->set_initial_props($itempath, $data); @@ -604,11 +609,19 @@ # the version->revision mapping, since the version could have been used # as a valid share source. if (defined ($label)) { + my $labeldir = $main::gCfg{labeldir}; + + if (defined $self->{label_mapper}) { + $labeldir = $self->{label_mapper}->remap ($main::gCfg{labeldir}, $label); + } + $labeldir =~ s:\\:/:g; + $labeldir =~ s:/$::; + $label =~ s![\\/:*?"<>|]!_!g; my $vssitempath = $itempath; $vssitempath =~ s/^$main::gCfg{trunkdir}//; - my $labelpath = "$main::gCfg{labeldir}/$label$vssitempath"; + my $labelpath = "$labeldir/$label$vssitempath"; $self->_create_svn_path ($nodes, $labelpath); Added: trunk/script/Vss2Svn/Dumpfile/LabelMapper.pm ============================================================================== --- trunk/script/Vss2Svn/Dumpfile/LabelMapper.pm (added) +++ trunk/script/Vss2Svn/Dumpfile/LabelMapper.pm Mon Jul 9 16:25:25 2007 @@ -1,0 +1,56 @@ +package Vss2Svn::Dumpfile::LabelMapper; + +use warnings; +use strict; +use Config::Ini; +use Text::Glob; + +############################################################################### +# new +############################################################################### +sub new { + my($class, $conf) = @_; + + my $self = + { + config => new Config::Ini( $conf, -commentdelim => "#" ), + }; + + $self->{labels} = $self->{config}->get (['labels']); + + $self = bless($self, $class); + return $self; + +} # End new + +############################################################################### +# remap +############################################################################### +sub remap { + my($self, $labeldir, $label) = @_; + + my ($glob, $remap); + + # we need to reset the following each enumeration if we aborted the + # previous one with a premature return + my $dummy = keys %{$self->{labels}}; + + while (($glob, $remap) = each %{ $self->{labels} }) { + if ( $label =~ /$glob/) { + if ($remap->[0] =~ m:^/:) { +# print "remap label: $label to $remap->[0]\n"; + return $remap->[0]; + } + else { +# print "remap label: $label to $labeldir/$remap->[0]\n"; + return $labeldir . "/" . $remap->[0]; + } + + } + } +# print "$label not remaped\n"; + return $labeldir; +} + + +1; Modified: trunk/script/vss2svn.pl ============================================================================== --- trunk/script/vss2svn.pl (original) +++ trunk/script/vss2svn.pl Mon Jul 9 16:25:25 2007 @@ -78,6 +78,10 @@ # Remove unnecessary Unpin/pin activities MERGEUNPINPIN => {handler => \&MergeUnpinPinData, + next => 'BUILDCOMMENTS'}, + + # Rebuild possible missing comments + BUILDCOMMENTS => {handler => \&BuildComments, next => 'BUILDACTIONHIST'}, # Take the history of physical actions and convert them to VSS @@ -444,6 +448,9 @@ # if ($actiontype eq 'PIN') { $vernum = $action->{PinnedToVersion} if (defined $action->{PinnedToVersion}); # } + + # for unpin actions also remeber the unpinned version + $info = $action->{UnpinnedFromVersion} if (defined $action->{UnpinnedFromVersion}); $priority -= 4 if $actiontype eq 'ADD'; # Adds are always first $priority -= 3 if $actiontype eq 'SHARE'; @@ -631,7 +638,7 @@ my $sth = $gCfg{dbh}->prepare($sql); $sth->execute( $depth, $row->{action_id} ); -} # End UpdateParentRec +} # End UpdateDepth ############################################################################### # GetChildRecs @@ -836,21 +843,39 @@ for $r (0 .. @$rows-2) { $row = $rows->[$r]; - $next_row = $rows->[$r+1]; - if ($row->{actiontype} eq 'PIN' - && !defined $row->{version} # UNPIN - && $next_row->{actiontype} eq 'PIN' - && defined $next_row->{version} # PIN - && $row->{physname} eq $next_row->{physname} - && $row->{parentphys} eq $next_row->{parentphys} - && $next_row->{timestamp} - $row->{timestamp} < 60 - && $next_row->{action_id} - $row->{action_id} == 1) { - print "found UNPIN/PIN combination for $row->{parentphys}/$row->{physname}" - . "($row->{itemname}) @ ID $row->{action_id}\n" if $gCfg{verbose}; - push (@delchild, $row->{action_id}); + if ($row->{actiontype} eq 'PIN' && !defined $row->{version}) # UNPIN + { + # Search for a matching pin action + my $u; + for ($u = $r+1; $u <= @$rows-2; $u++) { + $next_row = $rows->[$u]; + + if ( $next_row->{actiontype} eq 'PIN' + && defined $next_row->{version} # PIN + && $row->{physname} eq $next_row->{physname} + && $row->{parentphys} eq $next_row->{parentphys} +# && $next_row->{timestamp} - $row->{timestamp} < 60 +# && $next_row->{action_id} - $row->{action_id} == 1 + ) { + print "found UNPIN/PIN combination for $row->{parentphys}/$row->{physname}" + . "($row->{itemname}) @ ID $row->{action_id}\n" if $gCfg{verbose}; + + # if we have a unpinFromVersion number copy this one to the PIN handler + if (defined $row->{info}) + { + my $sql2 = "UPDATE PhysicalAction SET info = ? WHERE action_id = ?"; + my $sth2 = $gCfg{dbh}->prepare($sql2); + $sth2->execute($row->{info}, $next_row->{action_id}); + } + + push (@delchild, $row->{action_id}); + } + + # if the next action is anything else than a pin stop the search + $u = @$rows if ($next_row->{actiontype} ne 'PIN' ); } - + } } my $id; @@ -861,6 +886,97 @@ 1; } # End MergeUnpinPinData + +############################################################################### +# BuildComments +############################################################################### +sub BuildComments { + my($sth, $rows, $row, $r, $next_row); + my $sql = 'SELECT * FROM PhysicalAction WHERE actiontype="PIN" AND itemtype=2 ORDER BY physname ASC'; + $sth = $gCfg{dbh}->prepare($sql); + $sth->execute(); + + # need to pull in all recs at once, since we'll be updating/deleting data + $rows = $sth->fetchall_arrayref( {} ); + + foreach $row (@$rows) { + + # technically we have the following situations: + # PIN only: we come from the younger version and PIN to a older one: the + # younger version is the currenty version of the timestamp of the PIN action + # UNPIN only: we unpin from a older version to the current version, the + # timestamp of the action will again define the younger version + # UNPIN/PIN with known UNPIN version: we merge from UNPIN version to PIN version + # UNPIN/PIN with unknown UNPIN version: we are lost in this case and we + # can not distinguish this case from the PIN only case. + + my $sql2; + + # PIN only + if ( defined $row->{version} # PIN version number + && !defined $row->{info}) { # no UNPIN version number + $sql2 = 'SELECT * FROM PhysicalAction' + . ' WHERE physname="' . $row->{physname} . '"' + . ' AND parentphys ISNULL' + . ' AND itemtype=2' + . ' AND version>=' . $row->{version} + . ' AND timestamp<=' . $row->{timestamp} + . ' ORDER BY version DESC'; + } + + # UNPIN only + if ( !defined $row->{version} # no PIN version number + && defined $row->{info}) { # UNPIN version number + $sql2 = 'SELECT * FROM PhysicalAction' + . ' WHERE physname="' . $row->{physname} . '"' + . ' AND parentphys ISNULL' + . ' AND itemtype=2' + . ' AND timestamp<=' . $row->{timestamp} + . ' AND version>' . $row->{info} + . ' ORDER BY version ASC'; + } + + # PIN/UNPIN + if ( defined $row->{version} # no PIN version number + && defined $row->{info}) { # UNPIN version number + $sql2 = 'SELECT * FROM PhysicalAction' + . ' WHERE physname="' . $row->{physname} . '"' + . ' AND parentphys ISNULL' + . ' AND itemtype=2' + . ' AND version>' . $row->{info} + . ' AND version<=' . $row->{version} + . ' ORDER BY version ASC'; + } + + next if !defined $sql2; + + my $sth2 = $gCfg{dbh}->prepare($sql2); + $sth2->execute(); + + my $comments = $sth2->fetchall_arrayref( {} ); + my $comment; + print "merging comments for $row->{physname}" if $gCfg{verbose}; + print " from $row->{info}" if ($gCfg{verbose} && defined $row->{info}); + print " to $row->{version}" if ($gCfg{verbose} && defined $row->{version}); + print "\n" if $gCfg{verbose}; + + foreach my $c(@$comments) { + print " $c->{version}: $c->{comment}\n" if $gCfg{verbose}; + $comment .= $c->{comment} . "\n"; + $comment =~ s/^\n+//; + $comment =~ s/\n+$//; + } + + if (defined $comment && !defined $row->{comment}) { + $comment =~ s/"/""/g; + my $sql3 = 'UPDATE PhysicalAction SET comment="' . $comment . '" WHERE action_id = ' . $row->{action_id}; + my $sth3 = $gCfg{dbh}->prepare($sql3); + $sth3->execute(); + } + } + 1; + +} # End BuildComments ############################################################################### # DeleteChildRec @@ -1040,7 +1156,8 @@ $action_sth = $gCfg{dbh}->prepare($sql); my $autoprops = Vss2Svn::Dumpfile::AutoProps->new($gCfg{auto_props}) if $gCfg{auto_props}; - my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{do_md5}); + my $labelmapper = Vss2Svn::Dumpfile::LabelMapper->new($gCfg{label_mapper}) if $gCfg{label_mapper}; + my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{do_md5}, $labelmapper); Vss2Svn::Dumpfile->SetTempDir($gCfg{tempdir}); REVISION: @@ -1165,7 +1282,9 @@ Dumpfile : $gCfg{dumpfile} VSS Encoding : $gCfg{encoding} Auto Props : $gCfg{auto_props} - +trunk dirk : $gCfg{trunkdir} +label dir : $gCfg{labeldir} +label mapper : $gCfg{labelmapper} VSS2SVN ver : $VERSION SSPHYS exe : $gCfg{ssphys} @@ -1563,7 +1682,8 @@ DeletedFile => {type => 2, action => 'DELETE'}, DestroyedFile => {type => 2, action => 'DELETE'}, RecoveredFile => {type => 2, action => 'RECOVER'}, - ArchiveVersionsofFile => {type => 2, action => 'RESTORE'}, + ArchiveVersionsofFile => {type => 2, action => 'ADD'}, + ArchiveVersionsofProject => {type => 1, action => 'ADD'}, ArchiveFile => {type => 2, action => 'DELETE'}, RestoredFile => {type => 2, action => 'RESTORE'}, SharedFile => {type => 2, action => 'SHARE'}, @@ -1799,7 +1919,7 @@ GetOptions(\%gCfg,'vssdir=s','tempdir=s','dumpfile=s','resume','verbose', 'debug','timing+','task=s','revtimerange=i','ssphys=s', - 'encoding=s','trunkdir=s','auto_props=s', 'md5'); + 'encoding=s','trunkdir=s','auto_props=s', 'label_mapper=s', 'md5'); &GiveHelp("Must specify --vssdir") if !defined($gCfg{vssdir}); $gCfg{tempdir} = './_vss2svn' if !defined($gCfg{tempdir}); @@ -1973,6 +2093,7 @@ --auto_props : Specify an autoprops ini file to use, e.g. --auto_props="c:/Dokumente und Einstellungen/user/Anwendungsdaten/Subversion/config" --md5 : generate md5 checksums + --label_mapper : INI style file to map labels to different locataions EOTXT exit(1); From vss2svn-commits at lists.pumacode.org Mon Jul 9 18:29:06 2007 From: vss2svn-commits at lists.pumacode.org (vss2svn-commits@lists.pumacode.org) Date: Mon Jul 9 18:29:08 2007 Subject: r320 - luedi: /trunk/script/vss2svn.pl Message-ID: <20070709222906.B050815CDE7@cp.thetahost.com> Author: luedi Date: Mon Jul 9 18:29:06 2007 New Revision: 320 Log: #60: give a clue in the comment about the direction of the UNPIN/PIN situation. If we are comming from a higher version to a lower version, the comment will be prepended with a "reverted changes for: " message Modified: trunk/script/vss2svn.pl Modified: trunk/script/vss2svn.pl ============================================================================== --- trunk/script/vss2svn.pl (original) +++ trunk/script/vss2svn.pl Mon Jul 9 18:29:06 2007 @@ -911,6 +911,7 @@ # can not distinguish this case from the PIN only case. my $sql2; + my $prefix; # PIN only if ( defined $row->{version} # PIN version number @@ -922,6 +923,7 @@ . ' AND version>=' . $row->{version} . ' AND timestamp<=' . $row->{timestamp} . ' ORDER BY version DESC'; + $prefix = "reverted changes for: \n"; } # UNPIN only @@ -936,8 +938,8 @@ . ' ORDER BY version ASC'; } - # PIN/UNPIN - if ( defined $row->{version} # no PIN version number + # UNPIN/PIN + if ( defined $row->{version} # PIN version number && defined $row->{info}) { # UNPIN version number $sql2 = 'SELECT * FROM PhysicalAction' . ' WHERE physname="' . $row->{physname} . '"' @@ -945,7 +947,16 @@ . ' AND itemtype=2' . ' AND version>' . $row->{info} . ' AND version<=' . $row->{version} - . ' ORDER BY version ASC'; + . ' ORDER BY version '; + + if ($row->{info} > $row->{version}) { + $sql2 .= "DESC"; + $prefix = "reverted changes for: \n"; + } + else { + $sql2 .= "ASC"; + } + } next if !defined $sql2; @@ -968,6 +979,7 @@ } if (defined $comment && !defined $row->{comment}) { + $comment = $prefix . $comment if defined $prefix; $comment =~ s/"/""/g; my $sql3 = 'UPDATE PhysicalAction SET comment="' . $comment . '" WHERE action_id = ' . $row->{action_id}; my $sth3 = $gCfg{dbh}->prepare($sql3); @@ -1284,7 +1296,7 @@ Auto Props : $gCfg{auto_props} trunk dirk : $gCfg{trunkdir} label dir : $gCfg{labeldir} -label mapper : $gCfg{labelmapper} +label mapper : $gCfg{labelmapper} if defined $gCfg{labelmapper} VSS2SVN ver : $VERSION SSPHYS exe : $gCfg{ssphys} From vss2svn-commits at lists.pumacode.org Mon Jul 9 18:45:46 2007 From: vss2svn-commits at lists.pumacode.org (vss2svn-commits@lists.pumacode.org) Date: Mon Jul 9 18:45:48 2007 Subject: r321 - luedi: /trunk/script/vss2svn.pl Message-ID: <20070709224546.CA6BE15CDBD@cp.thetahost.com> Author: luedi Date: Mon Jul 9 18:45:46 2007 New Revision: 321 Log: fixed some typos for md5 (#53) generation and label_mapper (#59) Modified: trunk/script/vss2svn.pl Modified: trunk/script/vss2svn.pl ============================================================================== --- trunk/script/vss2svn.pl (original) +++ trunk/script/vss2svn.pl Mon Jul 9 18:45:46 2007 @@ -1169,7 +1169,7 @@ my $autoprops = Vss2Svn::Dumpfile::AutoProps->new($gCfg{auto_props}) if $gCfg{auto_props}; my $labelmapper = Vss2Svn::Dumpfile::LabelMapper->new($gCfg{label_mapper}) if $gCfg{label_mapper}; - my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{do_md5}, $labelmapper); + my $dumpfile = Vss2Svn::Dumpfile->new($fh, $autoprops, $gCfg{md5}, $labelmapper); Vss2Svn::Dumpfile->SetTempDir($gCfg{tempdir}); REVISION: @@ -1295,8 +1295,9 @@ VSS Encoding : $gCfg{encoding} Auto Props : $gCfg{auto_props} trunk dirk : $gCfg{trunkdir} +md5 : $gCfg{md5} label dir : $gCfg{labeldir} -label mapper : $gCfg{labelmapper} if defined $gCfg{labelmapper} +label mapper : $gCfg{label_mapper} VSS2SVN ver : $VERSION SSPHYS exe : $gCfg{ssphys} From vss2svn-commits at lists.pumacode.org Tue Jul 10 18:45:44 2007 From: vss2svn-commits at lists.pumacode.org (vss2svn-commits@lists.pumacode.org) Date: Tue Jul 10 18:45:46 2007 Subject: r322 - luedi: /trunk/Build.PL Message-ID: <20070710224544.CD30315B7EA@cp.thetahost.com> Author: luedi Date: Tue Jul 10 18:45:43 2007 New Revision: 322 Log: #59: added Jason's patch for the missing new perl modules LabelMapper and also AutoProps Modified: trunk/Build.PL Modified: trunk/Build.PL ============================================================================== --- trunk/Build.PL (original) +++ trunk/Build.PL Tue Jul 10 18:45:43 2007 @@ -20,6 +20,8 @@ 'script/Vss2Svn/Dumpfile.pm' => 'lib/Vss2Svn/Dumpfile.pm', 'script/Vss2Svn/SvnRevHandler.pm' => 'lib/Vss2Svn/SvnRevHandler.pm', 'script/Vss2Svn/Dumpfile/Node.pm' => 'lib/Vss2Svn/Dumpfile/Node.pm', + 'script/Vss2Svn/Dumpfile/AutoProps.pm' => 'lib/Vss2Svn/Dumpfile/AutoProps.pm', + 'script/Vss2Svn/Dumpfile/LabelMapper.pm' => 'lib/Vss2Svn/Dumpfile/LabelMapper.pm', 'script/Vss2Svn/Dumpfile/SanityChecker.pm' => 'lib/Vss2Svn/Dumpfile/SanityChecker.pm', }, PL_files => { 'ssphys/ssphys.PL' => 'bin/ssphys' }, From vss2svn-commits at lists.pumacode.org Wed Jul 18 12:19:20 2007 From: vss2svn-commits at lists.pumacode.org (vss2svn-commits@lists.pumacode.org) Date: Wed Jul 18 12:19:22 2007 Subject: r323 - luedi: /trunk/script/Vss2Svn/Dumpfile.pm Message-ID: <20070718161920.6BDD715CB6E@cp.thetahost.com> Author: luedi Date: Wed Jul 18 12:19:19 2007 New Revision: 323 Log: #51: the CRLF to LF conversion needs to be done on every commit of the file #13: apply auto_props also on renames #25, #53: if a specific version of an item is not recoverable the Copy patch fails to copy the missing file. Modified: trunk/script/Vss2Svn/Dumpfile.pm Modified: trunk/script/Vss2Svn/Dumpfile.pm ============================================================================== --- trunk/script/Vss2Svn/Dumpfile.pm (original) +++ trunk/script/Vss2Svn/Dumpfile.pm Wed Jul 18 12:19:19 2007 @@ -308,6 +308,10 @@ my $node = Vss2Svn::Dumpfile::Node->new(); $node->set_initial_props($newpath, $data); + # change the properties according to the new name + if (defined $self->{auto_props}) { + $node->add_props ($self->{auto_props}->get_props ($newpath)); + } $node->{action} = 'add'; my($copyrev, $copypath); @@ -764,17 +768,27 @@ my($self, $node) = @_; my $fh = $self->{fh}; + # only in an add or rename action the propery array is set. So we have + # to lookup the eol-style flag again. The best thing is to query the + # property always temporarirly + my %tmpProps = (); + if (defined $self->{auto_props}) { + %tmpProps = $self->{auto_props}->get_props ($node->{path}); + } + my $eolStyle = %tmpProps->{'svn:eol-style'}; + my $isNative = (defined $eolStyle && $eolStyle eq 'native') ? 1 : 0; + my $string = $node->get_headers(); print $fh $string; $self->output_content($node->{hideprops}? undef : $node->{props}, - $node->{text}, $node->{file}); + $node->{text}, $node->{file}, $isNative); } # End output_node ############################################################################### # output_content ############################################################################### sub output_content { - my($self, $props, $text, $file) = @_; + my($self, $props, $text, $file, $isNative) = @_; my $fh = $self->{fh}; @@ -803,11 +817,16 @@ my $md5; $md5 = Digest::MD5->new if $self->{do_md5}; + # prevent errors due to non existing files + if(!defined $text && defined $file && !-e $file) { + $text = ""; + } + # convert CRLF -> LF before calculating the size and compute the md5 if(!defined $text && defined $file) { - my ($input, $output); - my $style = $props->{'svn:eol-style'}; - if (defined $style && $style eq 'native') { + + my ($input, $output); + if (defined $isNative) { open ($input, "<:crlf", $file); my $tmpFile = "$gTmpDir/crlf_to_lf.tmp.txt"; open ($output, ">", $tmpFile);