1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
7 <title>Status for Andrew DeFaria: mktriggers.pl and RemoveEmptyBranch.pl</title>
9 <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
10 <link rel="alternate" type="application/rss+xml" title="RSS" href="http://defaria.com/blogs/Status/index.rdf" />
12 <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
13 <link rel="prev" href="http://defaria.com/blogs/Status/archives/000418.html" title="Backup Registry Server/Triggers" />
17 <script type="text/javascript" language="javascript">
20 function OpenTrackback (c) {
23 'width=480,height=480,scrollbars=yes,status=yes');
26 var HOST = 'defaria.com';
28 // Copyright (c) 1996-1997 Athenia Associates.
29 // http://www.webreference.com/js/
30 // License is granted if and only if this entire
31 // copyright notice is included. By Tomer Shiran.
33 function setCookie (name, value, expires, path, domain, secure) {
34 var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
35 document.cookie = curCookie;
38 function getCookie (name) {
39 var prefix = name + '=';
40 var c = document.cookie;
42 var cookieStartIndex = c.indexOf(prefix);
43 if (cookieStartIndex == -1)
45 var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
46 if (cookieEndIndex == -1)
47 cookieEndIndex = c.length;
48 return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
51 function deleteCookie (name, path, domain) {
53 document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
56 function fixDate (date) {
57 var base = new Date(0);
58 var skew = base.getTime();
60 date.setTime(date.getTime() - skew);
63 function rememberMe (f) {
66 now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
67 setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
68 setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
69 setCookie('mtcmthome', f.url.value, now, '', HOST, '');
72 function forgetMe (f) {
73 deleteCookie('mtcmtmail', '', HOST);
74 deleteCookie('mtcmthome', '', HOST);
75 deleteCookie('mtcmtauth', '', HOST);
93 <h1><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
94 <span class="description"></span>
102 <a href="http://defaria.com/blogs/Status/archives/000418.html">« Backup Registry Server/Triggers</a> |
104 <a href="http://defaria.com/blogs/Status/">Main</a>
113 <h2 class="date">September 12, 2005</h2>
115 <div class="blogbody">
117 <h3 class="title">mktriggers.pl and RemoveEmptyBranch.pl</h3>
119 <p>Shivdutt and I feel that the problem that check_full_baseline is hitting is initially caused by having elements that have a 0 element on a branch. This is a common problem as I've explained before - a user checks out a file, it is branched and a 0 element is created as well as a checked out element:</p>
121 <img src="/Images/CheckedOut.jpg">
123 <p>If the user then cancels the checkout then we are left with:</p>
125 <img src="/Images/AfterCancellingCheckout.jpg">
127 <p>There is no difference between /main/1 and /main/andys_branch/0. Both /main/andys_branch/0 and /main/andys_branch can be safely removed. I believe that check_full_baseline corrects this situation by creating yet another identical version /main/andys_branch/1 and checking in yet another identical version.</p>
129 <p>The RemoveEmptyBranch.pl trigger corrects this condition at uncheckout (rmver and rmbranch) time by detecting this situation and removing both /main/andys_branch/0 and /main/andys_branch. It will only do so if the 0 element is the only thing there. If there are labels attached to the 0 element it will not remove it.</p>
131 <p>In order to implement this trigger I had to get the code working here at Broadcom. The RemoveEmptyBranch.pl trigger runs right out of the box, however things must be placed the proper places here at Broadcom. Additionally this trigger should be added to all vobs. Suffice to say, as a Clearcase Admin, I've hit this problem before.</p>
133 <p>My solution is a mktriggers.pl script which adds (or replaces) triggers on all public vobs in a region based on data in a data file which describes triggers. Mktriggers.pl is smart to skips private vobs and UCM project vobs.</p>
135 <p>Finally, mktriggers.pl uses a module of mine called Display.pm, which provides a consistant way of displaying messages.</p>
137 <p>To this regard I have created/ported the following files in //fs-rmna-01/Projects-V0/cc4:</p>
140 <b>bin/mktriggers.pl:</b> Script to make/replace triggers in all vobs based on triggers.dat<br>
141 <b>etc/triggers.dat:</b> Data file describing triggers (currently only describeing RM_EMPTY_BRANCH)<br>
142 <b>triggers/RemoveEmptyBranch.pl:</b> The RM_EMPTY_BRANCH trigger<br>
143 <b>lib/Display.pm:</b> Perl module for displaying messages, errors, warnings consistently<br>
144 <b>lib/Logger.pm:</b> Perl Object for handling creating and manipulating log files (Not used yet)<br>
147 <p>Here's a usage for mktriggers.pl:</p>
148 <div class="code"><pre>
150 Usage mktriggers.pl: [-u] [-n] [-a] [-r] [-v] [ -vobs <vob tag list> ]
152 -u Displays this usage
153 -n No execute mode - just echo out what would have been done
154 -r Perform only replacements of triggers
155 -a Perform only adds of triggers that are missing
158 -vobs List of vob tags to apply triggers to (default all vobs)
161 <p>As you can see there is a no execute mode which just shows what would have been done. Add -v for verbose and it will also echo out the commands that would have been performed. You can also limit mktriggers.pl to only doing additions (-a) or replacements (-r).</p>
163 <p>Mktrigger.pl's data files is in etc/triggers.dat. It's format is relatively simple:</p>
164 <div class="code"><pre>
166 #################################################################################
169 # Description: Describes the triggers to be implemented.
170 # Author: Andrew@DeFaria.com
171 # Created: Mon Mar 15 08:48:24 PST 2004
174 # (c) Copyright 2004, Andrew@DeFaria.com, all rights reserved.
176 ################################################################################
178 # Only the following keywords are currently recognized:
180 # Trigger: Introduces the trigger and gives it its name
181 # Description: Used for the trigger type's comment
182 # Type: Type of trigger (so far they're all -element -all)
183 # Opkinds: Operation kinds that will cause the trigger to fire
184 # ScriptEngine: Currently only supporting ccperl (C:\Program
185 # Files\Rational\ClearCase\bin\ccperl)
186 # Script: Script to run (under triggers)
187 # Vobs: Can be either base, ucm, all or a list of vob tags.
188 # If base is specified then the trigger is applied to
189 # all base Clearcase vobs. If ucm is specified then the
190 # trigger is applied to all ucm vobs. If all is
191 # specified (or if Vobs is not present) then the trigger
192 # is applied to all vobs (base and ucm). Otherwise the
193 # value is considered a space separated list of vob tags
194 # (without the leading "\") and the trigger is applied
195 # only to those vobs.
196 # EndTrigger Ends this trigger definition.
198 ################################################################################
199 Trigger: RM_EMPTY_BRANCH
200 Description: Remove empty branches after uncheckout, rmver or rmbranch
202 Opkinds: -postop rmbranch,rmver,uncheckout
204 Script: RemoveEmptyBranch.pl
208 <p>Next I applied the triggers to ccase-rnma-1 since this is our replicated backup of production and here's the output:</p>
210 <div class="code"><pre>
211 bash-2.05b$ bin/mktriggers.pl -v
212 Adding trigger RM_EMPTY_BRANCH to vob /vobs/A1... done
213 Adding trigger RM_EMPTY_BRANCH to vob /vobs/CommEngine... done
214 Adding trigger RM_EMPTY_BRANCH to vob /vobs/NewTest... done
215 Adding trigger RM_EMPTY_BRANCH to vob /vobs/OnePhone... done
216 Adding trigger RM_EMPTY_BRANCH to vob /vobs/SpiceBoxSW... done
217 Adding trigger RM_EMPTY_BRANCH to vob /vobs/TrainCommEngine... done
218 Adding trigger RM_EMPTY_BRANCH to vob /vobs/alpha_video... done
219 Adding trigger RM_EMPTY_BRANCH to vob /vobs/bfc_systems... done
220 Adding trigger RM_EMPTY_BRANCH to vob /vobs/cablex... done
221 Adding trigger RM_EMPTY_BRANCH to vob /vobs/cablex_tools... done
222 Adding trigger RM_EMPTY_BRANCH to vob /vobs/docs... done
223 Adding trigger RM_EMPTY_BRANCH to vob /vobs/ldx_apps... done
224 Adding trigger RM_EMPTY_BRANCH to vob /vobs/ldx_dev... done
225 Adding trigger RM_EMPTY_BRANCH to vob /vobs/ldx_hausware... done
226 Adding trigger RM_EMPTY_BRANCH to vob /vobs/ldx_tools... done
227 Adding trigger RM_EMPTY_BRANCH to vob /vobs/lucentexcel... done
228 Adding trigger RM_EMPTY_BRANCH to vob /vobs/netro_apps... done
229 Adding trigger RM_EMPTY_BRANCH to vob /vobs/phonex... done
230 Adding trigger RM_EMPTY_BRANCH to vob /vobs/prot_callctrl... done
231 Adding trigger RM_EMPTY_BRANCH to vob /vobs/prot_h248... done
232 Adding trigger RM_EMPTY_BRANCH to vob /vobs/prot_mgcp... done
233 Adding trigger RM_EMPTY_BRANCH to vob /vobs/prot_openssl... done
234 Adding trigger RM_EMPTY_BRANCH to vob /vobs/prot_tools... done
235 Adding trigger RM_EMPTY_BRANCH to vob /vobs/rmna_projects... done
236 Adding trigger RM_EMPTY_BRANCH to vob /vobs/sec_uHSMnCipher... done
237 Adding trigger RM_EMPTY_BRANCH to vob /vobs/telecan... done
238 Adding trigger RM_EMPTY_BRANCH to vob /vobs/test_comp1... done
239 Adding trigger RM_EMPTY_BRANCH to vob /vobs/test_docs... done
240 Adding trigger RM_EMPTY_BRANCH to vob /vobs/test_pvob... done
241 Adding trigger RM_EMPTY_BRANCH to vob /vobs/test_trp_vob... done
242 Adding trigger RM_EMPTY_BRANCH to vob /vobs/voice_res_gw... done
243 Adding trigger RM_EMPTY_BRANCH to vob /vobs/widcomm_bluetooth... done
244 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_common... done
245 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_drivers... done
246 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_qa... done
247 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_qa_cbx... done
248 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_qa_ipp... done
249 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_qa_ldx... done
250 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_qa_op... done
251 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xchg_qa_xme... done
252 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xme... done
253 Adding trigger RM_EMPTY_BRANCH to vob /vobs/xme_sa... done
254 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_Nucleus... done
255 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_TCL... done
256 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_VxWorks... done
257 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_cygwin... done
258 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_eCos... done
259 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_gnu_mips_elf... done
260 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_misc... done
261 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_psos... done
262 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_ti54x... done
263 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_vc... done
264 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_x86... done
265 Adding trigger RM_EMPTY_BRANCH to vob /vobs/zOEMtools_zsp... done
268 <p>When neither add (-a) or replace (-r) is specified mktriggers.pl both adds and/or replaces triggers. If run again with only -a (meaning only add missing triggers) no additional triggers are added. This is a good way to check that no new vobs have been created that are missing triggers or to only add triggers to a vob you just created. You could also specify something like mktriggers.pl -a -vobs /vobs/newvob. Combined with no execute mode and you can easily check if there are any missing triggers without adding them (i.e. mktriggers.pl -n -a).</p>
273 <span class="posted">Posted by Andrew DeFaria at September 12, 2005 07:29 PM