Subversion Repositories DevTools

Rev

Rev 1329 | Rev 2049 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1329 Rev 1403
Line 46... Line 46...
46
my $opt_branch;
46
my $opt_branch;
47
my $opt_list;
47
my $opt_list;
48
my $opt_author;
48
my $opt_author;
49
my $opt_date;
49
my $opt_date;
50
my $opt_complexTag;
50
my $opt_complexTag;
-
 
51
my $opt_noUpdateCheck;
51
 
52
 
52
#
53
#
53
#   Globals
54
#   Globals
54
#
55
#
55
my $session;                                # Subversion Session
56
my $session;                                # Subversion Session
Line 83... Line 84...
83
                'branch'        => \$opt_branch,            # Flag
84
                'branch'        => \$opt_branch,            # Flag
84
                'list'          => \$opt_list,              # Flag
85
                'list'          => \$opt_list,              # Flag
85
                'author=s'      => \$opt_author,            # String
86
                'author=s'      => \$opt_author,            # String
86
                'date=s'        => \$opt_date,              # String
87
                'date=s'        => \$opt_date,              # String
87
                'allowlocalmods!'   => \$opt_complexTag,    # [no]aaaaaa
88
                'allowlocalmods!'   => \$opt_complexTag,    # [no]aaaaaa
-
 
89
                'allowRepoChanges!'   => \$opt_noUpdateCheck, # [no]aaaaaa
-
 
90
 
88
                );
91
                );
89
 
92
 
90
                #
93
                #
91
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
94
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
92
                #
95
                #
Line 114... Line 117...
114
Error ("Conflicting options. Clone and Label") if ( $opt_clone && $opt_label );
117
Error ("Conflicting options. Clone and Label") if ( $opt_clone && $opt_label );
115
Error ("Conflicting options. Rename and Label") if ( $opt_rename && $opt_label );
118
Error ("Conflicting options. Rename and Label") if ( $opt_rename && $opt_label );
116
$label = $ARGV[0];
119
$label = $ARGV[0];
117
 
120
 
118
#
121
#
-
 
122
#   Process user label specification
-
 
123
#   May in the form SVN::Path::Tag
-
 
124
#
-
 
125
$label =~ s~^SVN::~~ if $label;
-
 
126
if ( $label =~ m~(.+)::(.+)~ )
-
 
