Changeset 319

Show
Ignore:
Timestamp:
07/09/2007 04:25:25 PM
Author:
luedi
Message:
  • #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
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/script/Vss2Svn/ActionHandler.pm

    r305 r319  
    642642    my $parentinfo = \%{$physinfo->{parents}->{$row->{parentphys}}}; 
    643643 
     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     
    644649    my $version = $row->{version}; 
    645650    if (!defined $row->{version}) { 
    646651        # 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         
    647657        undef $parentinfo->{pinned}; 
    648658        $version = $physinfo->{last_version}; 
    649659    } 
    650660    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         
    651667        $parentinfo->{pinned} = $row->{version}; 
    652668    } 
     
    660676    $self->_track_item_path ($physname, $row->{parentphys}, $version, $itempath); 
    661677 
    662     return 1
     678    return $change_action
    663679}  #  End _pin_handler 
    664680 
  • trunk/script/Vss2Svn/Dumpfile.pm

    r316 r319  
    44use Vss2Svn::Dumpfile::SanityChecker; 
    55use Vss2Svn::Dumpfile::AutoProps; 
     6use Vss2Svn::Dumpfile::LabelMapper; 
    67 
    78require Time::Local; 
     
    4950############################################################################### 
    5051sub new { 
    51     my($class, $fh, $autoprops, $md5) = @_; 
     52    my($class, $fh, $autoprops, $md5, $labelmapper) = @_; 
    5253 
    5354    my $self = 
     
    6162         auto_props => $autoprops, 
    6263         do_md5 => $md5, 
     64         label_mapper => $labelmapper, 
    6365        }; 
    6466 
     
    568570    # if one of the necessary copy from attributes are unavailable we fall back 
    569571    # 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) { 
    571576        return $self->_commit_handler ($itempath, $nodes, $data, $expdir); 
    572     } 
     577#    } 
    573578     
    574579    my $node = Vss2Svn::Dumpfile::Node->new(); 
     
    605610    # as a valid share source. 
    606611    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         
    607620        $label =~ s![\\/:*?"<>|]!_!g; 
    608621         
    609622        my $vssitempath = $itempath; 
    610623        $vssitempath =~ s/^$main::gCfg{trunkdir}//; 
    611         my $labelpath = "$main::gCfg{labeldir}/$label$vssitempath"; 
     624        my $labelpath = "$labeldir/$label$vssitempath"; 
    612625 
    613626        $self->_create_svn_path ($nodes, $labelpath); 
  • trunk/script/vss2svn.pl

    r316 r319  
    7979            # Remove unnecessary Unpin/pin activities 
    8080            MERGEUNPINPIN => {handler => \&MergeUnpinPinData, 
     81                                 next    => 'BUILDCOMMENTS'}, 
     82 
     83            # Rebuild possible missing comments 
     84            BUILDCOMMENTS => {handler => \&BuildComments, 
    8185                                 next    => 'BUILDACTIONHIST'}, 
    8286 
     
    445449            $vernum = $action->{PinnedToVersion} if (defined $action->{PinnedToVersion}); 
    446450#        } 
     451 
     452        # for unpin actions also remeber the unpinned version 
     453        $info = $action->{UnpinnedFromVersion} if (defined $action->{UnpinnedFromVersion}); 
    447454 
    448455        $priority -= 4 if $actiontype eq 'ADD'; # Adds are always first 
     
    632639    $sth->execute( $depth, $row->{action_id} ); 
    633640 
    634 }  #  End UpdateParentRec 
     641}  #  End UpdateDepth 
    635642 
    636643############################################################################### 
     
    837844    for $r (0 .. @$rows-2) { 
    838845        $row = $rows->[$r]; 
    839         $next_row = $rows->[$r+1]; 
    840846         
    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' ); 
    852877            } 
    853          
     878        } 
    854879    } 
    855880  
     
    862887  
    863888}  #  End MergeUnpinPinData 
     889 
     890############################################################################### 
     891#  BuildComments 
     892############################################################################### 
     893sub 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 
    864980 
    865981############################################################################### 
     
    10411157 
    10421158    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); 
    10441161    Vss2Svn::Dumpfile->SetTempDir($gCfg{tempdir}); 
    10451162 
     
    11661283VSS Encoding : $gCfg{encoding} 
    11671284Auto Props   : $gCfg{auto_props} 
    1168  
     1285trunk dirk   : $gCfg{trunkdir} 
     1286label dir    : $gCfg{labeldir} 
     1287label mapper : $gCfg{labelmapper} 
    11691288 
    11701289VSS2SVN ver  : $VERSION 
     
    15641683        DestroyedFile => {type => 2, action => 'DELETE'}, 
    15651684        RecoveredFile => {type => 2, action => 'RECOVER'}, 
    1566         ArchiveVersionsofFile => {type => 2, action => 'RESTORE'}, 
     1685        ArchiveVersionsofFile => {type => 2, action => 'ADD'}, 
     1686        ArchiveVersionsofProject => {type => 1, action => 'ADD'}, 
    15671687        ArchiveFile => {type => 2, action => 'DELETE'}, 
    15681688        RestoredFile => {type => 2, action => 'RESTORE'}, 
     
    18001920    GetOptions(\%gCfg,'vssdir=s','tempdir=s','dumpfile=s','resume','verbose', 
    18011921               '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'); 
    18031923 
    18041924    &GiveHelp("Must specify --vssdir") if !defined($gCfg{vssdir}); 
     
    19742094                        --auto_props="c:/Dokumente und Einstellungen/user/Anwendungsdaten/Subversion/config" 
    19752095    --md5             : generate md5 checksums 
     2096    --label_mapper    : INI style file to map labels to different locataions 
    19762097EOTXT 
    19772098 

PumaCode.org recommends CVSDude for fast, professional Subversion and Trac hosting:

CVSDude.com

These ads are automatically generated by Google. Revenue from these ads helps to pay for hosting this site; however, these ads do not constitute an endorsement by PumaCode.org.