releasing/cbrtools/perl/ViewNotes
changeset 607 378360dbbdba
parent 602 3145852acc89
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 #!perl
       
     2 # Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of the License "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 # 
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 # 
       
    12 # Contributors:
       
    13 # 
       
    14 # Description:
       
    15 # 
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use FindBin;
       
    20 use lib "$FindBin::Bin";
       
    21 use Getopt::Long;
       
    22 use IniData;
       
    23 use RelData;
       
    24 use EnvDb;
       
    25 use NotesCompiler;
       
    26 use CommandController;
       
    27 
       
    28 
       
    29 #
       
    30 # Globals.
       
    31 #
       
    32 
       
    33 my $verbose = 0;
       
    34 my $iniData = IniData->New();
       
    35 my $commandController = CommandController->New($iniData, 'ViewNotes');
       
    36 my $comp1;
       
    37 my $ver1;
       
    38 my $comp2;
       
    39 my $ver2;
       
    40 my $compSummary;
       
    41 my $envSummary;
       
    42 my $diffEnvSummary;
       
    43 my $projectFilter;
       
    44 my $numberFilter;
       
    45 my $outputLocation;
       
    46 my $outputSTDOUTonly;
       
    47 my $htmlNotes="";
       
    48 #
       
    49 # Main.
       
    50 #
       
    51 
       
    52 ProcessCommandLine();
       
    53 
       
    54 if ($htmlNotes eq "") {
       
    55   # User didn't specify --html or --nohtml
       
    56   $htmlNotes = $iniData->HtmlNotes();
       
    57 }
       
    58 my $notesCompiler = NotesCompiler->New($iniData, $comp1, $ver1, $verbose, $outputLocation, $outputSTDOUTonly, $htmlNotes);
       
    59 $notesCompiler->SetProjectFilter($projectFilter);
       
    60 $notesCompiler->SetVersionNumberFilter($numberFilter);
       
    61 if ($compSummary) {
       
    62   if ($outputSTDOUTonly) {
       
    63     die "Error: Cannot use -s with -t\n";
       
    64     Usage(1);
       
    65   }
       
    66   $notesCompiler->DoCompSummary();
       
    67 }
       
    68 elsif ($envSummary or (not $comp1 and not $ver1)) {
       
    69   if ($outputSTDOUTonly && $envSummary) {
       
    70     die "Error: Cannot use -e with -t\n";
       
    71     Usage(1);
       
    72   }
       
    73   elsif ($outputSTDOUTonly and (not $comp1 and not $ver1)){
       
    74     die "Error: When using the -t flag, either <component> or <version> (or both) must be specified\n";
       
    75     Usage(1);
       
    76   }
       
    77   
       
    78   $notesCompiler->DoEnvSummary();
       
    79 }
       
    80 elsif ($diffEnvSummary) {
       
    81   $notesCompiler->DoDiffEnvSummary($comp2, $ver2);
       
    82 }
       
    83 else {
       
    84   $notesCompiler->DoStandardNotes();
       
    85 }
       
    86 if ($outputLocation) {
       
    87   print "LAUNCH LOCATION: ".$notesCompiler->HtmlMainFile();
       
    88 }
       
    89 elsif (!$outputSTDOUTonly){
       
    90   system "start ".$notesCompiler->HtmlFileName();
       
    91 }
       
    92 
       
    93 
       
    94 #
       
    95 # Subs.
       
    96 #
       
    97 
       
    98 sub ProcessCommandLine {
       
    99   Getopt::Long::Configure ("bundling");
       
   100   my $help;
       
   101   GetOptions('h' => \$help, 'e' => \$envSummary, 's' => \$compSummary, 'v+' => \$verbose, 'd' => \$diffEnvSummary, 'p=s' => \$projectFilter, 'n=s' => \$numberFilter, 'o=s' => \$outputLocation, 't' => \$outputSTDOUTonly, 'html!' => \$htmlNotes);
       
   102 
       
   103   if ($help) {
       
   104     Usage(0);
       
   105   }
       
   106 
       
   107   $comp1 = shift @ARGV;
       
   108   $ver1 = shift @ARGV;
       
   109   $comp2 = shift @ARGV;
       
   110   $ver2 = shift @ARGV;
       
   111 
       
   112   if (@ARGV) {
       
   113     print "Error: Invalid arguments\n";
       
   114     Usage(1);
       
   115   }
       
   116 
       
   117   if (defined ($compSummary) + defined ($envSummary) + defined ($diffEnvSummary) > 1) {
       
   118     print "Error: Incompatible options\n";
       
   119     Usage(1);
       
   120   }
       
   121 
       
   122   if ($projectFilter || $numberFilter) {
       
   123     unless ($compSummary || $diffEnvSummary || $envSummary) {
       
   124       print "Error: the -p and -n filters don't make sense if you're just viewing the notes for one release\n";
       
   125       Usage(1);
       
   126     }
       
   127   }
       
   128 
       
   129   if ($compSummary) {
       
   130     unless ($comp1) {
       
   131       print "Error: A component must be specified when using the -s option\n";
       
   132       Usage(1);
       
   133     }
       
   134     if ($ver1) {
       
   135       print "Error: Too many arguments\n";
       
   136       Usage(1);
       
   137     }
       
   138   }
       
   139   elsif ($diffEnvSummary) {
       
   140     if ($comp2 && !$ver2) {
       
   141       print "Error: You must specify a version number for each component\n";
       
   142       Usage(1);
       
   143     }
       
   144     unless ($comp1 && $ver1) {
       
   145       print "Error: You must specify a component and version to difference against\n";
       
   146       Usage(1);
       
   147     }
       
   148   }
       
   149   elsif ($comp1 and not $ver1) {
       
   150     SetVersionToCurrent();
       
   151   }
       
   152 }
       
   153 
       
   154 sub Usage {
       
   155   my $exitCode = shift;
       
   156 
       
   157   Utils::PrintDeathMessage($exitCode, "
       
   158 Usage: viewnotes [options] [[-t] <component> [<version>]]
       
   159        viewnotes [options] -s <component>
       
   160        viewnotes [options] -e [<component> [<version>]]
       
   161        viewnotes [options] -d [-t] <component> <version> [<component> <version>]
       
   162 
       
   163 options:
       
   164 
       
   165 -h  help
       
   166 -s  display a summary all releases made to date for a specified component
       
   167 -e  display a summary of all the releases in the specified environment
       
   168 -d  display a report of all the changes between two environments
       
   169 -v  verbose output (-vv very verbose)
       
   170 -t  output HTML directly to STDOUT, without generating a file
       
   171 -p <project> only display notes for releases in this project
       
   172 -n <version Number> only display notes for releases whose number matches this
       
   173 --html   Display notes made using tools v2.83.1013 and earlier as html
       
   174 --nohtml Display notes made using tools v2.83.1013 and earlier as plain text
       
   175 
       
   176 The --html and --nohtml options override the html_notes setting in reltools.ini\n");
       
   177 }
       
   178 
       
   179 sub SetVersionToCurrent {
       
   180   my $envDb = EnvDb->Open($iniData);
       
   181   $ver1 = $envDb->Version($comp1);
       
   182   unless (defined $ver1) {
       
   183     die "Error: $comp1 not installed in current environment\n";
       
   184   }
       
   185 }
       
   186 
       
   187 
       
   188 
       
   189 =head1 NAME
       
   190 
       
   191 ViewNotes - View the release notes of a component release.
       
   192 
       
   193 =head1 SYNOPSIS
       
   194 
       
   195        viewnotes [options] [[-t] <component> [<version>]]
       
   196        viewnotes [options] -s <component>
       
   197        viewnotes [options] -e [<component> [<version>]]
       
   198        viewnotes [options] -d [-t] <component> <version> [<component> <version>]
       
   199        
       
   200 options:
       
   201 
       
   202   -h  help
       
   203   -s  display a summary all releases made to date for a specified component
       
   204   -e  display a summary of all the releases in the specified environment
       
   205   -d  display a report of all the changes between two environments
       
   206   -v  verbose output (-vv very verbose)
       
   207   -t  output HTML directly to STDOUT, without generating a file
       
   208   -p <project> only display notes for releases in this project
       
   209   -n <version Number> only display notes for releases whose number matches this
       
   210   --html   Display notes made using tools v2.83.1013 and earlier as html
       
   211   --nohtml Display notes made using tools v2.83.1013 and earlier as plain text
       
   212 
       
   213 =head1 DESCRIPTION
       
   214 
       
   215 Launches a web browser to view the HTML release notes of the requested component release. Without C<-s>, C<-e> or C<-d>, it displays the notes for a single component version. If the version is specified, the notes for that component version are displayed. If the version is not specified, the notes for the currently installed component version are displayed. If the version is not specified and the component is currently C<pending release>, the notes for the component are displayed for previewing. 
       
   216 
       
   217 The C<-s> switch may be used to display a summary of all releases made to date (most recent first). The C<-e> switch displays notes for all the components in the specified environment (or your current environment, if you don't specify one).
       
   218 
       
   219 The C<-d> switch produces a single page which shows the release notes for all components which have changed between two environments. This page contains the release notes for each changed release, including any intervening releases which may exist on your release archive.
       
   220 
       
   221 The C<-s>, C<-e> and C<-d> switches all produce information for several releases. In all cases, but especially with C<-d>, you may not want information produced for every release. You can therefore use C<-p> and C<-n> to filter the releases for which you want to see the notes. The C<-n> switch can take a regular expression, so that you can (for example) show only releases starting with a certain phrase.
       
   222 
       
   223 The C<-t> switch will not create a file, but instead, will output the HTML to STDOUT. The output to STDOUT is useful for viewnotes to be built into other scripts and provides more flexibility in viewing release notes.
       
   224 
       
   225 The C<--html> and C<--nohtml> switches override the setting of the html_notes keyword in your reltools.ini file.  This setting controls how the text in release notes made using tools version 2.83.1013 and earlier is displayed in a web browser - either as html (allowing tags to be used) or as plain text.  Note that release notes used with newer versions of tools use the <html/> element to specify whether the text is html or not at time of writing, so this setting is ignored with those releases.
       
   226 
       
   227 (Note: there is also a C<--dummy> switch, which prompts the page to be generated but not displayed in a web browser. This is intended for the use of test scripts).
       
   228 
       
   229 =head1 KNOWN BUGS
       
   230 
       
   231 None.
       
   232 
       
   233 =head1 COPYRIGHT
       
   234 
       
   235  Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
   236  All rights reserved.
       
   237  This component and the accompanying materials are made available
       
   238  under the terms of the License "Eclipse Public License v1.0"
       
   239  which accompanies this distribution, and is available
       
   240  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
   241  
       
   242  Initial Contributors:
       
   243  Nokia Corporation - initial contribution.
       
   244  
       
   245  Contributors:
       
   246  
       
   247  Description:
       
   248  
       
   249 
       
   250 =cut