127
{
-
 
128
    my $sourcePath = $1;
-
 
129
    my $tag = $2;
-
 
130
 
-
 
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
 
-
 
161
#
119
#   Locate package and workspace roots
162
#   Locate package and workspace roots
120
#
163
#
121
LocateRoots ();
164
LocateRoots ();
122
 
165
 
123
################################################################################
166
################################################################################
Line 180... Line 223...
180
{
223
{
181
    #
224
    #
182
    #   Create old and new paths for the full label
225
    #   Create old and new paths for the full label
183
    #
226
    #
184
    my $ws_label_old = make_src_label ($pkg_root, $label);
227
    my $ws_label_old = make_src_label ($pkg_root, $label);
-
 
228
    my $label_new = SvnIsaSimpleLabel($opt_rename);
185
    my $ws_label_new = make_label ($pkg_root ,SvnIsaSimpleLabel($opt_rename));
229
    my $ws_label_new = make_label ($pkg_root , $label_new);
186
 
230
 
187
    $session->SvnRename (
231
    $session->SvnRename (
188
                'old' => $ws_label_old,
232
                'old' => $ws_label_old,
189
                'new' => $ws_label_new,
233
                'new' => $ws_label_new,
190
                'comment' => $opt_comment ? $opt_comment : 'Renamed by Jats Svnlabel',
234
                'comment' => $opt_comment ? $opt_comment : 'Renamed by Jats Svnlabel',
191
                'replace' => $opt_replace ? 1 : 0,
235
                'replace' => $opt_replace ? 1 : 0,
192
                );
236
                );
193
    
237
    
194
    Message ("Repository Ref: " . $session->RmRef);
238
    Message ("Repository Ref: " . $session->RmRef);
-
 
239
    Message ("Vcs Tag       : " . $session->SvnTag);
195
    updateProperties();
240
    updateProperties();
196
    $opr_done = 1;
241
    $opr_done = 1;
197
}
242
}
198
 
243
 
199
################################################################################
244
################################################################################
Line 204... Line 249...
204
if ( $opt_label )
249
if ( $opt_label )
205
{
250
{
206
    #
251
    #
207
    #   Can now create a nice pathname for the label
252
    #   Can now create a nice pathname for the label
208
    #
253
    #
-
 
254
    $label = SvnIsaSimpleLabel ($label);
209
    my $ws_label = make_label( $pkg_root, SvnIsaSimpleLabel ($label));
255
    my $ws_label = make_label( $pkg_root, $label );
210
 
256
 
211
    #
257
    #
212
    #   Don't let the user create a tag from a workspace that is
258
    #   Don't let the user create a tag from a workspace that is
213
    #   also created from a tag.
259
    #   also created from a tag.
214
    #
260
    #
Line 220... Line 266...
220
           "WorkSpace: $session->{WSURL}" )
266
           "WorkSpace: $session->{WSURL}" )
221
        if ( !$opt_branch && (($session->WsType) eq 'tags') );
267
        if ( !$opt_branch && (($session->WsType) eq 'tags') );
222
 
268
 
223
    #
269
    #
224
    #   The label operation *should* be a server side operation only
270
    #   The label operation *should* be a server side operation only
225
    #   If the user has commited chaages, but not yet updated the local
271
    #   If the user has commited changes, but not yet updated the local
226
    #   workspace, then subversion will do a client side copy
272
    #   workspace, then subversion will do a client side copy
227
    #   This is not good.
273
    #   This is not good.
228
    #       If the 'tags' area is not writable then we get a cryptic message
274
    #       If the 'tags' area is not writable then we get a cryptic message
229
    #       If the 'tags' area is writable then we commit the changes twice
275
    #       If the 'tags' area is writable then we commit the changes twice
230
    #
276
    #
231
    #   Solution - ensure that the Workspace is upto date
277
    #   Solution - ensure that the Workspace is upto date
232
    #              This is done within SvnCopyWs
278
    #              This is done within SvnCopyWs
233
    #
279
    #
234
 
-
 
235
    $session->SvnCopyWs (
280
    $session->SvnCopyWs (
236
                   target => $ws_label,
281
                   target => $ws_label,
237
                   'allowLocalMods' => $opt_complexTag,
282
                   'allowLocalMods' => $opt_complexTag,
-
 
283
                   'noupdatecheck' => $opt_noUpdateCheck,
238
                   'noswitch' => 1,
284
                   'noswitch' => 1,
239
                   'replace' => $opt_replace ? 1 : 0,
285
                   'replace' => $opt_replace ? 1 : 0,
240
                   'comment' => $opt_comment ? $opt_comment : 'Created by Jats Svnlabel',
286
                   'comment' => $opt_comment ? $opt_comment : 'Created by Jats Svnlabel',
241
                   );
287
                   );
242
 
288
 
243
    Message ("Repository Ref: " . $session->RmRef);
289
    Message ("Repository Ref: " . $session->RmRef);
-
 
290
    Message ("Vcs Tag       : " . $session->SvnTag);
244
    updateProperties();
291
    updateProperties();
245
    $opr_done = 1;
292
    $opr_done = 1;
246
}
293
}
247
 
294
 
