head     1.12106;
access   ;
symbols  ;
locks    ;comment  @@;


1.12106
date     2013.02.02.17.38.28;  author p4;  state Exp;
branches ;
next     ;


desc
@@


1.12106
log
@@
text
@#
# Copyright 2009 Perforce Software.
# This file is part of the Perforce Scripting Class.
# See license.txt for Copyright information.
#
# Module:		relnotes.pl
#                     
# Purpose: 	Generate a limited list of changelists
# 		for a given path.

sub init
{ 
	use P4;
	$p4 = new P4;

	# Use SetApiLevel(<value>) to set the data returned by the
	# server to a specific Perforce release, e.g. for 2009.1:
	# $p4 -> SetApiLevel( 65);
	# Use SetProg(<string>) so Perforce Administrators can
	# see your program's name when running p4 monitor -e

	$p4->SetProg("Release Notes");
	$p4->Connect() or die("Cannot connect to Perforce server");
}

sub getdata
{
	@@cmd = @@_;
	my @@res = $p4->Run(@@cmd);

	# Print warning message if Perforce can't execute command and
	# do some additional checking if tagged output requested.

	if ($p4->ErrorCount()) 
	{
	    @@err = $p4->Errors();
	    foreach $str (@@err)
	    {
		print "Error message: $str";
	     }
	} 
	elsif ($p4->WarningCount()) 
	{
	    @@wrn = $p4->Warnings();
	    foreach $str (@@wrn)
	    {
		print "Warning message: $str \n";
	    }
	} 
	else 
	{	
	    if ($p4->IsTagged()) 
	    {
		# Check for an empty data set.
		if ($#res > -1) 
		{
		    #Check to be sure our command returned a hash.
		    if ($res[0] !~m/^HASH/) 
		    {
			$p4->Disconnect();
			die ("This command does not return tagged output.");
		    }
		}
	    }
   	}
	return @@res;
}
# ########################################################
# PRINT DATA TO STANDARD OUTPUT
# Use this subroutine if you wish to print the results of your command.

sub printdata 
{
	(my @@res) = @@_;
	# If we have tagged output we must dereference the index, e.g.
	if ($p4->IsTagged())
	{
	    foreach $str (@@res)
	    {
		%hash = %{$str};
		while (($key,  $value) = each(%hash)) 
		{
		    print "$key => $value\n";
		}
	    }
	} 
	else 
	{
	    foreach $str (@@res)
	    {
		print ($str, "\n");
	    }
	}
}
# ######################################################
# WRITE TO A FILE
sub writedata 
{
	# Get the array of changelist descriptions from your 
	# data  below. 
	# Open a file handle for your releasenotes file.
	# Iterate over your array and print 
	# Change number <changelist number> and
	# Description <changelist description> from your array.
	# close the file handle to your releasenotes file.
}

# #######################################################
# Construct your command string here as an array, @@fullcommand.
# The syntax is @@fullcommand = ("p4command", "flags", "filespecs")
#
#  MAIN PROGRAM

init();

@@cmd = ("changes", "-s", "submitted", "//Sim/Prod/REL2.1/src/...");
@@chg = getdata(@@cmd);

# Get changelists and push the changelist descriptions to an array.

foreach $str (@@chg)
{
	%hash = %{$str};
	$chg1 = $hash{"change"};
	print "$chg1 \n";

	# Use the $chg1 variable to construct a command 
 	# that performs a 'describe -s' on each changelist
	# using the API command string syntax. 
	# Use getdata(@@your_command) and push the array
	# to a results array e.g. push(@@your_array, @@your_description);
}

# Create a releasenotes file by finishing the writedata subroutine above.

# writedata(@@your_array);

# #####################################################
# Terminate your instance of P4 cleanly:

$p4->Disconnect();                
@
