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