248
################################################################################
295
################################################################################
Line 273... Line 320...
273
{
320
{
274
    #
321
    #
275
    #   Create old and new paths for the full label
322
    #   Create old and new paths for the full label
276
    #
323
    #
277
    my $ws_label_old = make_src_label ($pkg_root, $label);
324
    my $ws_label_old = make_src_label ($pkg_root, $label);
-
 
325
    my $new_label = SvnIsaSimpleLabel($opt_clone);
278
    my $ws_label_new = make_label ($pkg_root ,SvnIsaSimpleLabel($opt_clone));
326
    my $ws_label_new = make_label ($pkg_root , $new_label);
-
 
327
    #
-
 
328
    #   Backtrack label so that we clone the tag source, not the tag
-
 
329
    #
-
 
330
    if ( $ws_label_old =~ m~/tags/~ )
-
 
331
    {
-
 
332
        my $tag = $label;
-
 
333
        $tag = 'tags/' . $tag unless ( $tag =~ m~^tags/~ );
-
 
334
        $ws_label_old = $session->backTrackSvnLabel( $tag, savedevbranch => 1);
-
 
335
        Verbose2 ("Tag back tracked to: $ws_label_old");
-
 
336
        $ws_label_old = $pkg_root . '/' . $ws_label_old;
-
 
337
    }
-
 
338
 
279
    $session->SvnCopy (
339
    $session->SvnCopy (
280
                'old' => $ws_label_old,
340
                'old' => $ws_label_old,
281
                'new' => $ws_label_new,
341
                'new' => $ws_label_new,
282
                'comment' => $opt_comment ? $opt_comment : 'Copied by Jats Svnlabel',
342
                'comment' => $opt_comment ? $opt_comment : 'Copied by Jats Svnlabel Clone',
283
                'replace' => $opt_replace ? 1 : 0,
343
                'replace' => $opt_replace ? 1 : 0,
284
                );
344
                );
285
    
-
 
286
    Message ("Repository Ref: " . $session->RmRef);
345
    Message ("Repository Ref: " . $session->RmRef);
-
 
346
    Message ("Vcs Tag       : " . $session->SvnTag);
287
    updateProperties();
347
    updateProperties();
288
    $opr_done = 1;
348
    $opr_done = 1;
289
}
349
}
290
 
350
 
291
 
351
 
Line 313... Line 373...
313
#-------------------------------------------------------------------------------
373
#-------------------------------------------------------------------------------
314
# Function        : make_src_label
374
# Function        : make_src_label
315
#
375
#
316
# Description     : Create a source label ( tag or branch )
376
# Description     : Create a source label ( tag or branch )
317
#
377
#
318
#                   Calculation may be bypassed in the global $src_label
378
#                   Calculation may be bypassed if the global $src_label
319
#                   is specified.
379
#                   is specified.
320
#
380
#
321
# Inputs          : $base
381
# Inputs          : $base
322
#                   $name           - May contain hint
382
#                   $name           - May contain hint
323
#                                     Prefixed with 'tags/' or 'branches/'
383
#                                     Prefixed with 'tags/' or 'branches/'
Line 472... Line 532...
472
    -workspace=path        - Path to a workspace to label
532
    -workspace=path        - Path to a workspace to label
473
    -packagebase=path      - Repository path to package base
533
    -packagebase=path      - Repository path to package base
474
    -author=name           - Force author of changes
534
    -author=name           - Force author of changes
475
    -date=dateString       - Force date of changes
535
    -date=dateString       - Force date of changes
476
    -allowLocalMods        - Allow complex tagging
536
    -allowLocalMods        - Allow complex tagging
-
 
537
    -allowRepoChanges      - Supress check for an up to date workspace
477
 
538
 
478
=head1 OPTIONS
539
=head1 OPTIONS
479
 
540
 
480
=over 8
541
=over 8
481
 
542
 
Line 561... Line 622...
561
be taken to be that of the package in the workspace.
622
be taken to be that of the package in the workspace.
562
 
623
 
563
=item B<-branch>
624
=item B<-branch>
564
 
625
 
565
This option modifies all commands. It causes the labeling operations to be
626
This option modifies all commands. It causes the labeling operations to be
566
performed on a the packages 'branches' area instead of the default 'tags'
627
performed on a packages 'branches' area instead of the default 'tags'
567
area.
628
area.
568
 
629
 
569
=item -author=name
630
=item -author=name
570
 
631
 
571
This option will force the author of changes as recorded in the repository.
632
This option will force the author of changes as recorded in the repository.
Line 593... Line 654...
593
and will form a part of the tag.
654
and will form a part of the tag.
594
 
655
 
595
This mode of operation should NOT be used for normal labeling. It is useful for
656
This mode of operation should NOT be used for normal labeling. It is useful for
596
the preservation of 'Mixed Workspaces'.
657
the preservation of 'Mixed Workspaces'.
597
 
658
 
-
 
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
 
598
=back
673
=back
599
 
674
 
600
=head1 DESCRIPTION
675
=head1 DESCRIPTION
601
 
676
 
602
This program provides a number of useful Subversion labeling operations. These
677
This program provides a number of useful Subversion labeling operations. These