[Rt-commit] rt branch, 4.2/fixup-version-history, repushed

Jim Brandt jbrandt at bestpractical.com
Fri Aug 9 10:17:57 EDT 2013


The branch 4.2/fixup-version-history was deleted and repushed:
       was 541d9b7d406485861e02a11d71347f394e8bc8cb
       now 1426745f80e4dd663a53b3422c71bce46c85d469

1:  884b153 = 1:  884b153 Hide upgrade history from global attributes on config page
-:  ------- > 2:  689e66a Add ids to recorded upgrade entries to track success/failure
-:  ------- > 3:  ce353dc Add before entry to insert actions
2:  541d9b7 ! 4:  1426745 Updates to initial display of RT upgrade history
    @@ -8,61 +8,6 @@
         installed extensions for convenience. Also show upgrades that
         didn't appear to finish.
     
    -diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
    ---- a/sbin/rt-setup-database.in
    -+++ b/sbin/rt-setup-database.in
    -@@
    - 
    - my $package = $args{'package'} || 'RT';
    - my $ext_version = $args{'ext-version'};
    -+my $upgrade_id = Digest::MD5::md5_hex(time . {} . $$ . rand(1024));
    - 
    - foreach my $action ( @actions ) {
    -     no strict 'refs';
    -@@
    -         action   => 'insert',
    -         filename => Cwd::abs_path($file),
    -         content  => $content,
    --        stage    => 'after',);
    -+        stage    => 'after',
    -+        type     => 'process initialdata',
    -+        upgrade_id => $upgrade_id );
    - 
    -     $upgrade_data{'ext_version'} = $ext_version if $ext_version;
    - 
    -@@
    -         from      => $upgrading_from,
    -         to        => $upgrading_to,
    -         versions  => [@versions],
    -+        upgrade_id => $upgrade_id,
    -     });
    - 
    -     my $previous = $upgrading_from;
    -@@
    -             stage  => 'before',
    -             from   => $previous,
    -             to     => $v,
    -+            upgrade_id => $upgrade_id,
    -         });
    - 
    -         my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef, backcompat => \@back);
    -@@
    -             stage  => 'after',
    -             from   => $previous,
    -             to     => $v,
    -+            upgrade_id => $upgrade_id,
    -         });
    - 
    -         $previous = $v;
    -@@
    -         from      => $upgrading_from,
    -         to        => $upgrading_to,
    -         versions  => [@versions],
    -+        upgrade_id => $upgrade_id,
    -     });
    - 
    -     return 1;
    -
     diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
     --- a/share/html/Admin/Tools/Configuration.html
     +++ b/share/html/Admin/Tools/Configuration.html
    @@ -76,37 +21,40 @@
     +
     +if ( not $upgrade_history->{'RT'} ){
     +    $upgrade_history->{'RT'} = [
    -+        { stage => 'after',
    ++        { stage => 'before',
     +          action => 'No upgrade history found',
     +          type => 'individual upgrade',
     +          timestamp => '',
     +          from => 'N/A',
     +          to => 'N/A',
     +          rt_version => '',
    -+          upgrade_id => '1',
    ++          individual_id => '1',
    ++        },
    ++        { stage => 'after',
    ++          individual_id => '1',
     +        }];
     +}
    ++
    ++for my $package (@packages) {
    ++    my $version_status = "Current version: ";
    ++    if ( $package eq 'RT' ){
    ++        $version_status .= $RT::VERSION;
    ++    }
    ++    elsif ( grep {/$package/} @{RT->Config->Get('Plugins')} ) {
    ++        {
    ++            no strict 'refs';
    ++            $version_status .= ${ $package . '::VERSION' };
    ++        }
    ++    }
    ++    else {
    ++        $version_status = "Not currently loaded";
    ++    }
    ++</%perl>
      
     -% my $upgrade_history = RT->System->UpgradeHistory;
     -% my @packages = ('RT', sort grep { $_ ne 'RT' } keys %$upgrade_history);
     -% for my $package (@packages) {
     -<h4><% $package %></h4>
    -+for my $package (@packages) {
    -+    my $version_status = "Current version: ";
    -+    if ( $package eq 'RT' ){
    -+        $version_status .= $RT::VERSION;
    -+    }
    -+    elsif ( grep {/$package/} @{RT->Config->Get('Plugins')} ) {
    -+        {
    -+            no strict 'refs';
    -+            $version_status .= ${ $package . '::VERSION' };
    -+        }
    -+    }
    -+    else {
    -+        $version_status = "Not currently loaded";
    -+    }
    -+</%perl>
    -+
     +<h4><% $package . ' (' . $version_status . ')' %></h4>
      <table border="0" cellspacing="0" cellpadding="5" width="100%" class="collection">
      <tr class="collection-as-table">
    @@ -122,47 +70,39 @@
     -    for my $upgrade (@{ $upgrade_history->{$package} }) {
     -        # only list completed upgrades
     -        next unless $upgrade->{stage} eq 'after';
    -+    my %upgrades;
    -+    foreach my $upgrade ( @{$upgrade_history->{$package}} ){
    -+        # Batch upgrade history by id.
    -+        # Entries within batches are already in time order.
    -+        push @{$upgrades{$upgrade->{upgrade_id}}}, $upgrade;
    -+    }
    -+
    -+    # Sort the batches by time using first (and possibly only) entry
    -+    # in each batch.
    -+    foreach my $upgrade_batch ( sort { $a->[0]{timestamp} <=> $b->[0]{timestamp} }
    -+                                values %upgrades ){
    -+
    ++    my @upgrades;
    ++    my @failed;
    ++UPGRADE: foreach my $upgrade ( @{$upgrade_history->{$package}} ){
     +        my $i = 0;
    -+        my $full_upgrade = grep { $_->{'type'} eq 'full upgrade' } @{ $upgrade_batch };
    -+        # Move the full upgrade entry to first
    -+        unshift @{ $upgrade_batch }, pop @{ $upgrade_batch } if $full_upgrade;
    -+
    -+        foreach my $upgrade (@{ $upgrade_batch }) {
    -+
    -+        if ( $upgrade->{'stage'} eq 'before' ){
    -+            # Find a matching after for this before
    -+            next if ( grep { $_->{'action'} eq 'upgrade'
    -+                             and $_->{'stage'} eq 'after'
    -+                             and $_->{'from'} eq $upgrade->{'from'}
    -+                             and $_->{'to'} eq $upgrade->{'to'} } @{ $upgrade_batch } );
    -+            $upgrade->{'action'} = 'Individual upgrade from ' . $upgrade->{'from'}
    -+              . ' to ' . $upgrade->{'to'} . ' started but not completed';
    ++        if ( $upgrade->{'stage'}
    ++             and $upgrade->{'stage'} eq 'before' ){
    ++            push @upgrades, $upgrade->{'individual_id'};
    ++        }
    ++        elsif ( $upgrade->{'stage'}
    ++                and $upgrade->{'stage'} eq 'after' ){
    ++
    ++            while ( my $before_id = pop @upgrades ){
    ++                # It's the matching after for the last before
    ++                next UPGRADE if $before_id = $upgrade->{'individual_id'};
    ++
    ++                # Didn't match, so we didn't see an after for this id
    ++                push @failed, $before_id;
    ++            }
     +        }
     +
     +        my $tr_class = 'oddline';
     +        if ( $package eq 'RT' ){
     +            if ( $upgrade->{'type'} ne 'full upgrade' ) {
    -+                $tr_class = 'evenline '
    -+                  . 'upgrade-history-' . $upgrade->{'upgrade_id'};
    ++                $tr_class = 'evenline';
    ++                $tr_class .= ' upgrade-history-' . $upgrade->{'full_id'}
    ++                    if $upgrade->{'full_id'};
     +            }
     +        }
     +        else {
     +            $tr_class = $i++ %2 ? 'oddline' : 'evenline';
     +        }
    -+        if ( $full_upgrade and $upgrade->{'type'} eq 'full upgrade' ){
    -+            my $parent_id = $upgrade->{'upgrade_id'};
    ++        if ( $upgrade->{'type'} eq 'full upgrade' ){
    ++            my $parent_id = $upgrade->{'full_id'};
      </%perl>
     -<tr class="<% $i++ %2 ? 'oddline' : 'evenline'%>">
     -    <td class="collection-as-table">
    @@ -183,8 +123,8 @@
     +<tr class="<% $tr_class %>">
     +<td class="collection-as-table"></td>
     +%       }
    -+%       if ( $upgrade->{'type'} ne 'full upgrade'
    -+%            and $full_upgrade ){
    ++%       if ( $upgrade->{'type'} ne 'full upgrade' ){
    ++%#            and $full_upgrade ){
     +<td class="collection-as-table" style="padding-left:15px">
     +%       } else {
     +<td class="collection-as-table">
    @@ -192,7 +132,7 @@
     +%       if ($upgrade->{'action'} eq 'upgrade') { # type is more specific for upgrades
     +<% $upgrade->{'type'} eq 'full upgrade' ? "Upgrade" : "Individual upgrade" %>
     +<&|/l, $upgrade->{'from'}, $upgrade->{'to'} &>from [_1] to [_2]</&>
    -+%       } elsif ( $upgrade->{'type'} eq 'process initialdata' ) {
    ++%       } elsif ( $upgrade->{'action'} eq 'insert' ) {
     +<% "Insert from " . $upgrade->{'filename'} %>
     +%       } else {
     +<% ucfirst($upgrade->{action}) %>
    @@ -210,11 +150,35 @@
     +        <% $upgrade->{rt_version} %>
          </td>
      </tr>
    ++<%perl>
    ++}
    ++# Ids remaining on @upgrades also failed as they didn't have an
    ++# after entry to pop them off
    ++foreach my $id ( @failed, @upgrades ){
    ++    my ($entry) = grep { $_->{'individual_id'} eq $id } @{$upgrade_history->{$package}};
    ++    my $message;
    ++    my $timestamp = RT::Date->new($session{CurrentUser});
    ++    $timestamp->Set(Value => $entry->{timestamp});
    ++
    ++    if ( $entry->{'action'} eq 'upgrade' ){
    ++        $message = 'Upgrade attempt from ' . $entry->{'from'}
    ++        . ' to ' . $entry->{'to'} . ' on ' . $timestamp->AsString
    ++        . ' did not finish.';
    ++    }
    ++    elsif ( $entry->{'action'} eq 'insert' ){
    ++        $message = 'Insert attempt with filename ' . $entry->{'filename'}
    ++        . ' on ' . $timestamp->AsString
    ++        . ' did not finish.';
    ++    }
    ++    else {
    ++        $message = 'An upgrade step on ' . $timestamp->AsString
    ++        . ' did not finish.';
    ++    }
    ++</%perl>
    ++<tr class="oddline"><td class="collection-as-table" colspan=4><% $message %></td></tr>
      % }
    -+% }
      </table>
      % }
    - </&>
     
     diff --git a/share/static/css/base/collection.css b/share/static/css/base/collection.css
     --- a/share/static/css/base/collection.css



More information about the Rt-commit mailing list