P4Change.html #1

  • //
  • guest/
  • tony_smith/
  • perforce/
  • P4Rubylib/
  • triggers/
  • doc/
  • classes/
  • P4Change.html
  • View
  • Commits
  • Open Download .zip Download (7 KB)
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: P4Change</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel=StyleSheet href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript" language="JavaScript">
  <!--
  function popCode(url) {
    window.open(url, "Code", 
          "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }
  //-->
  </script>
</head>

<body bgcolor="white">

<table summary="Information on class" width="100%" border="0" cellspacing="0">
 <tr class="title-row">
 <td class="big-title-font">
   <sup><font color="aqua">Class</font></sup> P4Change
 </td>
 <td align="right">
   <table summary="layout" cellspacing="0" cellpadding="2">
     <tr valign="top">
      <td class="small-title-font">In:</td>
      <td class="small-title-font">
        <a href="../files/P4Triggers_rb.html" class="aqua">
P4Triggers.rb
         </a>
<br />
      </td>
     </tr>
     <tr>
      <td class="small-title-font">Parent:</td>
      <td class="small-title-font">
Object
      </td>
     </tr>
   </table>
  </td>
  </tr>
</table>
  <!-- banner header -->



<div class="description"><p>
A class for holding info about a change. This is intended to be populated
be the output of &quot;p4 describe&quot; rather than &quot;p4 change
-o&quot;. The difference is mostly in the case of the hash keys, but
that&#8217;s significant enough.
</p>
</div>


<table summary="Methods" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Methods</td></tr>
</table>
<div class="name-list">
<a href="#M000004">each_file</a>&nbsp; &nbsp;
<a href="#M000005">each_job</a>&nbsp; &nbsp;
<a href="#M000003">new</a>&nbsp; &nbsp;
</div>


<table summary="Attributes" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Attributes</td></tr>
</table>
<table summary="Attribute details" cellspacing="5">
     <tr valign="top">
       <td class="attr-name">change</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">client</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">desc</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">files</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">jobs</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">status</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">time</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
     <tr valign="top">
       <td class="attr-name">user</td>
       <td align="center" class="attr-rw">&nbsp;[R]&nbsp;</td>
       <td></td>
     </tr>
</table>



<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Class methods</td></tr>
</table>
<table summary="method"  width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000003"></a>
<b>new</b>( hash )
</td></tr>
</table>
<div class="description">
<p>
Constructor. Pass the hash returned by P4#run_describe( &quot;-s&quot; ) in
tagged mode.
</p>
</div>
<pre class="source">
<span class="cmt"># File P4Triggers.rb, line 47</span>
    <span class="kw">def</span> initialize( hash )
        @change = hash[ <span class="str">&quot;change&quot;</span>  ]
        @user  = hash[ <span class="str">&quot;user&quot;</span>    ]
        @client = hash[ <span class="str">&quot;client&quot;</span>  ]
        @desc  = hash[ <span class="str">&quot;desc&quot;</span>    ]
        @time  = Time.at( hash[ <span class="str">&quot;time&quot;</span> ].to_i )

        @status        = hash[ <span class="str">&quot;status&quot;</span>  ]
        @files = Array.new
        @jobs = Hash.new

        <span class="kw">if</span> ( hash.has_key?( <span class="str">&quot;depotFile&quot;</span> ) )
            hash[ <span class="str">&quot;depotFile&quot;</span> ].each_index <span class="kw">do</span>
                |i|
                name = hash[ <span class="str">&quot;depotFile&quot;</span>      ][ i ]
                type = hash[ <span class="str">&quot;type&quot;</span>           ][ i ]
                rev    = hash[ <span class="str">&quot;rev&quot;</span>            ][ i ]
                act    = hash[ <span class="str">&quot;action&quot;</span> ][ i ]

                df = P4DepotFile.new( name )
                dr = df.new_revision

                dr.type       = type
                dr.revno      = rev.to_i
                dr.action     = act

                @files.push( df )
            <span class="kw">end</span>
        <span class="kw">end</span>

        <span class="kw">if</span> ( hash.has_key?( <span class="str">&quot;job&quot;</span> ) )
            hash[ <span class="str">&quot;job&quot;</span> ].each_index <span class="kw">do</span>
                |i|
                job   = hash[ <span class="str">&quot;job&quot;</span>      ][ i ]
                status        = hash[ <span class="str">&quot;jobstat&quot;</span> ][ i ]
                @jobs[ job ] = status
            <span class="kw">end</span>
        <span class="kw">end</span>
    <span class="kw">end</span>
</pre>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Instance methods</td></tr>
</table>
<table summary="method"  width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000004"></a>
<b>each_file</b>( &amp;block ) {| f | ...}
</td></tr>
</table>
<div class="description">
<p>
Shorthand iterator for looking at the files in the change
</p>
</div>
<pre class="source">
<span class="cmt"># File P4Triggers.rb, line 90</span>
    <span class="kw">def</span> each_file( &amp;block )
        @files.each { |f| <span class="kw">yield</span>( f ) }
    <span class="kw">end</span>
</pre>
<table summary="method"  width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000005"></a>
<b>each_job</b>( &amp;block ) {| j | ...}
</td></tr>
</table>
<div class="description">
<p>
Shorthand iterator for looking at the jobs fixed by the change
</p>
</div>
<pre class="source">
<span class="cmt"># File P4Triggers.rb, line 95</span>
    <span class="kw">def</span> each_job( &amp;block )
        @jobs.each { |j| <span class="kw">yield</span>( j ) }
    <span class="kw">end</span>
</pre>

</body>
</html>
# Change User Description Committed
#3 4654 Tony Smith Add an example spec trigger to show how you might restrict the
default view for all new clients to a pre-defined set of
mappings.
#2 4640 Tony Smith Add a sample post-commit trigger that can be used to keep a master
and slave branch in sync.
#1 3637 Tony Smith Add RDoc documentation to the sample triggers.