| 267 |
dpurdie |
1 |
########################################################################
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 267 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : jats_svnlabel.pl
|
|
|
5 |
# Module type : Jats Utility
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): Jats
|
|
|
8 |
#
|
|
|
9 |
# Description : A script to perform a number of labeling operations
|
|
|
10 |
# The script will:
|
|
|
11 |
# label a workspace - Create a tag
|
|
|
12 |
# delete a label - Deletes a tag
|
|
|
13 |
# rename a label - Renames a tag
|
|
|
14 |
# clone a label - Clones a tag
|
|
|
15 |
#
|
|
|
16 |
#......................................................................#
|
|
|
17 |
|
|
|
18 |
require 5.006_001;
|
|
|
19 |
use strict;
|
|
|
20 |
use warnings;
|
|
|
21 |
use JatsError;
|
|
|
22 |
use JatsSvn;
|
|
|
23 |
|
|
|
24 |
use Pod::Usage; # required for help support
|
|
|
25 |
use Getopt::Long;
|
| 7262 |
dpurdie |
26 |
use FileUtils;
|
| 267 |
dpurdie |
27 |
|
|
|
28 |
my $VERSION = "1.0.0"; # Update this
|
|
|
29 |
|
|
|
30 |
#
|
|
|
31 |
# Options
|
|
|
32 |
#
|
|
|
33 |
my $opt_debug = $ENV{'GBE_DEBUG'}; # Allow global debug
|
|
|
34 |
my $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbose
|
|
|
35 |
my $opt_help = 0;
|
|
|
36 |
my $opt_check;
|
|
|
37 |
my $opt_avail;
|
|
|
38 |
my $opt_label;
|
|
|
39 |
my $opt_replace;
|
|
|
40 |
my $opt_delete;
|
|
|
41 |
my $opt_rename;
|
|
|
42 |
my $opt_clone;
|
|
|
43 |
my $opt_comment;
|
|
|
44 |
my $opt_workspace;
|
|
|
45 |
my $opt_packagebase;
|
|
|
46 |
my $opt_branch;
|
|
|
47 |
my $opt_list;
|
| 385 |
dpurdie |
48 |
my $opt_author;
|
|
|
49 |
my $opt_date;
|
|
|
50 |
my $opt_complexTag;
|
| 1403 |
dpurdie |
51 |
my $opt_noUpdateCheck;
|
| 267 |
dpurdie |
52 |
|
|
|
53 |
#
|
|
|
54 |
# Globals
|
|
|
55 |
#
|
|
|
56 |
my $session; # Subversion Session
|
|
|
57 |
my $label; # User argument - one label
|
|
|
58 |
my $src_label; # User specified source label
|
|
|
59 |
my $pkg_root; # Root of corresponding package
|
|
|
60 |
my $opr_done; # User has done something
|
|
|
61 |
|
|
|
62 |
#-------------------------------------------------------------------------------
|
|
|
63 |
# Function : Mainline Entry Point
|
|
|
64 |
#
|
|
|
65 |
# Description :
|
|
|
66 |
#
|
|
|
67 |
# Inputs :
|
|
|
68 |
#
|
|
|
69 |
my $result = GetOptions (
|
| 385 |
dpurdie |
70 |
'help:+' => \$opt_help, # flag, multiple use allowed
|
|
|
71 |
'manual:3' => \$opt_help, # flag
|
|
|
72 |
'verbose:+' => \$opt_verbose, # flag, multiple use allowed
|
|
|
73 |
'check' => \$opt_check, # Flag
|
|
|
74 |
'available' => \$opt_avail, # Flag
|
|
|
75 |
'label' => \$opt_label, # Flag
|
|
|
76 |
'auto' => \$opt_label, # Same as -label
|
|
|
77 |
'delete' => \$opt_delete, # Flag
|
|
|
78 |
'replace!' => \$opt_replace, # Flag
|
|
|
79 |
'rename=s' => \$opt_rename, # String
|
|
|
80 |
'clone=s' => \$opt_clone, # String
|
|
|
81 |
'comment=s' => \$opt_comment, # String
|
|
|
82 |
'workspace=s' => \$opt_workspace, # String
|
|
|
83 |
'packagebase=s' => \$opt_packagebase, # String
|
|
|
84 |
'branch' => \$opt_branch, # Flag
|
|
|
85 |
'list' => \$opt_list, # Flag
|
|
|
86 |
'author=s' => \$opt_author, # String
|
|
|
87 |
'date=s' => \$opt_date, # String
|
| 1329 |
dpurdie |
88 |
'allowlocalmods!' => \$opt_complexTag, # [no]aaaaaa
|
| 1403 |
dpurdie |
89 |
'allowRepoChanges!' => \$opt_noUpdateCheck, # [no]aaaaaa
|
|
|
90 |
|
| 267 |
dpurdie |
91 |
);
|
|
|
92 |
|
|
|
93 |
#
|
|
|
94 |
# UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
|
|
|
95 |
#
|
|
|
96 |
|
|
|
97 |
#
|
|
|
98 |
# Process help and manual options
|
|
|
99 |
#
|
|
|
100 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
|
|
|
101 |
pod2usage(-verbose => 1) if ($opt_help == 2 );
|
|
|
102 |
pod2usage(-verbose => 2) if ($opt_help > 2);
|
|
|
103 |
|
|
|
104 |
#
|
|
|
105 |
# Configure the error reporting process now that we have the user options
|
|
|
106 |
#
|
| 7262 |
dpurdie |
107 |
InitFileUtils();
|
| 267 |
dpurdie |
108 |
ErrorConfig( 'name' =>'SVNLABEL',
|
|
|
109 |
'verbose' => $opt_verbose,
|
|
|
110 |
);
|
|
|
111 |
|
|
|
112 |
#
|
|
|
113 |
# Validate user options
|
|
|
114 |
# Need one command line argument
|
|
|
115 |
#
|
|
|
116 |
Error ("No labels provided") if ( $#ARGV < 0 && !$opt_list );
|
|
|
117 |
Error ("Too many labels provided") if ( $#ARGV > 0);
|
| 375 |
dpurdie |
118 |
Error ("Conflicting options. Clone and Label") if ( $opt_clone && $opt_label );
|
|
|
119 |
Error ("Conflicting options. Rename and Label") if ( $opt_rename && $opt_label );
|
| 267 |
dpurdie |
120 |
$label = $ARGV[0];
|
|
|
121 |
|
|
|
122 |
#
|
| 1403 |
dpurdie |
123 |
# Process user label specification
|
|
|
124 |
# May in the form SVN::Path::Tag
|
|
|
125 |
#
|
|
|
126 |
$label =~ s~^SVN::~~ if $label;
|
|
|
127 |
if ( $label =~ m~(.+)::(.+)~ )
|
|
|
128 |
{
|
|
|
129 |
my $sourcePath = $1;
|
|
|
130 |
my $tag = $2;
|
|
|
131 |
|
|
|
132 |
#
|
|
|
133 |
# Sanity test of sourcePath
|
|
|
134 |
#
|
|
|
135 |
Error ("Invalid use of a peg: $label")
|
|
|
136 |
if ( $sourcePath =~ m~\@\d+$~ );
|
|
|
137 |
|
|
|
138 |
#
|
|
|
139 |
# Remove anything after a ttb (truck, tags, branch) element
|
|
|
140 |
# This will be the root of the package within the repo
|
|
|
141 |
#
|
|
|
142 |
if ( $sourcePath =~ m~(.*)/((tags|branches|trunk)(/|$)(.*))~ )
|
|
|
143 |
{
|
|
|
144 |
Error ("Source Path has insufficient items")
|
|
|
145 |
if ( $1 eq '' );
|
|
|
146 |
|
|
|
147 |
Error ("SourcePath contains invalid items after '$3': '$5'")
|
|
|
148 |
if ( ($3 eq 'tags' || $3 eq 'trunk') && $5 ne '' );
|
|
|
149 |
|
|
|
150 |
Error ("SourcePath must contain items after 'branches'")
|
|
|
151 |
if ( $3 eq 'branches' && $5 eq '');
|
|
|
152 |
|
|
|
153 |
$label = $1 . '/tags/' . $tag;
|
|
|
154 |
}
|
|
|
155 |
else
|
|
|
156 |
{
|
|
|
157 |
Error ("Source Path does not contain tags or trunk or branches component");
|
|
|
158 |
}
|
|
|
159 |
Verbose ("Tag: $label");
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
#
|
| 267 |
dpurdie |
163 |
# Locate package and workspace roots
|
|
|
164 |
#
|
|
|
165 |
LocateRoots ();
|
|
|
166 |
|
|
|
167 |
################################################################################
|
|
|
168 |
#
|
|
|
169 |
# Validate one or more labels
|
|
|
170 |
# Intended to be used within scripts for testing
|
|
|
171 |
#
|
|
|
172 |
if ( $opt_check )
|
|
|
173 |
{
|
|
|
174 |
$session->SvnValidateTarget
|
|
|
175 |
(
|
|
|
176 |
'target' => make_src_label ($pkg_root, $label),
|
| 341 |
dpurdie |
177 |
'cmd' => 'Validate Existence',
|
| 267 |
dpurdie |
178 |
'require' => 1,
|
|
|
179 |
);
|
|
|
180 |
$opr_done = 1;
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
if ( $opt_avail )
|
|
|
184 |
{
|
|
|
185 |
$session->SvnValidateTarget
|
|
|
186 |
(
|
|
|
187 |
'target' => make_src_label ($pkg_root, $label),
|
|
|
188 |
'cmd' => 'Validate Availablility',
|
|
|
189 |
'available' => 1,
|
|
|
190 |
);
|
|
|
191 |
$opr_done = 1;
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
################################################################################
|
|
|
195 |
#
|
|
|
196 |
# List labels
|
|
|
197 |
#
|
|
|
198 |
if ( $opt_list )
|
|
|
199 |
{
|
|
|
200 |
my $pList = $session->ListLabels (make_label ($pkg_root, '') );
|
|
|
201 |
|
|
|
202 |
#
|
| 379 |
dpurdie |
203 |
# Remove trailing / on all directory names
|
| 267 |
dpurdie |
204 |
#
|
|
|
205 |
chop @{$pList};
|
|
|
206 |
|
|
|
207 |
my $type = $opt_branch ? 'branch' : 'tag';
|
|
|
208 |
Information ( "Package: " . $session->Path,
|
|
|
209 |
,map ( $type . ': ' . $_, @{$pList})
|
|
|
210 |
);
|
|
|
211 |
$opr_done = 1;
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
################################################################################
|
|
|
216 |
#
|
|
|
217 |
# Rename a label
|
|
|
218 |
# This has implications for stuff that is stored within release manager
|
|
|
219 |
#
|
|
|
220 |
# Renaming a pegged version is problematical
|
|
|
221 |
# At the moment we do a copy ( rename, without the delete)
|
|
|
222 |
#
|
|
|
223 |
if ( $opt_rename )
|
|
|
224 |
{
|
|
|
225 |
#
|
|
|
226 |
# Create old and new paths for the full label
|
|
|
227 |
#
|
|
|
228 |
my $ws_label_old = make_src_label ($pkg_root, $label);
|
| 1403 |
dpurdie |
229 |
my $label_new = SvnIsaSimpleLabel($opt_rename);
|
|
|
230 |
my $ws_label_new = make_label ($pkg_root , $label_new);
|
| 267 |
dpurdie |
231 |
|
|
|
232 |
$session->SvnRename (
|
|
|
233 |
'old' => $ws_label_old,
|
|
|
234 |
'new' => $ws_label_new,
|
|
|
235 |
'comment' => $opt_comment ? $opt_comment : 'Renamed by Jats Svnlabel',
|
|
|
236 |
'replace' => $opt_replace ? 1 : 0,
|
|
|
237 |
);
|
|
|
238 |
|
|
|
239 |
Message ("Repository Ref: " . $session->RmRef);
|
| 1403 |
dpurdie |
240 |
Message ("Vcs Tag : " . $session->SvnTag);
|
| 385 |
dpurdie |
241 |
updateProperties();
|
| 267 |
dpurdie |
242 |
$opr_done = 1;
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
################################################################################
|
|
|
246 |
#
|
|
|
247 |
# The Svn Label need a package root
|
|
|
248 |
# If we are in a WorkSpace, then we can determine the package root
|
|
|
249 |
#
|
|
|
250 |
if ( $opt_label )
|
|
|
251 |
{
|
|
|
252 |
#
|
|
|
253 |
# Can now create a nice pathname for the label
|
|
|
254 |
#
|
| 1403 |
dpurdie |
255 |
$label = SvnIsaSimpleLabel ($label);
|
|
|
256 |
my $ws_label = make_label( $pkg_root, $label );
|
| 267 |
dpurdie |
257 |
|
|
|
258 |
#
|
|
|
259 |
# Don't let the user create a tag from a workspace that is
|
|
|
260 |
# also created from a tag.
|
|
|
261 |
#
|
|
|
262 |
# They should be using a branch.
|
|
|
263 |
# Can't stop them - but can make it difficult.
|
|
|
264 |
#
|
|
|
265 |
Error ("Cannot tag a Workspace based on a 'tag'",
|
|
|
266 |
"You should be working in a branch",
|
|
|
267 |
"WorkSpace: $session->{WSURL}" )
|
| 379 |
dpurdie |
268 |
if ( !$opt_branch && (($session->WsType) eq 'tags') );
|
| 267 |
dpurdie |
269 |
|
| 1329 |
dpurdie |
270 |
#
|
|
|
271 |
# The label operation *should* be a server side operation only
|
| 1403 |
dpurdie |
272 |
# If the user has commited changes, but not yet updated the local
|
| 1329 |
dpurdie |
273 |
# workspace, then subversion will do a client side copy
|
|
|
274 |
# This is not good.
|
|
|
275 |
# If the 'tags' area is not writable then we get a cryptic message
|
|
|
276 |
# If the 'tags' area is writable then we commit the changes twice
|
|
|
277 |
#
|
|
|
278 |
# Solution - ensure that the Workspace is upto date
|
|
|
279 |
# This is done within SvnCopyWs
|
| 7272 |
dpurdie |
280 |
#
|
|
|
281 |
# If the workspace has 'mixed revisions' then files will be added/removed/copied
|
|
|
282 |
# directly to the 'tags' and will not be present on the branch. This is not good.
|
|
|
283 |
#
|
|
|
284 |
# Solution - Ensure that the Workspace is not mixed
|
|
|
285 |
# This is done within SvnCopyWs
|
| 1329 |
dpurdie |
286 |
#
|
| 267 |
dpurdie |
287 |
$session->SvnCopyWs (
|
|
|
288 |
target => $ws_label,
|
| 385 |
dpurdie |
289 |
'allowLocalMods' => $opt_complexTag,
|
| 1403 |
dpurdie |
290 |
'noupdatecheck' => $opt_noUpdateCheck,
|
| 267 |
dpurdie |
291 |
'noswitch' => 1,
|
|
|
292 |
'replace' => $opt_replace ? 1 : 0,
|
| 5073 |
dpurdie |
293 |
'comment' => $opt_comment ? $opt_comment : ('Created by Jats Svnlabel:' . $label),
|
| 267 |
dpurdie |
294 |
);
|
|
|
295 |
|
|
|
296 |
Message ("Repository Ref: " . $session->RmRef);
|
| 1403 |
dpurdie |
297 |
Message ("Vcs Tag : " . $session->SvnTag);
|
| 385 |
dpurdie |
298 |
updateProperties();
|
| 267 |
dpurdie |
299 |
$opr_done = 1;
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
################################################################################
|
|
|
303 |
#
|
|
|
304 |
# Delete a label
|
|
|
305 |
# Can't really delete one, but we can remove it from the head
|
|
|
306 |
# If SVN ever gets an 'obliterate' command then prehaps we could use it
|
|
|
307 |
#
|
|
|
308 |
if ( $opt_delete )
|
|
|
309 |
{
|
|
|
310 |
#
|
|
|
311 |
# Calculate the label name to delete
|
|
|
312 |
#
|
|
|
313 |
my $ws_label = make_src_label( $pkg_root, $label );
|
|
|
314 |
$session->SvnDelete ( 'target' => $ws_label,
|
|
|
315 |
'comment' => $opt_comment ? $opt_comment : 'Deleted by Jats Svnlabel',
|
| 1329 |
dpurdie |
316 |
'noerror' => 0 );
|
| 267 |
dpurdie |
317 |
$opr_done = 1;
|
|
|
318 |
}
|
|
|
319 |
|
|
|
320 |
################################################################################
|
|
|
321 |
#
|
|
|
322 |
# Clone a label
|
|
|
323 |
# Essentially a copy of a tag
|
|
|
324 |
#
|
|
|
325 |
#
|
|
|
326 |
if ( $opt_clone )
|
|
|
327 |
{
|
|
|
328 |
#
|
|
|
329 |
# Create old and new paths for the full label
|
|
|
330 |
#
|
|
|
331 |
my $ws_label_old = make_src_label ($pkg_root, $label);
|
| 1403 |
dpurdie |
332 |
my $new_label = SvnIsaSimpleLabel($opt_clone);
|
|
|
333 |
my $ws_label_new = make_label ($pkg_root , $new_label);
|
|
|
334 |
#
|
|
|
335 |
# Backtrack label so that we clone the tag source, not the tag
|
|
|
336 |
#
|
|
|
337 |
if ( $ws_label_old =~ m~/tags/~ )
|
|
|
338 |
{
|
|
|
339 |
my $tag = $label;
|
|
|
340 |
$tag = 'tags/' . $tag unless ( $tag =~ m~^tags/~ );
|
|
|
341 |
$ws_label_old = $session->backTrackSvnLabel( $tag, savedevbranch => 1);
|
|
|
342 |
Verbose2 ("Tag back tracked to: $ws_label_old");
|
|
|
343 |
$ws_label_old = $pkg_root . '/' . $ws_label_old;
|
|
|
344 |
}
|
|
|
345 |
|
| 267 |
dpurdie |
346 |
$session->SvnCopy (
|
|
|
347 |
'old' => $ws_label_old,
|
|
|
348 |
'new' => $ws_label_new,
|
| 1403 |
dpurdie |
349 |
'comment' => $opt_comment ? $opt_comment : 'Copied by Jats Svnlabel Clone',
|
| 267 |
dpurdie |
350 |
'replace' => $opt_replace ? 1 : 0,
|
|
|
351 |
);
|
|
|
352 |
Message ("Repository Ref: " . $session->RmRef);
|
| 1403 |
dpurdie |
353 |
Message ("Vcs Tag : " . $session->SvnTag);
|
| 385 |
dpurdie |
354 |
updateProperties();
|
| 267 |
dpurdie |
355 |
$opr_done = 1;
|
|
|
356 |
}
|
|
|
357 |
|
|
|
358 |
|
|
|
359 |
Error ("No valid operations specified. Try -h") unless ( $opr_done );
|
|
|
360 |
exit 0;
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
#-------------------------------------------------------------------------------
|
|
|
364 |
# Function : make_label
|
|
|
365 |
#
|
|
|
366 |
# Description : Create a label ( tag or branch )
|
|
|
367 |
#
|
|
|
368 |
# Inputs : $base
|
|
|
369 |
# $name
|
|
|
370 |
#
|
|
|
371 |
# Returns : Full label
|
|
|
372 |
#
|
|
|
373 |
sub make_label
|
|
|
374 |
{
|
|
|
375 |
my ($base, $name) = @_;
|
|
|
376 |
my $join = $opt_branch ? '/branches/' : '/tags/';
|
|
|
377 |
return $base . $join . $name;
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
#-------------------------------------------------------------------------------
|
|
|
381 |
# Function : make_src_label
|
|
|
382 |
#
|
|
|
383 |
# Description : Create a source label ( tag or branch )
|
|
|
384 |
#
|
| 1403 |
dpurdie |
385 |
# Calculation may be bypassed if the global $src_label
|
| 379 |
dpurdie |
386 |
# is specified.
|
|
|
387 |
#
|
| 267 |
dpurdie |
388 |
# Inputs : $base
|
| 379 |
dpurdie |
389 |
# $name - May contain hint
|
|
|
390 |
# Prefixed with 'tags/' or 'branches/'
|
| 267 |
dpurdie |
391 |
#
|
|
|
392 |
# Returns : Full label
|
|
|
393 |
#
|
|
|
394 |
sub make_src_label
|
|
|
395 |
{
|
|
|
396 |
return $src_label if ( $src_label );
|
|
|
397 |
my ($base, $name) = @_;
|
| 379 |
dpurdie |
398 |
my $result = $name;
|
| 1329 |
dpurdie |
399 |
unless ( $name =~ m~(^branches/)|(^tags)|(^trunk\@)~ )
|
| 379 |
dpurdie |
400 |
{
|
|
|
401 |
$result = ($opt_branch ? 'branches/' : 'tags/' ) . $name;
|
|
|
402 |
}
|
|
|
403 |
return $base . '/' . $result;
|
| 267 |
dpurdie |
404 |
}
|
|
|
405 |
|
|
|
406 |
|
|
|
407 |
#-------------------------------------------------------------------------------
|
|
|
408 |
# Function : LocateRoots
|
|
|
409 |
#
|
|
|
410 |
# Description : Determine workspace root and associated
|
|
|
411 |
# package root
|
|
|
412 |
#
|
|
|
413 |
# Uses several hint to figure it out
|
|
|
414 |
# The default is the package in the current directory
|
|
|
415 |
# -workspace - may address a workspace
|
|
|
416 |
# -packagebase - may specify a package base
|
|
|
417 |
# Does not work with -label
|
|
|
418 |
# as we need a workspace
|
|
|
419 |
#
|
|
|
420 |
#
|
|
|
421 |
# Inputs : None - uses globals
|
|
|
422 |
#
|
|
|
423 |
# Returns : Setup global variables
|
|
|
424 |
#
|
|
|
425 |
sub LocateRoots
|
|
|
426 |
{
|
|
|
427 |
#
|
|
|
428 |
# Use current directory as the workspace unless the user
|
|
|
429 |
# has specified a different one
|
|
|
430 |
#
|
|
|
431 |
$session = NewSessionByWS( $opt_workspace || '.', $opt_workspace ? 0 : 1 );
|
|
|
432 |
|
|
|
433 |
Verbose ("Determine the current workspace root" );
|
|
|
434 |
my $ws_root = $session->SvnLocateWsRoot(1) || '';
|
|
|
435 |
|
|
|
436 |
#
|
|
|
437 |
# Only need a WS root for the label operation
|
|
|
438 |
# Every thing else can live without it
|
|
|
439 |
#
|
|
|
440 |
Error ("Cannot determine source Workspace") if ( $opt_label && !$ws_root );
|
|
|
441 |
|
|
|
442 |
#
|
| 7262 |
dpurdie |
443 |
# If operation is 'label', then we have a Workspace
|
|
|
444 |
# Ensure that we are in the 'root' of the workspace - otherwise we will get cryptic messages
|
|
|
445 |
#
|
|
|
446 |
if ( $opt_label && $ws_root && !$opt_workspace) {
|
|
|
447 |
my $pathToRoot = RelPath($ws_root);
|
|
|
448 |
if ( $pathToRoot =~ m~^..~) {
|
|
|
449 |
Warning("Current directory is the not the workspace root",
|
|
|
450 |
"The 'svn update' command will not update the entire workspace");
|
|
|
451 |
}
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
#
|
| 267 |
dpurdie |
455 |
# Calculate the package base
|
|
|
456 |
# - User specified
|
|
|
457 |
# - Extacted from label
|
|
|
458 |
# - Extracted from WorkSpace
|
|
|
459 |
# - User specified Workspace
|
|
|
460 |
# - Current directory
|
|
|
461 |
#
|
|
|
462 |
if ( $opt_packagebase )
|
|
|
463 |
{
|
|
|
464 |
#
|
|
|
465 |
# User has given us the package base
|
|
|
466 |
#
|
| 361 |
dpurdie |
467 |
$session = NewSessionByUrl ( $opt_packagebase, 0, $session );
|
| 267 |
dpurdie |
468 |
$session->SvnValidatePackageRoot();
|
|
|
469 |
}
|
| 375 |
dpurdie |
470 |
elsif ( (!$opt_label ) && $label && $label =~ m~(.+)(/(tags|branches|trunk)(/|@)(.+))~ )
|
| 267 |
dpurdie |
471 |
{
|
|
|
472 |
#
|
| 375 |
dpurdie |
473 |
# Attempt to extract it from the label, but only if we are not
|
|
|
474 |
# labeling a sandbox.
|
| 267 |
dpurdie |
475 |
# Remove it from the label
|
|
|
476 |
#
|
|
|
477 |
$src_label = $2;
|
|
|
478 |
$label = $5;
|
| 361 |
dpurdie |
479 |
$session = NewSessionByUrl ( $1, 0, $session );
|
| 267 |
dpurdie |
480 |
$session->SvnValidatePackageRoot();
|
|
|
481 |
$src_label = $session->Full . $src_label;
|
|
|
482 |
}
|
|
|
483 |
elsif ( $ws_root )
|
|
|
484 |
{
|
|
|
485 |
# $s2 = $session;
|
|
|
486 |
}
|
|
|
487 |
else
|
|
|
488 |
{
|
|
|
489 |
Error ("Cannot determine the Package Base");
|
|
|
490 |
}
|
|
|
491 |
$pkg_root = $session->Full;
|
|
|
492 |
|
|
|
493 |
#
|
|
|
494 |
# Everything needs a $pkg_root
|
|
|
495 |
#
|
|
|
496 |
Error ("Cannot determine Package Base") unless ( $pkg_root );
|
|
|
497 |
|
|
|
498 |
Verbose ("Workspace root: $ws_root");
|
|
|
499 |
Verbose ("Package root : $pkg_root");
|
|
|
500 |
#DebugDumpData ("Session", $session );
|
|
|
501 |
}
|
|
|
502 |
|
|
|
503 |
#-------------------------------------------------------------------------------
|
| 385 |
dpurdie |
504 |
# Function : updateProperties
|
|
|
505 |
#
|
|
|
506 |
# Description : Update the properties, if present
|
|
|
507 |
#
|
|
|
508 |
# Inputs : Globals
|
|
|
509 |
#
|
|
|
510 |
# Returns : Nothing
|
|
|
511 |
#
|
|
|
512 |
sub updateProperties
|
|
|
513 |
{
|
|
|
514 |
$session->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
|
|
|
515 |
$session->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
#-------------------------------------------------------------------------------
|
| 267 |
dpurdie |
519 |
# Documentation
|
|
|
520 |
#
|
|
|
521 |
|
|
|
522 |
=pod
|
|
|
523 |
|
| 361 |
dpurdie |
524 |
=for htmltoc GENERAL::Subversion::
|
|
|
525 |
|
| 267 |
dpurdie |
526 |
=head1 NAME
|
|
|
527 |
|
|
|
528 |
jats_svnlabel - Subversion label operations
|
|
|
529 |
|
|
|
530 |
=head1 SYNOPSIS
|
|
|
531 |
|
| 361 |
dpurdie |
532 |
jats svnlabel [options] C<label>
|
| 267 |
dpurdie |
533 |
|
|
|
534 |
Options:
|
|
|
535 |
-help - brief help message
|
|
|
536 |
-help -help - Detailed help message
|
|
|
537 |
-man - Full documentation
|
| 385 |
dpurdie |
538 |
-available - Check for label availability
|
| 267 |
dpurdie |
539 |
-check - Check for label existence
|
|
|
540 |
-clone=xxx - Clone a package version
|
|
|
541 |
-delete - Delete label from the repository
|
|
|
542 |
-label - Labels a Package
|
| 383 |
dpurdie |
543 |
-auto - Same as -label
|
| 385 |
dpurdie |
544 |
-list - List labels in a package
|
| 267 |
dpurdie |
545 |
-rename=xxx - Rename a label
|
| 385 |
dpurdie |
546 |
|
| 267 |
dpurdie |
547 |
Modifiers
|
|
|
548 |
-branch - Use branches, not tags
|
|
|
549 |
-replace - Replace existing labels. Use with -label
|
|
|
550 |
-comment=text - Comment to add to repository operations
|
|
|
551 |
-workspace=path - Path to a workspace to label
|
| 385 |
dpurdie |
552 |
-packagebase=path - Repository path to package base
|
|
|
553 |
-author=name - Force author of changes
|
|
|
554 |
-date=dateString - Force date of changes
|
|
|
555 |
-allowLocalMods - Allow complex tagging
|
| 1403 |
dpurdie |
556 |
-allowRepoChanges - Supress check for an up to date workspace
|
| 267 |
dpurdie |
557 |
|
|
|
558 |
=head1 OPTIONS
|
|
|
559 |
|
|
|
560 |
=over 8
|
|
|
561 |
|
|
|
562 |
=item B<-help>
|
|
|
563 |
|
|
|
564 |
Print a brief help message and exits.
|
|
|
565 |
|
|
|
566 |
=item B<-help -help>
|
|
|
567 |
|
|
|
568 |
Print a detailed help message with an explanation for each option.
|
|
|
569 |
|
|
|
570 |
=item B<-man>
|
|
|
571 |
|
|
|
572 |
Prints the manual page and exits.
|
|
|
573 |
|
|
|
574 |
=item B<-clone=xxx>
|
|
|
575 |
|
| 385 |
dpurdie |
576 |
This option will copy a labeled version of a package to a new label.
|
| 267 |
dpurdie |
577 |
|
|
|
578 |
=item B<-delete>
|
|
|
579 |
|
|
|
580 |
This option will delete the specified label from the repository
|
|
|
581 |
|
|
|
582 |
=item B<-available>
|
|
|
583 |
|
| 385 |
dpurdie |
584 |
This option will check for the labels non-existence. An error will be reported
|
| 267 |
dpurdie |
585 |
if the label exists.
|
|
|
586 |
|
|
|
587 |
=item B<-check>
|
|
|
588 |
|
| 385 |
dpurdie |
589 |
This option will check for the labels existence. An error will be reported
|
| 267 |
dpurdie |
590 |
if the label does not exist.
|
|
|
591 |
|
|
|
592 |
=item B<-label>
|
|
|
593 |
|
|
|
594 |
This option will label a workspace.
|
|
|
595 |
|
|
|
596 |
The -replace option may be used to force labels to be moved.
|
|
|
597 |
|
| 383 |
dpurdie |
598 |
=item B<-auto>
|
|
|
599 |
|
|
|
600 |
This option is the same as '-label'. It is provided for compatibility with other
|
|
|
601 |
labeling tools.
|
|
|
602 |
|
| 267 |
dpurdie |
603 |
=item B<-rename=xxx>
|
|
|
604 |
|
|
|
605 |
This option will rename a label. The new name of the label is provided as the
|
|
|
606 |
argument after the option. If any further operation are to be performed the
|
|
|
607 |
new label name will be used.
|
|
|
608 |
|
|
|
609 |
=item B<-list>
|
|
|
610 |
|
| 385 |
dpurdie |
611 |
This option will case all labels for the related package to be shown. The
|
| 267 |
dpurdie |
612 |
command assumes that the repository is in a trunk/tags/branches format.
|
|
|
613 |
|
|
|
614 |
By default tags are shown. Branches may be shown with the -branches option.
|
|
|
615 |
|
|
|
616 |
=item B<-replace>
|
|
|
617 |
|
|
|
618 |
This option may be used with the -label command to allow existing labels to
|
|
|
619 |
be replaced.
|
|
|
620 |
|
|
|
621 |
=item B<-comment=text>
|
|
|
622 |
|
|
|
623 |
This option provides text to be used to document the operation in the log.
|
|
|
624 |
|
|
|
625 |
If none is provided, then the utility will use a simple comment of its own.
|
|
|
626 |
|
|
|
627 |
=item B<-workspace=path>
|
|
|
628 |
|
|
|
629 |
This option can be used to specify the path to a workspace to be labeled.
|
|
|
630 |
|
|
|
631 |
If not provided then the utility will use the current directory to determine
|
|
|
632 |
the root of the workspace.
|
|
|
633 |
|
| 2049 |
dpurdie |
634 |
=item B<-packagebase=path>
|
| 267 |
dpurdie |
635 |
|
|
|
636 |
This option can be used to specify the path to a package within a repository.
|
|
|
637 |
|
|
|
638 |
If the 'label' contains a package base, then it will be extracted and used.
|
|
|
639 |
|
|
|
640 |
If not provided and the utility is within a workspace, then the package base will
|
|
|
641 |
be taken to be that of the package in the workspace.
|
|
|
642 |
|
|
|
643 |
=item B<-branch>
|
|
|
644 |
|
|
|
645 |
This option modifies all commands. It causes the labeling operations to be
|
| 1403 |
dpurdie |
646 |
performed on a packages 'branches' area instead of the default 'tags'
|
| 267 |
dpurdie |
647 |
area.
|
|
|
648 |
|
| 385 |
dpurdie |
649 |
=item -author=name
|
|
|
650 |
|
|
|
651 |
This option will force the author of changes as recorded in the repository.
|
|
|
652 |
The repository must be configured to allow such changes.
|
|
|
653 |
|
|
|
654 |
This option may not work for non-admin users.
|
|
|
655 |
|
|
|
656 |
=item -date=dateString
|
|
|
657 |
|
|
|
658 |
This option will force the date of the changes as recorded in the repository.
|
|
|
659 |
The repository must be configured to allow such changes.
|
|
|
660 |
The dateString is in a restricted ISO 8601 format: ie 2009-02-12T00:44:04.921324Z
|
|
|
661 |
|
|
|
662 |
This option may not work for non-admin users.
|
|
|
663 |
|
|
|
664 |
=item -allowLocalMods
|
|
|
665 |
|
|
|
666 |
This option modifies the checking that is done when the workspace is labeled.
|
|
|
667 |
The default is to 'not' allow local modifications. All modifications must be
|
|
|
668 |
committed before the label is created.
|
|
|
669 |
|
|
|
670 |
If local modifications are allowed, then the utility will warn about local
|
|
|
671 |
modifications, but the labelling process will continue. This allows
|
|
|
672 |
for 'complex' tagging. The modified files will be transferred to the repository
|
|
|
673 |
and will form a part of the tag.
|
|
|
674 |
|
|
|
675 |
This mode of operation should NOT be used for normal labeling. It is useful for
|
|
|
676 |
the preservation of 'Mixed Workspaces'.
|
|
|
677 |
|
| 1403 |
dpurdie |
678 |
=item -allowRepoChanges
|
|
|
679 |
|
|
|
680 |
This option modifies the checking that is done when the workspace is labeled.
|
|
|
681 |
The default is to 'not' allow changes between the Workspace and the Repository.
|
|
|
682 |
Normally the Workspace must be up to date with respect to the head of the
|
|
|
683 |
development branch.
|
|
|
684 |
|
|
|
685 |
If Repository Changes are allowed, then the utility will warn about changes, but
|
|
|
686 |
the labelling process will continue. This allows Workspaces that have been
|
|
|
687 |
pegged to old versions to be tagged.
|
|
|
688 |
|
|
|
689 |
The Repository may still reject the tag if the workspace has been modified in
|
|
|
690 |
a manner that would result in a client-side copy. This is intentional.
|
|
|
691 |
|
| 267 |
dpurdie |
692 |
=back
|
|
|
693 |
|
|
|
694 |
=head1 DESCRIPTION
|
|
|
695 |
|
|
|
696 |
This program provides a number of useful Subversion labeling operations. These
|
|
|
697 |
are:
|
|
|
698 |
|
|
|
699 |
=over 8
|
|
|
700 |
|
| 361 |
dpurdie |
701 |
=item *
|
| 267 |
dpurdie |
702 |
|
| 385 |
dpurdie |
703 |
check - check existence of a label
|
| 267 |
dpurdie |
704 |
|
| 361 |
dpurdie |
705 |
=item *
|
| 267 |
dpurdie |
706 |
|
| 385 |
dpurdie |
707 |
available - check non-existence of a label
|
| 267 |
dpurdie |
708 |
|
| 361 |
dpurdie |
709 |
=item *
|
| 267 |
dpurdie |
710 |
|
| 375 |
dpurdie |
711 |
list - list the labels on a package
|
| 267 |
dpurdie |
712 |
|
| 361 |
dpurdie |
713 |
=item *
|
| 267 |
dpurdie |
714 |
|
| 361 |
dpurdie |
715 |
rename - rename a label
|
|
|
716 |
|
|
|
717 |
=item *
|
|
|
718 |
|
|
|
719 |
label - label a workspace
|
|
|
720 |
|
|
|
721 |
=item *
|
|
|
722 |
|
|
|
723 |
delete - delete a label
|
|
|
724 |
|
|
|
725 |
=item *
|
|
|
726 |
|
|
|
727 |
clone - duplicate a label
|
|
|
728 |
|
| 267 |
dpurdie |
729 |
=back
|
|
|
730 |
|
|
|
731 |
The various operations may be mixed in the one command. The order of the
|
|
|
732 |
operations is: check, available, list, rename, label, delete and clone
|
|
|
733 |
|
|
|
734 |
=head2 LABEL format
|
|
|
735 |
|
|
|
736 |
A 'label' as used by JATS within a Subversion repository, may have four elements.
|
|
|
737 |
These are:
|
|
|
738 |
|
|
|
739 |
=over
|
|
|
740 |
|
|
|
741 |
=item * Package Path
|
|
|
742 |
|
| 385 |
dpurdie |
743 |
Any text proceeding a / will be taken to be a package path. This identifies the
|
| 267 |
dpurdie |
744 |
root of the package within the repository.
|
|
|
745 |
|
|
|
746 |
=item * Label Type
|
|
|
747 |
|
|
|
748 |
This will be one of 'trunk', 'branches' or 'tags'.
|
|
|
749 |
|
|
|
750 |
Normally labels are placed on the 'tags' subdirectory of a package.
|
|
|
751 |
|
|
|
752 |
=item * Simple Label
|
|
|
753 |
|
| 341 |
dpurdie |
754 |
The label tag. It can only contain Alphanumerics and the characters :-_.
|
| 267 |
dpurdie |
755 |
In practice this can be a simple version number as the labels are held the
|
|
|
756 |
context of a package.
|
|
|
757 |
|
| 383 |
dpurdie |
758 |
A simple label of TIMESTAMP will be treated in special manner. The name will be
|
|
|
759 |
replaced with a unique name based on the users name and the current date time.
|
|
|
760 |
|
| 267 |
dpurdie |
761 |
=item * Peg
|
|
|
762 |
|
|
|
763 |
A peg consists of a '@' and a number string at the end of the label.
|
|
|
764 |
|
|
|
765 |
=back
|
|
|
766 |
|
|
|
767 |
An example of a full label is: repo/package/component/tags/label_text@1234
|
|
|
768 |
|
|
|
769 |
Not all operation support the full label syntax. The 'peg' is not allowed in
|
|
|
770 |
a label that will be used as a target of a repository copy operation, nor
|
|
|
771 |
is the 'Package Path'.
|
|
|
772 |
|
|
|
773 |
Full labels can be used in operations that specify the source of a
|
|
|
774 |
copy operation, such as a delete, rename or clone operation.
|
|
|
775 |
|
|
|
776 |
All operations report a 'Full Label' that can be used to reference the
|
| 341 |
dpurdie |
777 |
repository at any time in the future. This is the 'tag' that needs to be
|
| 267 |
dpurdie |
778 |
provided to 'Release Manager in order to reproduce the package.
|
|
|
779 |
|
|
|
780 |
=head1 EXAMPLE
|
|
|
781 |
|
|
|
782 |
jats svnlabel -label daf_br_23.0.0.syd
|
|
|
783 |
|
|
|
784 |
=cut
|
|
|
785 |
|