Initial add of defaria.com
[clearscm.git] / defaria.com / blogs / Status / archives / 000497.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4 <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <meta name="generator" content="Movable Type 5.2.3" />
7
8    <link rel="stylesheet" href="http://defaria.com/blogs/Status/styles-site.css" type="text/css" />
9    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://defaria.com/blogs/Status/atom.xml" />
10    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://defaria.com/blogs/Status/index.xml" />
11
12    <title>Status for Andrew DeFaria: get_views_for_stream/create_dev_snapview.pl</title>
13
14    <link rel="start" href="http://defaria.com/blogs/Status/" title="Home" />
15    <link rel="prev" href="http://defaria.com/blogs/Status/archives/000496.html" title="cvsims" />
16    <link rel="next" href="http://defaria.com/blogs/Status/archives/000498.html" title="CQ Web/Rebase/GNATS Access" />
17
18    
19
20    
21
22    <script type="text/javascript" src="http://defaria.com/blogs/Status/mt-site.js"></script>
23 </head>
24 <body class="layout-one-column" onload="individualArchivesOnLoad(commenter_name)">
25    <div id="container">
26       <div id="container-inner" class="pkg">
27
28          <div id="banner">
29             <div id="banner-inner" class="pkg">
30                <h1 id="banner-header"><a href="http://defaria.com/blogs/Status/" accesskey="1">Status for Andrew DeFaria</a></h1>
31                <h2 id="banner-description">Searchable status reports and work log</h2>
32             </div>
33          </div>
34
35          <div id="pagebody">
36             <div id="pagebody-inner" class="pkg">
37                <div id="alpha">
38                   <div id="alpha-inner" class="pkg">
39
40                      <p class="content-nav">
41                         <a href="http://defaria.com/blogs/Status/archives/000496.html">&laquo; cvsims</a> |
42                         <a href="http://defaria.com/blogs/Status/">Main</a>
43                         | <a href="http://defaria.com/blogs/Status/archives/000498.html">CQ Web/Rebase/GNATS Access &raquo;</a>
44                      </p>
45
46                      <a id="a000497"></a>
47                      <div class="entry" id="entry-497">
48                         <h3 class="entry-header">get_views_for_stream/create_dev_snapview.pl</h3>
49                         <div class="entry-content">
50                            <div class="entry-body">
51                               <ul>
52   <li>Found and fixed bug in get_views_for_stream</li>
53
54   <li>Fixed bug in create_dev_snapview.pl::ParseBaselines
55 </ul>
56                            </div>
57                            <div id="more" class="entry-more">
58                               <h2>get_views_for_stream</h2>
59
60 <p>Hi Naga. I'm writing you this because I believe there's a bug, possibly with Clearcase, but that seems to manifest itself in code I believe you wrote. I came across this implementing enhancements to create_dev_snapview.pl for Andrew Feltham. In essence Andrew wants to be able to have multiple views in a stream. I've implemented a -reuse_stream parm to allow this. If -reuse_stream is used then the code will skip recreating the stream and effectively just make another view in that same stream. If -reuse_stream is not specified then the stream is removed - along with any views that that stream has.</p>
61
62 <p>It appears as if the code was coded to attempt to handle the case where a stream has multiple views however it fails due to a possible but with lsstream. When calling create_stream the code checks to see if the stream exists and if it does it attempts to recreate the stream by determining the view(s) in the stream, deleting them, deleting the stream and creating the stream anew.</p>
63
64 <p>To determine the view(s) in the stream get_views_for_stream is called. Here's the original function:</p>
65
66 <div class="code"><pre>
67 sub get_views_for_stream {
68     my $sel_pvob = $_[0];
69     my $sel_stream = $_[1];
70
71     my @views = split(/\n/, `cleartool lsstream -fmt \"\%\[views\]p\\n\" stream:$sel_stream\@\\$sel_pvob`);
72     return @views;
73 }
74 </pre></div>
75
76 <p>Essentially it does an lsstream asking for only the views, separated by newlines. The problem is that lsstream (with that format) does not return the views separated by newlines:</p>
77
78 <div class="code"><pre>
79 P:\>cleartool lsstream -fmt "%[views]p\n" stream:Build_rmnaNT_adefaria_LTSJCA-ADEFARIA_sv_ldx_2.3@\rmna_projects
80 adefaria_test adefaria_test2 adefaria_test3
81
82 P:\>
83 </pre></div>
84
85 <p>As you can see adefaria_test, adefaria_test2 and adefaria_test3 all appear on the same line. The code then splits the line on \n and effectively always returns a 1 entry array with possibly multiple view names in the first entry separated by spaces. Needless to say this will fail later on when remove_view is called and it generates a "cleartool rmview -force &lt;view names&gt;".</p>
86
87 <p>Here's my proposed fix:</p>
88
89 <div class="code"><pre>
90 sub get_views_for_stream {
91     my $sel_pvob = $_[0];
92     my $sel_stream = $_[1];
93     # Modified Wed Dec 14 11:25:09 PST 2005 Andrew@DeFaria.com
94     #
95     # Note: The format -fmt "%[views]p\n" below does not work! What is
96     # expected to be returned is:
97     #
98     # view1
99     # view2
100     # view3
101     #
102     # However what is actually returned is:
103     #
104     # view1 view2 view3
105     #
106     # Therefore the old spilt of /\n/ always returned a single entry
107     # array with possibly multiple view names in the first
108     # entry. Changed to use / / for split and not append a \n.
109     my @views = split(/ /, `cleartool lsstream -fmt \"\%\[views\]p\" stream:$sel_stream\@\\$sel_pvob`);
110     return @views;
111 }
112 </pre></div>
113
114 <p>Is this acceptable to you?</p>
115                            </div>
116                         </div>
117                         <p class="entry-footer">
118                            <span class="post-footers">Posted by  on December 14, 2005  1:48 PM</span> <span class="separator">|</span> <a class="permalink" href="http://defaria.com/blogs/Status/archives/000497.html">Permalink</a>
119                         </p>
120                      </div>
121
122                      
123
124                      
125                   </div>
126                </div>
127             </div>
128          </div>
129       </div>
130    </div>
131 </body>
132 </html>