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.rb
#                     
# Purpose:  Generate a limited list of changelists
#                   for a given path.

def init
  begin
  require "P4"
  $p4 = P4.new() 
    
    # Use p4.api_level = <value> to set the data
    # returned by the server to a specific
    # Perforce release, e.g. for 2009.1:
    # p4.api_level = 65
    # The default exception level is RAISE_ALL, but we
    # explicitly state it here for reference:
    
  $p4.exception_level = P4::RAISE_ALL

   # By setting p4.prog we enable listing by the 
   # "p4 monitor show -e"  command so admins can locate 
   # scripts that may be taking too long to complete.
  
  $p4.prog = "Release Notes"
  $p4.client = "script_ws"
  $p4.connect
  rescue P4Exception 
        
        # If we cannot connect to the server, that
        # is a client program error. We do not get
        # server error or warning messages, so we
        # go ahead and exit with a message.
        
        print "Cannot connect to the server."
        exit
   end
end
        
def getdata(cl)
    begin
    res = $p4.run(cl)
    return res
    rescue P4Exception
      $p4.errors.each { |e| puts( e ) }
      $p4.warnings.each { |w| puts( w ) }
    end
end
            
# ########################################################
# PRINT DATA TO STANDARD OUTPUT
# Use this subroutine if you wish to print the results of
# your command.

def printdata(r)
  if $p4.tagged?   
       h = r[0]
       h.each { |k,v|  puts "#{k} => #{v}"} 
      else
      puts r
  end
end 
            
# ######################################################
# WRITE TO A FILE
def writedata() 
    print "Write data to a file. \n"
	# 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.
end
# #######################################################
# 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.
i = 0
while i < chg.size do
    dict = chg[i]
    chg1 = dict["change"]
    puts chg1 
    i += 1
end    
	# 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                
@
