| 383 |
dpurdie |
1 |
########################################################################
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 383 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : jats_vcsdiff.pl
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : Create two views and DIFF them
|
|
|
10 |
# The views can be any type understood by JATS
|
|
|
11 |
# Can:
|
|
|
12 |
# - Compare with MD5SUms
|
|
|
13 |
# - Invoke BeyondCompare
|
|
|
14 |
#
|
|
|
15 |
#......................................................................#
|
|
|
16 |
|
|
|
17 |
require 5.008_002;
|
|
|
18 |
use strict;
|
|
|
19 |
use warnings;
|
|
|
20 |
|
|
|
21 |
use Pod::Usage;
|
|
|
22 |
use Getopt::Long;
|
|
|
23 |
|
|
|
24 |
use JatsError;
|
|
|
25 |
use JatsSystem;
|
| 7213 |
dpurdie |
26 |
use JatsRmApi;
|
|
|
27 |
use DBI;
|
| 383 |
dpurdie |
28 |
use FileUtils;
|
|
|
29 |
use Cwd;
|
|
|
30 |
|
|
|
31 |
my $VERSION = "1.0.0"; # Update this
|
|
|
32 |
|
|
|
33 |
#
|
|
|
34 |
# Options
|
|
|
35 |
#
|
|
|
36 |
my $opt_debug = $ENV{'GBE_DEBUG'}; # Allow global debug
|
|
|
37 |
my $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbose
|
|
|
38 |
my $opt_help = 0;
|
|
|
39 |
my $opt_new_label;
|
|
|
40 |
my $opt_old_label;
|
|
|
41 |
my $opt_md5check;
|
|
|
42 |
my $opt_mode;
|
| 2931 |
dpurdie |
43 |
my $opt_diff;
|
| 7213 |
dpurdie |
44 |
my $opt_rtag_id;
|
|
|
45 |
my $opt_package_name;
|
| 6085 |
dpurdie |
46 |
my @opt_options;
|
| 383 |
dpurdie |
47 |
|
|
|
48 |
#
|
|
|
49 |
# Globals - Provided by the JATS environment
|
|
|
50 |
#
|
|
|
51 |
my $USER = $ENV{'USER'};
|
|
|
52 |
my $UNIX = $ENV{'GBE_UNIX'};
|
|
|
53 |
my $TMP = $UNIX ? "/tmp" : $ENV{'TMP'};
|
|
|
54 |
my $MACHINENAME = $ENV{'GBE_HOSTNAME'};
|
|
|
55 |
|
|
|
56 |
#
|
|
|
57 |
# Globals
|
|
|
58 |
#
|
| 2931 |
dpurdie |
59 |
my $Name = 'BeyondCompare';
|
| 3967 |
dpurdie |
60 |
my $DiffProg;
|
| 2931 |
dpurdie |
61 |
my @DiffArgs;
|
|
|
62 |
my $DiffWait;
|
| 383 |
dpurdie |
63 |
my @view_tags;
|
|
|
64 |
my @view_commands;
|
|
|
65 |
my @cleanFiles;
|
|
|
66 |
|
| 7213 |
dpurdie |
67 |
my $RM_DB; # Database interface
|
|
|
68 |
my $package_name; # Selected package name.
|
|
|
69 |
my $package_ver; # Selected package version.
|
|
|
70 |
my $package_vcs; # Selected package VCS tag.
|
|
|
71 |
my $package_vcs_base; # Selected package base path.
|
|
|
72 |
my $package_release_branch; # Selected package release branch or nul if released on trunk.
|
| 383 |
dpurdie |
73 |
|
| 7213 |
dpurdie |
74 |
|
| 383 |
dpurdie |
75 |
#-------------------------------------------------------------------------------
|
|
|
76 |
# Function : Mainline Entry Point
|
|
|
77 |
#
|
|
|
78 |
# Description :
|
|
|
79 |
#
|
|
|
80 |
# Inputs :
|
|
|
81 |
#
|
|
|
82 |
|
|
|
83 |
#
|
|
|
84 |
# Parse the user options
|
|
|
85 |
#
|
|
|
86 |
my $result = GetOptions (
|
| 7213 |
dpurdie |
87 |
'help|h:+' => \$opt_help, # Help Level
|
|
|
88 |
'manual:3' => \$opt_help, # Help Level
|
|
|
89 |
"verbose:+" => \$opt_verbose, # Verbosity
|
|
|
90 |
"debug:+" => \$opt_debug, # Debug Verbosity
|
|
|
91 |
"new=s" => \$opt_new_label, # Path1
|
|
|
92 |
"old=s" => \$opt_old_label, # Path2
|
|
|
93 |
'check' => \$opt_md5check, # Force MD5 Check
|
|
|
94 |
'diff!' => \$opt_diff, # Force use of diff
|
|
|
95 |
"rtagid|rtag_id=s" => \$opt_rtag_id, # Release tag needed for release extractions
|
|
|
96 |
"package=s" => \$opt_package_name, # Name of the package to query
|
|
|
97 |
'option=s' => \@opt_options, # User options
|
| 383 |
dpurdie |
98 |
);
|
|
|
99 |
|
|
|
100 |
#
|
|
|
101 |
# UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
|
|
|
102 |
#
|
|
|
103 |
|
|
|
104 |
#
|
|
|
105 |
# Process help and manual options
|
|
|
106 |
#
|
|
|
107 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result );
|
|
|
108 |
pod2usage(-verbose => 1) if ($opt_help == 2 );
|
| 7213 |
dpurdie |
109 |
pod2usage(-verbose => 2) if ($opt_help > 2 );
|
| 383 |
dpurdie |
110 |
|
|
|
111 |
InitFileUtils();
|
|
|
112 |
|
|
|
113 |
#
|
|
|
114 |
# Configure the error reporting process now that we have the user options
|
|
|
115 |
#
|
|
|
116 |
ErrorConfig( 'name' => 'VCSDIFF',
|
|
|
117 |
'verbose' => $opt_verbose,
|
|
|
118 |
'debug' => $opt_debug );
|
|
|
119 |
|
| 2931 |
dpurdie |
120 |
Error ("Options -check and -diff cannot be combined")
|
|
|
121 |
if ( $opt_md5check && $opt_diff );
|
|
|
122 |
|
| 383 |
dpurdie |
123 |
#
|
|
|
124 |
# Determine mode
|
|
|
125 |
# Not all modes work on all machines
|
|
|
126 |
#
|
|
|
127 |
Verbose ("Machine Type: UNIX=$UNIX");
|
|
|
128 |
if ( $opt_md5check )
|
|
|
129 |
{
|
|
|
130 |
$opt_mode = 'md5';
|
|
|
131 |
}
|
| 2931 |
dpurdie |
132 |
elsif ( $UNIX || $opt_diff )
|
|
|
133 |
{
|
|
|
134 |
$opt_mode = 'diff';
|
|
|
135 |
$Name = 'diff';
|
|
|
136 |
push @DiffArgs, '-r';
|
|
|
137 |
$Name = 'gdiff';
|
|
|
138 |
$DiffProg = LocateProgInPath( $Name, '--All');
|
|
|
139 |
unless ( $DiffProg =~ m~/~ )
|
|
|
140 |
{
|
|
|
141 |
$Name = 'diff';
|
|
|
142 |
$DiffProg = LocateProgInPath( $Name, '--All');
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
Error ("Cannot locate a 'diff' utility in the users PATH")
|
|
|
146 |
unless ( $DiffProg =~ m~/~ );
|
|
|
147 |
}
|
| 383 |
dpurdie |
148 |
else
|
|
|
149 |
{
|
|
|
150 |
$opt_mode = 'bc2';
|
| 2931 |
dpurdie |
151 |
$DiffWait = 1;
|
| 383 |
dpurdie |
152 |
|
|
|
153 |
#
|
| 3967 |
dpurdie |
154 |
# Determine the path to Beyond Compare Exe
|
|
|
155 |
# It may not be installed in the default place, but the Windows
|
|
|
156 |
# registry will know where it is
|
| 383 |
dpurdie |
157 |
#
|
| 3967 |
dpurdie |
158 |
GetBeyondCompareExePath();
|
| 383 |
dpurdie |
159 |
}
|
|
|
160 |
|
|
|
161 |
#
|
|
|
162 |
# Validate user options
|
|
|
163 |
#
|
|
|
164 |
# Be nice to the user
|
|
|
165 |
# If we have two options and no labels, then assign them
|
|
|
166 |
#
|
|
|
167 |
if ( ! $opt_new_label && ! $opt_old_label )
|
|
|
168 |
{
|
|
|
169 |
Error ("Must provide two labels on command line unless they are provided via -old and -new options")
|
|
|
170 |
if ( $#ARGV < 1 );
|
|
|
171 |
|
|
|
172 |
$opt_old_label = shift @ARGV;
|
|
|
173 |
$opt_new_label = shift @ARGV;
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
Error ("Need two labels on the command line, or via options")
|
|
|
177 |
unless ( $opt_old_label && $opt_new_label );
|
|
|
178 |
|
|
|
179 |
Error ("Too many command line arguments" )
|
|
|
180 |
unless ( $#ARGV < 0 );
|
|
|
181 |
|
|
|
182 |
#
|
|
|
183 |
# Extract parameters that will be used to create a view that is
|
|
|
184 |
# unique. Will use hostname and user name
|
|
|
185 |
#
|
|
|
186 |
Error ("Machine Name not determined")
|
|
|
187 |
unless ( $MACHINENAME );
|
|
|
188 |
|
|
|
189 |
Error ("USER name not determined" )
|
|
|
190 |
unless ( $USER );
|
|
|
191 |
|
|
|
192 |
#
|
|
|
193 |
# Need a TMP working directory
|
|
|
194 |
# Used to create config files
|
|
|
195 |
#
|
|
|
196 |
Error ("TMP not found or not a directory")
|
|
|
197 |
unless ( $TMP && -d $TMP );
|
|
|
198 |
$TMP = "$TMP/$$";
|
|
|
199 |
|
|
|
200 |
#
|
| 7213 |
dpurdie |
201 |
# Translate special label names.
|
|
|
202 |
#
|
|
|
203 |
$opt_old_label = translateSpecialLabelName( "old", $opt_old_label );
|
|
|
204 |
$opt_new_label = translateSpecialLabelName( "new", $opt_new_label );
|
|
|
205 |
|
|
|
206 |
#
|
| 383 |
dpurdie |
207 |
# Create views for the two views
|
|
|
208 |
# Verify that the view are present
|
|
|
209 |
#
|
|
|
210 |
Message ("Constructing views");
|
| 7213 |
dpurdie |
211 |
Message (" old = $opt_old_label" );
|
|
|
212 |
Message (" new = $opt_new_label" );
|
| 383 |
dpurdie |
213 |
my $path1 = create_view( $opt_old_label, 1 );
|
|
|
214 |
my $path2 = create_view( $opt_new_label, 2 );
|
|
|
215 |
|
|
|
216 |
Error ("Cannot locate view directory: $path1" ) unless (-d $path1);
|
|
|
217 |
Error ("Cannot locate view directory: $path2" ) unless (-d $path2);
|
|
|
218 |
|
|
|
219 |
#
|
|
|
220 |
# If one of the paths is a dynamic view and the other is a local path
|
|
|
221 |
# then attempt to locate the common directories
|
|
|
222 |
#
|
|
|
223 |
if ( $#view_tags == 0 )
|
|
|
224 |
{
|
|
|
225 |
massage_paths();
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
if ( $opt_md5check )
|
|
|
229 |
{
|
|
|
230 |
Verbose ("Performing MD5 Check");
|
|
|
231 |
my $checkfile = 'vcsdiff_md5.txt';
|
|
|
232 |
my $rv;
|
|
|
233 |
push @cleanFiles, $checkfile;
|
|
|
234 |
$rv = JatsTool ('jats_manifest', '-quiet',
|
|
|
235 |
'-manifest', $checkfile,
|
|
|
236 |
'-rootdir', $path1 );
|
|
|
237 |
|
|
|
238 |
$rv = JatsTool ('jats_manifest', '-quiet', '-check',
|
|
|
239 |
'-manifest', $checkfile,
|
|
|
240 |
'-rootdir', $path2 ) unless $rv;
|
|
|
241 |
|
|
|
242 |
exit $rv;
|
|
|
243 |
}
|
|
|
244 |
|
| 2931 |
dpurdie |
245 |
#
|
|
|
246 |
# Diffing the paths
|
|
|
247 |
# Will use BeyondCompare under Windows
|
|
|
248 |
# Will use diff under unix
|
|
|
249 |
#
|
|
|
250 |
Message ("Using '$Name' to compare two views",
|
|
|
251 |
"Wait for utility to exit so that we can delete the views" ) if ($DiffWait);
|
| 383 |
dpurdie |
252 |
|
| 2931 |
dpurdie |
253 |
Verbose ("Diff Utility: $DiffProg");
|
| 6085 |
dpurdie |
254 |
System ( $DiffProg, @DiffArgs, split(/,/, join (',', @opt_options)), $path1, $path2 );
|
| 383 |
dpurdie |
255 |
exit 0;
|
|
|
256 |
|
|
|
257 |
#-------------------------------------------------------------------------------
|
|
|
258 |
# Function : create_view
|
|
|
259 |
#
|
|
|
260 |
# Description : Create dynamic view, based on a Vcs Tag
|
|
|
261 |
#
|
|
|
262 |
# Inputs : $vcstag
|
|
|
263 |
#
|
|
|
264 |
# Returns : Path to the view
|
|
|
265 |
#
|
|
|
266 |
sub create_view
|
|
|
267 |
{
|
|
|
268 |
my ($vcstag, $num) = @_;
|
|
|
269 |
|
|
|
270 |
#
|
|
|
271 |
# Intercept and treat the special label 'current'
|
|
|
272 |
#
|
|
|
273 |
return create_path_view( $vcstag )
|
|
|
274 |
if ( $vcstag eq 'current' || $vcstag =~ m~^dir=.+~ || $vcstag =~ m~^current=.+~ );
|
|
|
275 |
|
|
|
276 |
my $tag = "${USER}_${MACHINENAME}_vcsdiff_${num}";
|
|
|
277 |
push @view_tags, $tag;
|
|
|
278 |
|
|
|
279 |
#
|
|
|
280 |
# Use vcsrelease to do the hard work
|
|
|
281 |
#
|
|
|
282 |
my @command = ( 'jats_vcsrelease',
|
|
|
283 |
'-extractfiles',
|
|
|
284 |
'-root=.' ,
|
|
|
285 |
'-noprefix',
|
| 1403 |
dpurdie |
286 |
'-devmode=escrow',
|
| 383 |
dpurdie |
287 |
'-view', $tag ,
|
|
|
288 |
'-label', $vcstag,
|
|
|
289 |
);
|
|
|
290 |
push @view_commands, \@command;
|
|
|
291 |
|
|
|
292 |
if ( $opt_debug && -d $tag )
|
|
|
293 |
{
|
|
|
294 |
Message ("Using existing view");
|
|
|
295 |
}
|
|
|
296 |
else
|
|
|
297 |
{
|
|
|
298 |
JatsTool( @command );
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
#
|
|
|
302 |
# Minor Kludge
|
|
|
303 |
# Should be in a library
|
|
|
304 |
# Iff CC::, then process path info too
|
|
|
305 |
#
|
|
|
306 |
if ( $vcstag =~ m~^CC::(.*?)(::(.+))?$~ )
|
|
|
307 |
{
|
|
|
308 |
my $path = $1;
|
|
|
309 |
if ( $path )
|
|
|
310 |
{
|
|
|
311 |
my $try = $tag . '/' . $path;
|
|
|
312 |
if ( -d $try )
|
|
|
313 |
{
|
|
|
314 |
$tag = $try;
|
|
|
315 |
}
|
|
|
316 |
}
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
return $tag;
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
#-------------------------------------------------------------------------------
|
|
|
323 |
# Function : create_path_view
|
|
|
324 |
#
|
|
|
325 |
# Description : Not using a view, using a path
|
|
|
326 |
# Return the path as requested
|
|
|
327 |
#
|
|
|
328 |
# Inputs : $label - with embedded path
|
|
|
329 |
#
|
|
|
330 |
# Returns : Path to the (dummy) view
|
|
|
331 |
#
|
|
|
332 |
sub create_path_view
|
|
|
333 |
{
|
|
|
334 |
my ($label) = @_;
|
|
|
335 |
my $path = '.';
|
|
|
336 |
|
|
|
337 |
$path = $1
|
|
|
338 |
if ( $label =~ m~.+=(.+)~ );
|
|
|
339 |
|
|
|
340 |
Error ("Directory not found: $path" )
|
|
|
341 |
unless ( -d $path );
|
|
|
342 |
|
|
|
343 |
$path = FullPath( $path );
|
|
|
344 |
return $path;
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
#-------------------------------------------------------------------------------
|
|
|
348 |
# Function : massage_paths
|
|
|
349 |
#
|
|
|
350 |
# Description : Used when one of the paths is a view and the the other
|
|
|
351 |
# is a local directory.
|
|
|
352 |
#
|
|
|
353 |
# Attempt to locate the common root
|
|
|
354 |
#
|
|
|
355 |
# Inputs : None
|
|
|
356 |
#
|
|
|
357 |
# Returns : Modifies $path1 and $path2
|
|
|
358 |
#
|
|
|
359 |
sub massage_paths
|
|
|
360 |
{
|
|
|
361 |
my $view_path = $view_tags[0];
|
|
|
362 |
my $user_path = $path1;
|
|
|
363 |
$user_path = $path2 if ( $view_path eq $path1 );
|
|
|
364 |
|
|
|
365 |
#
|
|
|
366 |
# Split the user path into its component directory entries
|
|
|
367 |
# Start at the top and look for one of these in the view
|
|
|
368 |
#
|
|
|
369 |
my @user_path = split ('/', $user_path );
|
| 7040 |
dpurdie |
370 |
shift @user_path if $user_path[0] eq '';
|
| 383 |
dpurdie |
371 |
my $tpath = '';
|
|
|
372 |
foreach my $dir ( @user_path )
|
|
|
373 |
{
|
|
|
374 |
if ( -d "$view_path/$dir" )
|
|
|
375 |
{
|
|
|
376 |
#
|
|
|
377 |
# Common directory found
|
|
|
378 |
# Set the user path to the previous directory
|
|
|
379 |
#
|
|
|
380 |
$user_path = $tpath;
|
|
|
381 |
if ( $view_path eq $path1 )
|
|
|
382 |
{
|
|
|
383 |
$path2 = $user_path;
|
|
|
384 |
}
|
|
|
385 |
else
|
|
|
386 |
{
|
|
|
387 |
$path1 = $user_path;
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
#
|
|
|
391 |
# now add the common part
|
|
|
392 |
#
|
|
|
393 |
$path1 .= "/$dir";
|
|
|
394 |
$path2 .= "/$dir";
|
|
|
395 |
Message ("Setting common root path ($dir)", $path1, $path2);
|
|
|
396 |
last;
|
|
|
397 |
}
|
|
|
398 |
$tpath .= '/' if ( $tpath );
|
|
|
399 |
$tpath .= $dir;
|
|
|
400 |
}
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
#-------------------------------------------------------------------------------
|
| 3967 |
dpurdie |
404 |
# Function : GetBeyondCompareExePath
|
| 383 |
dpurdie |
405 |
#
|
|
|
406 |
# Description : Determine the path to the BeyondCompare executable
|
|
|
407 |
# by looking in the Windows Registry
|
|
|
408 |
#
|
|
|
409 |
# Inputs : None
|
|
|
410 |
#
|
|
|
411 |
# Returns : Path to an executable
|
|
|
412 |
#
|
|
|
413 |
|
| 3967 |
dpurdie |
414 |
sub GetBeyondCompareExePath
|
| 383 |
dpurdie |
415 |
{
|
|
|
416 |
eval "require Win32::TieRegistry"
|
|
|
417 |
or Error ("Win32::TieRegistry not available");
|
|
|
418 |
|
| 5264 |
dpurdie |
419 |
Win32::TieRegistry::import(qw( REG_SZ REG_EXPAND_SZ REG_DWORD REG_BINARY REG_MULTI_SZ KEY_READ KEY_WRITE KEY_ALL_ACCESS ));
|
|
|
420 |
|
|
|
421 |
my $userKey= Win32::TieRegistry->new("CUser", {Access=>KEY_READ(),Delimiter=>"/"})
|
| 383 |
dpurdie |
422 |
or Error( "Can't access HKEY_CURRENT_USER key: $^E" );
|
|
|
423 |
|
| 5264 |
dpurdie |
424 |
my $localKey= Win32::TieRegistry->new("LMachine", {Access=>KEY_READ(),Delimiter=>"/"})
|
| 5240 |
dpurdie |
425 |
or Error( "Can't access HKEY_LOCAL_MACHINE key: $^E" );
|
|
|
426 |
|
|
|
427 |
sub checkKeys
|
|
|
428 |
{
|
|
|
429 |
my ($userKey, $localKey, $key) = @_;
|
|
|
430 |
my ($bcKey, $DiffProg);
|
| 5264 |
dpurdie |
431 |
$bcKey = $userKey->Open( $key );
|
| 5240 |
dpurdie |
432 |
if ($bcKey && ($DiffProg = $bcKey->GetValue( 'ExePath' )) )
|
|
|
433 |
{
|
|
|
434 |
return $DiffProg;
|
|
|
435 |
}
|
| 5264 |
dpurdie |
436 |
$bcKey = $localKey->Open( $key );
|
| 5240 |
dpurdie |
437 |
if ($bcKey && ($DiffProg = $bcKey->GetValue( 'ExePath' )) )
|
|
|
438 |
{
|
|
|
439 |
return $DiffProg;
|
|
|
440 |
}
|
|
|
441 |
return undef;
|
|
|
442 |
}
|
|
|
443 |
|
| 3967 |
dpurdie |
444 |
my $bcKey;
|
| 5240 |
dpurdie |
445 |
if ($DiffProg = checkKeys( $userKey, $localKey,"Software/Scooter Software/Beyond Compare 4" ))
|
| 3967 |
dpurdie |
446 |
{
|
| 5100 |
dpurdie |
447 |
Verbose("Using BC4");
|
|
|
448 |
push @DiffArgs, '/solo';
|
|
|
449 |
}
|
| 5240 |
dpurdie |
450 |
elsif ($DiffProg = checkKeys( $userKey, $localKey,"Software/Scooter Software/Beyond Compare 3"))
|
| 5100 |
dpurdie |
451 |
{
|
| 3967 |
dpurdie |
452 |
Verbose("Using BC3");
|
|
|
453 |
push @DiffArgs, '/solo';
|
|
|
454 |
}
|
| 5240 |
dpurdie |
455 |
elsif ($DiffProg = checkKeys( $userKey, $localKey,"Software/Scooter Software/Beyond Compare"))
|
| 3967 |
dpurdie |
456 |
{
|
|
|
457 |
Verbose("Using BC2");
|
|
|
458 |
}
|
|
|
459 |
else
|
|
|
460 |
{
|
| 5100 |
dpurdie |
461 |
Error "Can't access BC2, BC3 or BC4 Keys: $^E";
|
| 3967 |
dpurdie |
462 |
}
|
| 383 |
dpurdie |
463 |
|
| 3967 |
dpurdie |
464 |
Error ("BeyondCompare program not found", "Prog: $DiffProg")
|
|
|
465 |
unless ( -x $DiffProg );
|
| 383 |
dpurdie |
466 |
}
|
|
|
467 |
|
|
|
468 |
#-------------------------------------------------------------------------------
|
| 7213 |
dpurdie |
469 |
# Function : findReleaseManagerPackage
|
|
|
470 |
#
|
|
|
471 |
# Description : Find the package information by looking up its existing in
|
|
|
472 |
# a given release.
|
|
|
473 |
#
|
|
|
474 |
# Inputs : label_name
|
|
|
475 |
# label_value
|
|
|
476 |
# rtag_id
|
|
|
477 |
# package_name
|
|
|
478 |
#
|
|
|
479 |
# Returns :
|
|
|
480 |
#
|
|
|
481 |
sub findReleaseManagerPackage
|
|
|
482 |
{
|
|
|
483 |
my ($label_name, $label_value) = @_;
|
|
|
484 |
my (@row);
|
|
|
485 |
my $found=0;
|
|
|
486 |
|
|
|
487 |
if ( !$opt_rtag_id || !$opt_package_name )
|
|
|
488 |
{
|
|
|
489 |
Error( "Must specify -rtagid and -package options when the '$label_name' tag has the value '$label_value'" );
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
if ( !$package_vcs )
|
|
|
493 |
{
|
|
|
494 |
|
|
|
495 |
connectRM(\$RM_DB) unless ($RM_DB);
|
|
|
496 |
|
|
|
497 |
# First get details from pv_id; split the package version and extension.
|
|
|
498 |
my $pkg_ext;
|
|
|
499 |
my $pkg_name;
|
|
|
500 |
if ( $opt_package_name =~ m/(.*)\.(\w*)$/ )
|
|
|
501 |
{
|
|
|
502 |
$pkg_name = $1;
|
|
|
503 |
$pkg_ext = $2;
|
|
|
504 |
}
|
|
|
505 |
else
|
|
|
506 |
{
|
|
|
507 |
$pkg_name = $opt_package_name;
|
|
|
508 |
}
|
|
|
509 |
|
|
|
510 |
my $m_sqlstr = "SELECT pv.PV_ID, pv.PKG_VERSION, release_manager.PK_RMAPI.return_vcs_tag(pv.PV_ID)".
|
|
|
511 |
" FROM RELEASE_MANAGER.RELEASE_CONTENT rc, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
|
|
|
512 |
" WHERE rc.RTAG_ID = $opt_rtag_id AND rc.PV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID AND pkg.PKG_NAME = '$pkg_name'";
|
|
|
513 |
if ( $pkg_ext )
|
|
|
514 |
{
|
|
|
515 |
$m_sqlstr .= " AND pv.V_EXT='.$pkg_ext'";
|
|
|
516 |
}
|
|
|
517 |
Verbose2( $m_sqlstr );
|
|
|
518 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
519 |
if ( defined($sth) )
|
|
|
520 |
{
|
|
|
521 |
if ( $sth->execute( ) )
|
|
|
522 |
{
|
|
|
523 |
if ( $sth->rows )
|
|
|
524 |
{
|
|
|
525 |
while ( @row = $sth->fetchrow_array )
|
|
|
526 |
{
|
|
|
527 |
my $pv_id = $row[0];
|
|
|
528 |
my $ver = $row[1];
|
|
|
529 |
my $vcs = $row[2];
|
|
|
530 |
|
|
|
531 |
Verbose( "findReleaseManagerPackage: [$opt_rtag_id, $opt_package_name] ==> [ $pv_id, $ver, $vcs]" );
|
|
|
532 |
|
|
|
533 |
$package_name = $opt_package_name;
|
|
|
534 |
$package_ver = $ver;
|
|
|
535 |
$package_vcs = $vcs;
|
|
|
536 |
|
|
|
537 |
# Most packages are released of trunk...
|
|
|
538 |
my $match = '^(SVN::.*)\/trunk::.*$';
|
|
|
539 |
if ( $package_vcs =~ m/$match/ )
|
|
|
540 |
{
|
|
|
541 |
$package_vcs_base = $1;
|
|
|
542 |
Verbose( "findReleaseManagerPackage: base on trunk ==> $package_vcs_base" );
|
|
|
543 |
}
|
|
|
544 |
else
|
|
|
545 |
{
|
|
|
546 |
# ...but some are released of branches.
|
|
|
547 |
$match = '^(SVN::.*)\/branches\/([^:]+)::.*$';
|
|
|
548 |
if ( $package_vcs =~ m/$match/ )
|
|
|
549 |
{
|
|
|
550 |
$package_vcs_base = $1;
|
|
|
551 |
$package_release_branch = $2;
|
|
|
552 |
Verbose( "findReleaseManagerPackage: base on branch $package_release_branch ==> $package_vcs_base" );
|
|
|
553 |
}
|
|
|
554 |
else
|
|
|
555 |
{
|
|
|
556 |
Error ( "Unable to determine base path from VCS: $package_vcs" );
|
|
|
557 |
}
|
|
|
558 |
}
|
|
|
559 |
$found++;
|
|
|
560 |
}
|
|
|
561 |
}
|
|
|
562 |
$sth->finish();
|
|
|
563 |
}
|
|
|
564 |
}
|
|
|
565 |
else
|
|
|
566 |
{
|
|
|
567 |
Error( "findReleaseManagerPackage:Prepare failure" );
|
|
|
568 |
}
|
|
|
569 |
|
|
|
570 |
if ( $found == 0 )
|
|
|
571 |
{
|
|
|
572 |
Error( "No package named $opt_package_name found in the release with rtag ID $opt_rtag_id" );
|
|
|
573 |
}
|
|
|
574 |
elsif ( $found > 1 )
|
|
|
575 |
{
|
|
|
576 |
Error( "Multiple packages named $opt_package_name found in the release with rtag ID $opt_rtag_id" );
|
|
|
577 |
}
|
|
|
578 |
}
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
#-------------------------------------------------------------------------------
|
|
|
582 |
# Function : translateSpecialLabelName
|
|
|
583 |
#
|
|
|
584 |
# Description : Translates the name of a label (-old or -new argument)
|
|
|
585 |
# if it is one of the special values.
|
|
|
586 |
#
|
|
|
587 |
# Inputs : label_name
|
|
|
588 |
# label_value
|
|
|
589 |
#
|
|
|
590 |
# Returns : new label_value
|
|
|
591 |
#
|
|
|
592 |
sub translateSpecialLabelName
|
|
|
593 |
{
|
|
|
594 |
my ($label_name, $label_value) = @_;
|
|
|
595 |
|
|
|
596 |
if ( $label_value eq "released" )
|
|
|
597 |
{
|
|
|
598 |
#
|
|
|
599 |
# Get the exact version released in Release Manager.
|
|
|
600 |
#
|
|
|
601 |
findReleaseManagerPackage( $label_name, $label_value );
|
|
|
602 |
return $package_vcs;
|
|
|
603 |
}
|
|
|
604 |
elsif ( $label_value eq "head" )
|
|
|
605 |
{
|
|
|
606 |
#
|
|
|
607 |
# Get the 'head' of the released branch in release manager; this is the trunk
|
|
|
608 |
# if the package is released off trunk or a branch if the package is getting
|
|
|
609 |
# released from a branch in this release area.
|
|
|
610 |
#
|
|
|
611 |
findReleaseManagerPackage( $label_name, $label_value );
|
|
|
612 |
if ( $package_release_branch )
|
|
|
613 |
{
|
|
|
614 |
return $package_vcs_base . '/branches/' . $package_release_branch;
|
|
|
615 |
}
|
|
|
616 |
else
|
|
|
617 |
{
|
|
|
618 |
return $package_vcs_base . '/trunk'
|
|
|
619 |
}
|
|
|
620 |
}
|
|
|
621 |
elsif ( $label_value =~ m/^branch=(.*)/ )
|
|
|
622 |
{
|
|
|
623 |
#
|
|
|
624 |
# Get a named branch for this package.
|
|
|
625 |
#
|
|
|
626 |
my $branch_name = $1;
|
|
|
627 |
findReleaseManagerPackage( $label_name, $label_value );
|
|
|
628 |
return $package_vcs_base . '/branches/' . $branch_name;
|
|
|
629 |
}
|
|
|
630 |
elsif ( $label_value eq "trunk" )
|
|
|
631 |
{
|
|
|
632 |
#
|
|
|
633 |
# Get the true trunk of this package.
|
|
|
634 |
#
|
|
|
635 |
findReleaseManagerPackage( $label_name, $label_value );
|
|
|
636 |
return $package_vcs_base . '/trunk';
|
|
|
637 |
}
|
|
|
638 |
|
|
|
639 |
return $label_value;
|
|
|
640 |
}
|
|
|
641 |
|
|
|
642 |
|
|
|
643 |
#-------------------------------------------------------------------------------
|
| 383 |
dpurdie |
644 |
# Function : END
|
|
|
645 |
#
|
|
|
646 |
# Description : This function will be called as the program exits
|
|
|
647 |
# It will also be called under error conditions
|
|
|
648 |
# Close down stuff we created
|
|
|
649 |
#
|
|
|
650 |
# Inputs :
|
|
|
651 |
#
|
|
|
652 |
# Returns :
|
|
|
653 |
#
|
|
|
654 |
|
|
|
655 |
sub END
|
|
|
656 |
{
|
|
|
657 |
my $exitCode = $?;
|
|
|
658 |
|
|
|
659 |
if ( $opt_debug )
|
|
|
660 |
{
|
|
|
661 |
Message ("NOT Cleaning up views");
|
|
|
662 |
return;
|
|
|
663 |
}
|
|
|
664 |
|
|
|
665 |
Message ("Cleaning up views") if @view_tags;
|
|
|
666 |
foreach my $cmds ( @view_commands )
|
|
|
667 |
{
|
|
|
668 |
JatsTool( @{$cmds}, '-delete' );
|
|
|
669 |
}
|
|
|
670 |
|
|
|
671 |
foreach my $file ( @cleanFiles )
|
|
|
672 |
{
|
|
|
673 |
unlink $file;
|
|
|
674 |
}
|
|
|
675 |
|
|
|
676 |
#
|
|
|
677 |
# The exit code may get modified by the JatsTool
|
|
|
678 |
# Preserve any error indication
|
|
|
679 |
#
|
|
|
680 |
$? = $exitCode;
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
#-------------------------------------------------------------------------------
|
|
|
684 |
# Documentation
|
|
|
685 |
#
|
|
|
686 |
|
|
|
687 |
=pod
|
|
|
688 |
|
|
|
689 |
=head1 NAME
|
|
|
690 |
|
|
|
691 |
jats_vcsdiff - Difference two views
|
|
|
692 |
|
|
|
693 |
=head1 SYNOPSIS
|
|
|
694 |
|
|
|
695 |
jats vcsdiff [options] [old_label new_label]
|
|
|
696 |
|
|
|
697 |
Options:
|
| 6085 |
dpurdie |
698 |
-help - Brief help message
|
|
|
699 |
-help -help - Detailed help message
|
|
|
700 |
-man - Full documentation
|
|
|
701 |
-check - Perform MD5SUM over both views
|
|
|
702 |
-[no]diff - Force the use of a 'diff' utility
|
|
|
703 |
-option=opt1,... - Add user options to the command line
|
| 7213 |
dpurdie |
704 |
-old=tag - Old VcsTag (or path or vcs keyword)
|
|
|
705 |
-new=tag - New VcsTag (or path or vcs keyword)
|
|
|
706 |
-rtagid=xxx - Specify the Release to process
|
|
|
707 |
-package=xxx - Specify the package to query from Release Manager
|
| 383 |
dpurdie |
708 |
|
|
|
709 |
=head1 OPTIONS
|
|
|
710 |
|
|
|
711 |
=over 8
|
|
|
712 |
|
|
|
713 |
=item B<-help>
|
|
|
714 |
|
|
|
715 |
Print a brief help message and exits.
|
|
|
716 |
|
|
|
717 |
=item B<-help -help>
|
|
|
718 |
|
|
|
719 |
Print a detailed help message with an explanation for each option.
|
|
|
720 |
|
|
|
721 |
=item B<-man>
|
|
|
722 |
|
|
|
723 |
Prints the manual page and exits.
|
|
|
724 |
|
|
|
725 |
=item B<-check>
|
|
|
726 |
|
|
|
727 |
This option controls the mode in which the program will operate.
|
|
|
728 |
|
| 2931 |
dpurdie |
729 |
If enabled the program will perform an MD5 Cheksum over the files in the first
|
| 383 |
dpurdie |
730 |
view and compare that with files in the second view.
|
|
|
731 |
|
| 2931 |
dpurdie |
732 |
This option cannot be used in conjunction with the '-diff' option'.
|
| 383 |
dpurdie |
733 |
|
| 2931 |
dpurdie |
734 |
=item B<-diff>
|
|
|
735 |
|
|
|
736 |
This option controls the mode in which the program will operate.
|
|
|
737 |
|
|
|
738 |
By default the program is Operating System dependent. It will:
|
|
|
739 |
|
|
|
740 |
=over 4
|
|
|
741 |
|
|
|
742 |
=item * Windows - Use Beyond Compare
|
|
|
743 |
|
|
|
744 |
=item * Unix - Use gdiff or diff
|
|
|
745 |
|
|
|
746 |
=back
|
|
|
747 |
|
|
|
748 |
This option will force the use of a 'diff' utility on both Windows and
|
|
|
749 |
Unix.
|
|
|
750 |
|
|
|
751 |
This option cannot be used in conjunction with the '-check' option'.
|
|
|
752 |
|
| 6085 |
dpurdie |
753 |
=item B<-option=opt1,..>
|
|
|
754 |
|
|
|
755 |
This option allows the user to modify the operation of the invoked diff program.
|
|
|
756 |
|
|
|
757 |
The options are passed directly to the diff utility invoved by the program. It is the users
|
|
|
758 |
responsibility to ensure that the options are valid.
|
|
|
759 |
|
|
|
760 |
This option may be used mutiple times, or options may be comma-seperated.
|
|
|
761 |
|
| 383 |
dpurdie |
762 |
=item B<-old=tag>
|
|
|
763 |
|
|
|
764 |
This option specifies the old, or base, VcsTag for the difference report. This
|
|
|
765 |
tag is mandatory.
|
|
|
766 |
|
|
|
767 |
The old and new tags may be provided on the command line, or via named
|
|
|
768 |
options, but not both.
|
|
|
769 |
|
|
|
770 |
The tag may be of the form dir=path to force the utility to use a local
|
|
|
771 |
view or path.
|
|
|
772 |
|
| 7213 |
dpurdie |
773 |
Additional tag values are available when generating differences against packages
|
|
|
774 |
that are released in Release Manager. In order to do this specific -rtagid and
|
|
|
775 |
-package to specify the Release Manager package version. Once
|
|
|
776 |
these are specified the following tags can be used:
|
|
|
777 |
|
|
|
778 |
=over 4
|
|
|
779 |
|
|
|
780 |
=item * released
|
|
|
781 |
|
|
|
782 |
Use the current released package version in Release Manager.
|
|
|
783 |
|
|
|
784 |
=item * head
|
|
|
785 |
|
|
|
786 |
Use the Subversion HEAD of the Release Manager release path.
|
|
|
787 |
|
|
|
788 |
=item * trunk
|
|
|
789 |
|
|
|
790 |
Use the HEAD of the Subversion trunk.
|
|
|
791 |
|
|
|
792 |
=item * branch=xxx
|
|
|
793 |
|
|
|
794 |
Use the HEAD of the Subversion branch named xxx.
|
|
|
795 |
|
|
|
796 |
=back
|
|
|
797 |
|
| 383 |
dpurdie |
798 |
=item B<-new=tag>
|
|
|
799 |
|
|
|
800 |
This option specifies the new, or current, VcsTag for the difference report. This
|
|
|
801 |
tag is mandatory.
|
|
|
802 |
|
| 7213 |
dpurdie |
803 |
Other than that, it has the same form as the -old tag described above.
|
| 383 |
dpurdie |
804 |
|
| 7213 |
dpurdie |
805 |
=item B<-rtagid=xxx>
|
| 383 |
dpurdie |
806 |
|
| 7213 |
dpurdie |
807 |
This option specified an RTAG_ID that must be determined from Release Manager.
|
|
|
808 |
|
|
|
809 |
The RTAG_ID uniquely identifies a Release. The value can be read from the URL
|
|
|
810 |
used to view the release. ie:
|
|
|
811 |
|
|
|
812 |
https://auawsaweb005/ManagerSuite/Release_Manager/dependencies.asp?rtag_id=17223
|
|
|
813 |
|
|
|
814 |
=item B<-package=xxx>
|
|
|
815 |
|
|
|
816 |
Specifies the name of the package to query from Release Manager. This can be
|
|
|
817 |
in the form of <package_name> or alternatly <package_name>.<ext> where <ext>
|
|
|
818 |
is the project-specific extension for that package. The <package_name>.<ext>
|
|
|
819 |
variant is required when there is more than one package with the same name
|
|
|
820 |
in the release given by -rtagid.
|
|
|
821 |
|
| 383 |
dpurdie |
822 |
=back
|
|
|
823 |
|
|
|
824 |
=head1 DESCRIPTION
|
|
|
825 |
|
|
|
826 |
This program has two modes of operation:
|
|
|
827 |
|
|
|
828 |
=over 4
|
|
|
829 |
|
|
|
830 |
=item 1 MD5Sum of the two views
|
|
|
831 |
|
| 2931 |
dpurdie |
832 |
=item 2 Invoke a differencing program.
|
| 383 |
dpurdie |
833 |
|
| 2931 |
dpurdie |
834 |
The program that is invoked is, by default, Operating System dependent. It will:
|
|
|
835 |
|
|
|
836 |
=over 4
|
|
|
837 |
|
|
|
838 |
=item * Windows - Use Beyond Compare to perform a visual diff.
|
|
|
839 |
|
| 383 |
dpurdie |
840 |
This mode simplifies the process of perform a code review between two
|
|
|
841 |
VCS Tags by:
|
|
|
842 |
|
|
|
843 |
=over 8
|
|
|
844 |
|
|
|
845 |
=item *
|
|
|
846 |
|
|
|
847 |
Creating a visual difference between two labels
|
|
|
848 |
|
|
|
849 |
=item *
|
|
|
850 |
|
|
|
851 |
Creating a visual difference between a label and a directory
|
|
|
852 |
|
|
|
853 |
=item *
|
|
|
854 |
|
|
|
855 |
Creating a visual difference between two directories.
|
|
|
856 |
|
|
|
857 |
=back
|
|
|
858 |
|
| 2931 |
dpurdie |
859 |
=item * Unix - Use gdiff or diff
|
|
|
860 |
|
| 383 |
dpurdie |
861 |
=back
|
|
|
862 |
|
| 2931 |
dpurdie |
863 |
=back
|
|
|
864 |
|
| 383 |
dpurdie |
865 |
The program will:
|
|
|
866 |
|
|
|
867 |
=over 8
|
|
|
868 |
|
|
|
869 |
=item *
|
|
|
870 |
|
|
|
871 |
Create two 'extract only' views based on the VCS Tags provided. The resultant
|
|
|
872 |
views are not connected to any version control system.
|
|
|
873 |
|
|
|
874 |
=item *
|
|
|
875 |
|
| 2931 |
dpurdie |
876 |
Perform the desired operation: MD5Sum or Difference.
|
| 383 |
dpurdie |
877 |
|
|
|
878 |
=item *
|
|
|
879 |
|
|
|
880 |
Delete the created directories the comparison is complete.
|
|
|
881 |
|
|
|
882 |
=back
|
|
|
883 |
|
|
|
884 |
If one of the Vcs Tags is of the form:
|
|
|
885 |
|
|
|
886 |
=over 8
|
|
|
887 |
|
| 7213 |
dpurdie |
888 |
=item * current
|
| 383 |
dpurdie |
889 |
|
| 7213 |
dpurdie |
890 |
=item * current=path
|
| 383 |
dpurdie |
891 |
|
| 7213 |
dpurdie |
892 |
=item * dir=path
|
| 383 |
dpurdie |
893 |
|
| 7213 |
dpurdie |
894 |
=back
|
| 383 |
dpurdie |
895 |
|
| 7213 |
dpurdie |
896 |
Then the tag will be treated as a directory and will be used for one side
|
|
|
897 |
of the comparison.
|
| 383 |
dpurdie |
898 |
|
| 7213 |
dpurdie |
899 |
If a Vcs Tag is of the form:
|
| 383 |
dpurdie |
900 |
|
| 7213 |
dpurdie |
901 |
=over 8
|
|
|
902 |
|
|
|
903 |
=item * released
|
|
|
904 |
|
|
|
905 |
=item * head
|
|
|
906 |
|
|
|
907 |
=item * trunk
|
|
|
908 |
|
|
|
909 |
=item * branch=xxx
|
|
|
910 |
|
| 383 |
dpurdie |
911 |
=back
|
|
|
912 |
|
| 7213 |
dpurdie |
913 |
Then the source code is checked out of source control based on a Release Manager
|
|
|
914 |
rtagid (-rtagid option) and package name (-package) option.
|
| 383 |
dpurdie |
915 |
|
|
|
916 |
Two directories views will be created. These should be deleted by this program,
|
|
|
917 |
but may remain if the command line program is terminated.
|
|
|
918 |
|
|
|
919 |
=head1 EXAMPLE
|
|
|
920 |
|
|
|
921 |
The following command will compare a Subversion view with a ClearCase view.
|
|
|
922 |
|
|
|
923 |
jats vcsdiff SVN::AUPERASVN02/COTS/crc/tags/crc_26.4.0007.cr@18587 CC::/MASS_Dev_Infra/crc::crc_26.4.0006.cr -check
|
|
|
924 |
|
|
|
925 |
The following command will compare a Subversion View with a local directory
|
|
|
926 |
|
|
|
927 |
jats vcsdiff SVN::AUPERASVN02/COTS/crc/tags/crc_26.4.0000.cr dir=crc
|
|
|
928 |
|
| 7213 |
dpurdie |
929 |
The following command will compare the release version of the ct-spa package from Pulse 2.7.0 with the current head of that package
|
|
|
930 |
|
|
|
931 |
jats vcsdiff -rtagid=38970 -package=ct-spa released head
|
|
|
932 |
|
| 383 |
dpurdie |
933 |
=cut
|
|
|
934 |
|