releasing/cbrtools/perl/EnvDifferencer.pm
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 14:05:41 +0800
changeset 713 7b7f0409fc00
parent 602 3145852acc89
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
package EnvDifferencer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
use RelData;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
  my $class = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
  my $self = bless {}, (ref $class || $class);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
  $self->{iniData} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
  $self->{verbose} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
  $self->{startcomp} = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
  $self->{endcomp} = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
  $self->{startver} = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
  $self->{endver} = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
  $self->{reldatacache} = {}; # keyed by concatenated of comp and ver
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
  $self->{results} = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
  if ($self->{verbose}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
    require Data::Dumper ;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
    Data::Dumper->import();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
sub SetStartCompVer {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
  $self->Reset();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
  $self->{startcomp} = $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
  $self->{startver} = $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
sub SetEndCompVer {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
  $self->Reset();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
  $self->{endcomp} = $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
  $self->{endver} = $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
sub Reset {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  $self->{results} = undef;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
# Accessor methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
sub StartEnvReldata {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
  die "Start component not defined" unless $self->{startcomp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
  die "Start version not defined" unless $self->{startver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
  return $self->RelData($self->{startcomp}, $self->{startver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
sub EndEnvReldata {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
  die "End component not defined" unless $self->{endcomp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
  die "End version not defined" unless $self->{endver};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
  return $self->RelData($self->{endcomp}, $self->{endver});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
sub StartReldata {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  return $self->RelData($comp, $self->StartVersion($comp));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
sub EndReldata {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
  return $self->RelData($comp, $self->EndVersion($comp));
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
sub StartVersion {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
  return $self->GetStartEnv()->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
sub EndVersion {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  return $self->GetEndEnv()->{$comp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
sub ChangedComps {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  $self->DoDiff;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
  return $self->{results}->{diff}->{changed};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
sub NewerComps {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  $self->CompareDiffDates;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
  return $self->{results}->{diffdates}->{newer};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
sub OlderComps {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  $self->CompareDiffDates;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
  return $self->{results}->{diffdates}->{older};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
sub UnchangedComps {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
  $self->DoDiff;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
  return $self->{results}->{diff}->{same};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
sub OnlyStart {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
  $self->DoDiff;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
  return $self->{results}->{diff}->{onlystart};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
sub OnlyEnd {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
  $self->DoDiff;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
  return $self->{results}->{diff}->{onlyend};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
sub IntermediateReldatas {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
  my $relDataObjects = RelData->OpenSet($self->{iniData}, $comp, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
  my $startdate = $self->StartReldata($comp)->ReleaseTime();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
  my $enddate = $self->EndReldata($comp)->ReleaseTime();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
  # Specifically exclude the start and end reldatas... i.e use < > not <= >=
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
  my @results = grep { $_->ReleaseTime() < $enddate and $_->ReleaseTime() > $startdate } @$relDataObjects;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  return \@results;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
sub GetStartEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
  unless ($self->{results}->{startenv}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
    if ($self->{startcomp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
      $self->{results}->{startenv} = $self->StartEnvReldata()->Environment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
      $self->{results}->{startenv} = $self->CurrentEnv;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
  return $self->{results}->{startenv};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
sub GetEndEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  unless ($self->{results}->{endenv}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
    if ($self->{endcomp}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
      $self->{results}->{endenv} = $self->EndEnvReldata()->Environment();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
      $self->{results}->{endenv} = $self->CurrentEnv;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
  return $self->{results}->{endenv};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
### Private
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
sub CurrentEnv {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
  my $envDb = EnvDb->Open($self->{iniData}, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  return $envDb->VersionInfo();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
sub DoDiff {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
  return if $self->{results}->{diff};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
  die "Neither environment was specified.\n" unless ($self->{startcomp} || $self->{endcomp});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
  my %env1 = %{$self->GetStartEnv()};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
  my %env2 = %{$self->GetEndEnv()};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
  # Deliberately make copies, as we will be deleting stuff from them
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
  if ($self->{verbose}>1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
    print "Start environment is ".Dumper(\%env1)."\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
    print "End environment is ".Dumper(\%env2)."\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
  my @changed;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
  my @onlynew;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
  my @onlyold;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
  my @same;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
  # Compare $env1 against $env2 first.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
  foreach my $thisComp (keys %env1) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
    my $ver1 = $env1{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
    my $ver2 = $env2{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
    if (not defined $ver2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
      push @onlyold, $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
    elsif (lc($ver1) eq lc($ver2)) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
      push @same, $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
    else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
      push @changed, $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
    if (defined $ver2) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
      # Remove this component from $env2 because it has been accounted for.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
      # Components left over in the $env2 hash are those not present in $env1.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
      delete $env2{$thisComp};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
  # List the components in $env2 but not in $env1.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
  @onlynew = keys %env2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
  $self->{results}->{diff} = {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
    same => \@same,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
    onlyend => \@onlynew,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
    onlystart => \@onlyold,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
    changed => \@changed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
  print "At end of main comparison... with results ".Dumper($self->{results}->{diff})."\n" if $self->{verbose}>1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
sub CompareDiffDates {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
  return if $self->{results}->{diffdates};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
  $self->DoDiff; # returns if already completed
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
  my @older;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
  my @newer;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
  foreach my $thisComp (@{$self->{results}->{diff}->{changed}}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
    my $relData1 = $self->StartReldata($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
    my $relData2 = $self->EndReldata($thisComp);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
    if ($relData1->ReleaseTime() <= $relData2->ReleaseTime()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
      push @newer, $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
    } else {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
      push @older, $thisComp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
  $self->{results}->{diffdates} = {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
    older => \@older,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
    newer => \@newer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
  };
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
  print "At end of date comparison... with results ".Dumper($self->{results}->{diffdates})."\n" if $self->{verbose}>1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
sub RelData {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
  my $comp = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
  my $ver = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
  print "Asked for reldata for $comp $ver\n" if $self->{verbose}>2;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
  die "Can't get reldata for undefined comp" unless $comp;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
  die "Can't get reldata for undefined version of $comp" unless $ver;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
  my $key = "$comp$ver";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
  unless ($self->{reldatacache}->{$key}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
    $self->{reldatacache}->{$key} = RelData->Open
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
      ($self->{iniData}, $comp, $ver, $self->{verbose});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
  return $self->{reldatacache}->{$key};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
EnvDifferencer.pm - A class to find differences between two environments.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
This class is used by C<DiffEnv> and C<ViewNotes> to examine the differences between two environments. To use it, first create an object, then use the C<SetStartCompVer> and C<SetEndCompVer> methods to set the component name and version that you wish to compare. You can then use any of the other methods to access information about the differences between them.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   295
=head2 Necessary calls
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   296
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   297
=head3 New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   298
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   299
Expects to be passed two arguments; firstly, an C<IniData> object, and secondly, a verbosity level.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   300
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   301
=head3 SetStartCompVer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   302
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   303
=head3 SetEndCompVer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   304
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   305
These two methods are each passed a component name a version number. These two environments are used for differencing. Note that no differencing is actually performed until information is requested by one of the accessor methods. These methods also call C<Reset>, which means that all results are deleted and a new diff will be performed whenever information is requested.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   306
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   307
If one of these is not called before the comparison, then the current environment (as returned by a C<EnvDb> object) will be used for the missing environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   308
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   309
=head3 Reset
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   310
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   311
This method should never be needed. It resets the object so that it performs a new diff the next time some information is requested.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   312
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   313
=head2 Accessor Methods
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   314
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   315
Any of these may trigger a differencing to happen.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   316
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   317
=head3 StartReldata
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   318
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   319
=head3 EndReldata
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   320
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   321
Takes a component name. Returns a C<RelData> object corresponding to that component in the start or the end environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   322
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   323
=head3 StartVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   324
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   325
=head3 EndVersion
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   326
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   327
Given a component name, returns the version number of that component in the start or the end environment. The behaviour is undefined if that component doesn't exist in the given environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   328
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   329
=head3 GetStartEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   330
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   331
=head3 GetEndEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   332
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   333
Returns a hashref of the components and version numbers in each environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   334
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   335
=head3 StartEnvReldata
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   336
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   337
=head3 EndEnvReldata
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   338
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   339
Returns the C<RelData> object corresponding to the environment itself.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   340
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   341
=head3 ChangedComps
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   342
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   343
Returns a list of component names in both environments, but with different version numbers.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   344
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   345
=head3 UnchangedComps
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   346
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   347
Returns a similar list of those components which are identical in both environments.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   348
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   349
=head3 OnlyStart
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   350
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   351
=head3 OnlyEnd
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   352
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   353
Return lists of those components only in one or other environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   354
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   355
=head3 NewerComps
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   356
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   357
=head3 OlderComps
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   358
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   359
These two methods trigger some additional differencing, which compares the dates of each changed component. They then return a list of those components which are newer, or older, in the end environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   360
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   361
=head3 IntermediateReldatas
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   362
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   363
Given a component name, this returns a list of C<RelData> objects belonging to releases of that component made between the start and end release. It specifically does not include the start or end release.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   364
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   365
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   366
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   367
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   368
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   369
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   370
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   371
 Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   372
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   373
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   374
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   375
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   376
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   377
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   378
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   379
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   380
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   381
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   382
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   383
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   384
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   385
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   386
=cut