M000019.html #1

  • //
  • guest/
  • tony_smith/
  • perforce/
  • P4Rubylib/
  • triggers/
  • doc/
  • classes/
  • P4Trigger.src/
  • M000019.html
  • View
  • Commits
  • Open Download .zip Download (2 KB)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>parse_change (P4Trigger)</title>
<link rel=StyleSheet href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body bgcolor="white">
<pre><span class="cmt"># File P4Triggers.rb, line 154</span>
    <span class="kw">def</span> parse_change( change_no )
        <span class="kw">begin</span>
            <span class="kw">if</span> ( ! change_no )
                raise(        <span class="str">&quot;No changelist number supplied to trigger script.\n&quot;</span> +
                        <span class="str">&quot;Please check your trigger configuration.&quot;</span>
                     )
            <span class="kw">end</span>
            get_change( change_no )
            <span class="kw">return</span> ( validate() ? 0 : 1 )
        <span class="kw">rescue</span> 
            <span class="cmt"># Report errors to stderr, so they go into the Perforce server's</span>
            <span class="cmt"># logfile and report a simpler message to stdout</span>
            $stderr.puts( <span class="str">&quot;\nError during trigger execution:\n\n&quot;</span> )
            <span class="kw">if</span> ( $!.kind_of?( P4Exception ) )
                p4.errors.each { |e| $stderr.puts( e ) }
            <span class="kw">else</span>
                $stderr.puts( $!.to_s )
            <span class="kw">end</span>
            $stderr.puts( <span class="str">&quot;\nStack Trace:\n&quot;</span> )
            $stderr.puts( $!.backtrace )
            $stdout.puts( error_message() )

            <span class="cmt"># Now we return false to the caller so they can return with </span>
            <span class="cmt"># the correct exit status</span>
            <span class="kw">return</span> 1
        <span class="kw">end</span>
    <span class="kw">end</span></pre>
</body>
</html>
# Change User Description Committed
#1 3637 Tony Smith Add RDoc documentation to the sample triggers.