<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Class: IntegMgr</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" /> <script type="text/javascript"> // <![CDATA[ function popupCode( url ) { window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") } function toggleCode( id ) { if ( document.getElementById ) elem = document.getElementById( id ); else if ( document.all ) elem = eval( "document.all." + id ); else return false; elemStyle = elem.style; if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { elemStyle.display = "none" } return true; } // Make codeblocks hidden by default document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) // ]]> </script> </head> <body> <div id="classHeader"> <h1>IntegMgr <sup class="type-note">(Class)</sup></h1> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../files/autointeg_rb.html"> autointeg.rb </a> <br /> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> Object </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <p> This simple class encapsulates the functionality of this script. Essentially, we integrate using a branchspec and auto resolve with ‘Accept Theirs’. This means that there’s no support for maintaining variant branches here, only master/slave branches. Useful for so-called ‘shared files’ (VSS-style). </p> </div> <div id="method-list"> <h2 class="section-bar">Methods</h2> <div class="name-list"> <a href="#M000018">create_change</a> <a href="#M000017">integrate</a> <a href="#M000016">new</a> </div> </div> <div id="attribute-list"> <h2 class="section-bar">Attributes</h2> <div class="name-list"> <table> <tr class="top-aligned-row context-row"> <td class="context-item-name">branch</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">p4</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> </table> </div> </div> </div> <!-- if includes --> <!-- if method_list --> <div id="methods"> <h2 class="section-bar">Public Class methods</h2> <div id="method-M000016" class="method-detail"> <a name="M000016"></a> <div class="method-heading"> <a href="#M000016" class="method-signature"> <span class="method-name">new</span><span class="method-args">( p4, branchspec )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000016-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000016-source"> <pre> <span class="ruby-comment cmt"># File autointeg.rb, line 101</span> 101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">branchspec</span> ) 102: <span class="ruby-ivar">@p4</span> = <span class="ruby-identifier">p4</span> 103: <span class="ruby-ivar">@branch</span> = <span class="ruby-identifier">branchspec</span> 104: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <h2 class="section-bar">Public Instance methods</h2> <div id="method-M000018" class="method-detail"> <a name="M000018"></a> <div class="method-heading"> <a href="#M000018" class="method-signature"> <span class="method-name">create_change</span><span class="method-args">( changeno )</span> </a> </div> <div class="method-description"> <p> Create a new empty changelist for this transaction </p> <p><a class="source-toggle" href="#" onclick="toggleCode('M000018-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000018-source"> <pre> <span class="ruby-comment cmt"># File autointeg.rb, line 145</span> 145: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_change</span>( <span class="ruby-identifier">changeno</span> ) 146: <span class="ruby-identifier">spec</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">fetch_change</span> 147: <span class="ruby-identifier">spec</span>[ <span class="ruby-value str">"Files"</span> ] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span> 148: <span class="ruby-identifier">spec</span>[ <span class="ruby-value str">"Jobs"</span> ] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span> 149: <span class="ruby-identifier">spec</span>[ <span class="ruby-value str">"Description"</span> ] = <span class="ruby-node">"Automatically propagate change #{changeno} "</span> <span class="ruby-operator">+</span> 150: <span class="ruby-value str">"to slave branch."</span> 151: <span class="ruby-identifier">change</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">save_change</span>( <span class="ruby-identifier">spec</span> ).<span class="ruby-identifier">shift</span> 152: <span class="ruby-keyword kw">if</span>( <span class="ruby-identifier">change</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^Change (\d+)/</span> ) 153: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">$1</span> 154: <span class="ruby-keyword kw">end</span> 155: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">P4Exception</span>, <span class="ruby-value str">"Unable to create an empty pending changelist"</span> ) 156: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000017" class="method-detail"> <a name="M000017"></a> <div class="method-heading"> <a href="#M000017" class="method-signature"> <span class="method-name">integrate</span><span class="method-args">( change )</span> </a> </div> <div class="method-description"> <p> Integrate the specified change through the branch view and resolve them. </p> <p><a class="source-toggle" href="#" onclick="toggleCode('M000017-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000017-source"> <pre> <span class="ruby-comment cmt"># File autointeg.rb, line 112</span> 112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">integrate</span>( <span class="ruby-identifier">change</span> ) 113: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_sync</span> 114: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">create_change</span>( <span class="ruby-identifier">change</span> ) 115: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_integrate</span>( <span class="ruby-value str">"-c"</span>, <span class="ruby-identifier">c</span>, <span class="ruby-value str">"-b"</span>, <span class="ruby-identifier">branch</span>, <span class="ruby-value str">"-s"</span>, 116: <span class="ruby-node">"//...@#{change},@#{change}"</span> ) 117: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_resolve</span>( <span class="ruby-value str">"-at"</span> ) 118: 119: <span class="ruby-comment cmt"># Build a list of the files to be submitted.</span> 120: <span class="ruby-identifier">filelist</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_opened</span>( <span class="ruby-value str">"-c"</span>, <span class="ruby-identifier">c</span> ).<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> 121: <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span> 122: <span class="ruby-identifier">sprintf</span>( <span class="ruby-value str">"%s#%s (%s)"</span>, <span class="ruby-identifier">h</span>[ <span class="ruby-value str">"depotFile"</span> ], <span class="ruby-identifier">h</span>[ <span class="ruby-value str">"rev"</span> ], <span class="ruby-identifier">h</span>[ <span class="ruby-value str">"action"</span> ] ) 123: <span class="ruby-keyword kw">end</span> 124: 125: <span class="ruby-comment cmt"># If no files were opened for integrate, there's nothing to do, so</span> 126: <span class="ruby-comment cmt"># we just delete our pending changelist and get out of here</span> 127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filelist</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> 128: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">delete_change</span>( <span class="ruby-identifier">c</span> ) 129: <span class="ruby-keyword kw">return</span> 130: <span class="ruby-keyword kw">end</span> 131: 132: <span class="ruby-comment cmt"># Now submit it. </span> 133: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_submit</span>( <span class="ruby-value str">"-c"</span>, <span class="ruby-identifier">c</span> ) 134: 135: <span class="ruby-identifier">admin_report</span> <span class="ruby-keyword kw">do</span> 136: <span class="ruby-node">"Change #{change} automatically integrated using branchspec "</span> <span class="ruby-operator">+</span> 137: <span class="ruby-ivar">@branch</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"\n\n"</span> <span class="ruby-operator">+</span> 138: <span class="ruby-value str">"Affected Files:\n\n\t"</span> <span class="ruby-operator">+</span> 139: <span class="ruby-identifier">filelist</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value str">"\n\t"</span> ) <span class="ruby-operator">+</span> 140: <span class="ruby-value str">"\n"</span> 141: <span class="ruby-keyword kw">end</span> 142: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> </div> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 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. |
||
#1 | 4640 | Tony Smith |
Add a sample post-commit trigger that can be used to keep a master and slave branch in sync. |