5 =head1 NAME $RCSfile: diffbl.pl,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Oct 25 11:10:47 PDT 2008
27 $Date: 2011/08/31 21:57:06 $
33 Usage cqperl diffbl.pl: [-u|sage] [-v|erbose] [-d|ebug]
34 [-[baseline1|bl1] <bl1>]
35 [-[baseline2|bl2] <bl2>]
39 -u|sage: Displays usage
41 -d|ebug: Output debug messages
42 -bl1 <bl1> Full baseline 1 to use in the comparison
43 -bl2 <bl2> Full baseline 2 to use in the comparison
44 -p|vob <pvob> Pvob to use
48 This script provides a Perl/Tk GUI application to compare baselines. It provides
49 several benefits over IBM/Rational's graphical diffbl (cleartool diffbl -g ...).
50 First, it assists you in finding baselines to compare whereas diffbl -g requires
51 that you find the baselines yourself. When diffbl.pl is run you are presented
52 with a GUI that you can use to find baselines by either using the dropdown to
53 select pvobs, streams and ultimately baselines. You can also simply type part
54 the name and diffbl.pl will narrow down the list of pvobs, streams or baselines
55 in the drop down. This allows you to easily find the baselines you wish to
58 Additionally, IBM/Rational's diffbl -g -version often shows extremely long, but
59 technically accurate version extended pathnames where the user thinks more along
60 the lines of "path to element in a vob" only. diffbl.pl shows shorter, more
61 easily comprehenable pathnames. diffbl.pl also shows only the latest version of
62 the element. Thus if foo.c changed with version 3, 4 and 5 then you see just
63 foo.c and it represents foo.c version 5.
65 Finally, diffbl.pl provides a way to save the list of elements that have changed
68 diffbl.pl also provides right click menu options to easily show the elements
69 properties, compare to previous, show the version tree and history of the
81 use lib "$FindBin::Bin/../CCDB/lib", "$FindBin::Bin/../lib";
91 $DiffBLUI::SELECTED{pvob} = $ENV{pvob}
92 ? Clearcase::vobname ($ENV{pvob})
105 # Should this be moved to Clearcase.pm?
107 my ($msg, $status, @output) = @_;
109 Tkerror join ("\n", "$msg (Status: $status)", "\n", @output);
115 my $user = $ARCH eq 'windows' ? $ENV{USERNAME} : $ENV{USER};
117 my $viewname = "${user}_$FindBin::Script";
119 Tkmsg "Creating a view to work in", -1;
121 my $newView = Clearcase::View->new ($viewname);
123 # If the streams have changed then we need to recreate the view.
124 $currentStream ||= $DiffBLUI::SELECTED{stream};
126 if ($currentStream ne $DiffBLUI::SELECTED{stream}) {
128 $currentStream = $DiffBLUI::SELECTED{stream};
131 # The create method needs to support additional parameters such as -stream so
132 # we have to do this by hand right now...
133 my ($status, @output) =
134 $Clearcase::CC->execute (
135 "mkview -tag $viewname -stream $DiffBLUI::SELECTED{stream}\@" .
136 "$Clearcase::VOBTAG_PREFIX$DiffBLUI::SELECTED{pvob} -stgloc -auto"
139 unless (grep {/already exists/} @output) {
141 ccerror ("Unable to create view $viewname", $status, @output);
145 $newView->updateViewInfo;
148 ($status, @output) = $newView->start;
150 ccerror ('Unable startview ' . $newView->tag, $status, @output)
158 sub compareBaselines () {
159 unless ($DiffBLUI::SELECTED{pvob}) {
160 Tkerror 'Project Vob must be selected';
164 unless ($DiffBLUI::SELECTED{fromBaseline}) {
165 Tkerror 'From baseline must be selected';
169 unless ($DiffBLUI::SELECTED{toBaseline}) {
170 Tkerror 'To baseline must be selected';
176 if ($DiffBLUI::MODE eq 'versions') {
177 $DiffBLUI::integrationActivitiesCheck->configure (-state => 'disable');
179 $DiffBLUI::integrationActivitiesCheck->configure (-state => 'normal');
182 # Create a view to work in.
185 # Get into the view context
186 my $view_context = $Clearcase::VIEWTAG_PREFIX . '/' . $view->tag;
189 # For my Cygwin environment - translate that path back into a Windows path
190 if ($ARCH eq 'cygwin') {
191 my @cwd = `cygpath -w $cwd`;
197 my ($status, @output) = $Clearcase::CC->execute ("cd \"$view_context\"");
199 ccerror "Unable to set view context to $view_context", $status, @output
202 Tkmsg 'Comparing baselines (This may take a while)', -1;
204 %DiffBLUI::LINES= ();
206 my $cmd = "diffbl -$DiffBLUI::MODE ";
207 $cmd .= $DiffBLUI::SELECTED{fromBaseline};
208 $cmd .= "\@$Clearcase::VOBTAG_PREFIX$DiffBLUI::SELECTED{pvob} ";
209 $cmd .= $DiffBLUI::SELECTED{toBaseline};
210 $cmd .= "\@$Clearcase::VOBTAG_PREFIX$DiffBLUI::SELECTED{pvob}";
212 ($status, @output) = $Clearcase::CC->execute ($cmd);
214 ccerror "Unable to perform command $cmd", $status, @output
219 my $viewtag = $Clearcase::VIEWTAG_PREFIX . '/' . $view->tag;
222 # Skip lines that don't have either <<, >>, <- or -> at the beginning
223 next unless /^(\<\-|\>\>|\<\<|\-\>)\s/;
225 if ($DiffBLUI::MODE eq 'activities') {
226 if (/\W+\s+(.*)\@/) {
227 $DiffBLUI::LINES{$1} = $1;
230 # Change those silly '\'s -> '/'s
233 # Extract the pathname and strip off the version. Note we use a hash here
234 # to get uniqueness based on the element name and only store the last
235 # version checked in. It is very possible, for example, that there is foo
236 # versions 1, 2 and 3 but we want to more simply just report that foo
237 # changed - not that foo changed 3 times.
238 if (/\W+\s+(.*)$Clearcase::SFX/) {
239 my $elementName = $1;
241 # Remove view path and tagname from $elementName
242 $elementName =~ s/$viewtag//;
244 $DiffBLUI::LINES{$elementName} = $elementName;
249 ($status, @output) = $Clearcase::CC->execute ("cd \"$cwd\"");
251 ccerror "Unable to set view context to $cwd", $status, @output
265 'usage' => sub { Usage },
266 'verbose' => sub { set_verbose },
267 'debug' => sub { set_debug },
268 'baseline1|bl1=s' => \$bl1,
269 'baseline2|bl2=s' => \$bl2,
270 'pvob=s' => \$DiffBLUI::SELECTED{pvob},
271 ) or Usage "Invalid parameter";
277 =head1 CONFIGURATION AND ENVIRONMENT
279 DEBUG: If set then $debug is set to this level.
281 VERBOSE: If set then $verbose is set to this level.
283 TRACE: If set then $trace is set to this level.
293 L<Getopt::Long|Getopt::Long>
295 =head2 ClearSCM Perl Modules
311 <a href="http://clearscm.com/php/cvs_man.php?file=lib/Clearcase.pm">Clearcase</a><br>
312 <a href="http://clearscm.com/php/cvs_man.php?file=lib/Clearcase/View.pm">Clearcase::View</a><br>
313 <a href="http://clearscm.com/php/cvs_man.php?file=cc/DiffBLUI.pm">DiffBLUI</a><br>
314 <a href="http://clearscm.com/php/cvs_man.php?file=lib/Display.pm">Display</a><br>
315 <a href="http://clearscm.com/php/cvs_man.php?file=lib/OSDep.pm">OSDep</a><br>
316 <a href="http://clearscm.com/php/cvs_man.php?file=lib/Utils.pm">Utils</a><br>
321 =head1 BUGS AND LIMITATIONS
323 There are no known bugs in this script
325 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
327 =head1 LICENSE AND COPYRIGHT
329 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.