Subversion Repositories DevTools

Rev

Rev 1356 | Rev 2053 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
311 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2008 ERG Limited, All rights reserved
3
#
4
# Module name   : jats_svn.pl
5
# Module type   : Jats Utility
6
# Compiler(s)   : Perl
7
# Environment(s): Jats
8
#
9
# Description   : A script to perform a number of SVN utility functions
10
#                 The script will:
11
#                   Delete a package
12
#                   Create a package
13
#                   Import source to a package
14
#
15
#
16
#......................................................................#
17
 
18
require 5.006_001;
19
use strict;
20
use warnings;
21
use JatsError;
22
use JatsSvn qw(:All);
23
use JatsLocateFiles;
379 dpurdie 24
use JatsProperties;
311 dpurdie 25
use Pod::Usage;                                 # required for help support
26
use Getopt::Long qw(:config require_order);     # Stop on non-option
27
use Cwd;
28
use File::Path;
29
use File::Copy;
30
use File::Basename;
31
use File::Compare;
387 dpurdie 32
use Encode;
311 dpurdie 33
 
34
my $VERSION = "1.0.0";                          # Update this
35
 
36
#
37
#   Options
38
#
39
my $opt_debug   = $ENV{'GBE_DEBUG'};            # Allow global debug
40
my $opt_verbose = $ENV{'GBE_VERBOSE'};          # Allow global verbose
41
my $opt_help = 0;
42
 
43
#
44
#   Globals
45
#
46
my $opr_done;                                   # User has done something
47
 
48
#-------------------------------------------------------------------------------
49
# Function        : Mainline Entry Point
50
#
51
# Description     :
52
#
53
# Inputs          :
54
#
55
my $result = GetOptions (
56
                "help:+"        => \$opt_help,              # flag, multiple use allowed
57
                "manual:3"      => \$opt_help,              # flag
58
                "verbose:+"     => \$opt_verbose,           # flag, multiple use allowed
59
 
60
                );
61
 
62
                #
63
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
64
                #
65
 
66
#
67
#   Process help and manual options
68
#
69
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
70
pod2usage(-verbose => 1) if ($opt_help == 2 );
71
pod2usage(-verbose => 2) if ($opt_help > 2);
72
 
73
#
74
#   Configure the error reporting process now that we have the user options
75
#
76
ErrorConfig( 'name'    =>'SVN',
77
             'verbose' => $opt_verbose,
78
            );
79
 
80
#
369 dpurdie 81
#   Reconfigure the options parser to allow subcommands to parse options
311 dpurdie 82
#
83
Getopt::Long::Configure('permute');
84
 
85
#
86
#   Process command
87
#   First command line argument is a subversion command
88
#
89
my $cmd = shift @ARGV || "help";
90
CreatePackage()                        if ( $cmd =~ m/^create/ );
2048 dpurdie 91
CreateBranch()                         if ( $cmd =~ m/^branch/ );
92
SwitchBranch()                         if ( $cmd =~ m/^switch/ );
385 dpurdie 93
DeleteBranch()                         if ( $cmd =~ m/^delete-branch/ );
311 dpurdie 94
DeletePackage()                        if ( $cmd =~ m/^delete-package/ );
95
ImportPackage()                        if ( $cmd =~ m/^import/ );
96
SvnRepoCmd($cmd, @ARGV)                if ( $cmd eq 'ls' );
363 dpurdie 97
TestSvn()                              if ($cmd eq 'test');
369 dpurdie 98
ShowPaths()                            if ( $cmd =~ m/^path/ );
99
ShowTag()                              if ( $cmd =~ m/^tag/ );
100
ShowUrl()                              if ( $cmd =~ m/^url/ );
311 dpurdie 101
 
102
pod2usage(-verbose => 0, -message => "No valid operations specified") unless ( $opr_done );
103
exit 0;
104
 
105
#-------------------------------------------------------------------------------
369 dpurdie 106
# Function        : ShowPaths
107
#
108
# Description     : Show PATHS
109
#
2048 dpurdie 110
# Inputs          :
369 dpurdie 111
#
2048 dpurdie 112
# Returns         :
369 dpurdie 113
#
114
sub ShowPaths
115
{
116
    #
117
    #   Parse more options
118
    #
119
    GetOptions (
120
                "help:+"        => \$opt_help,
121
                "manual:3"      => \$opt_help,
122
                ) || Error ("Invalid command line" );
123
 
124
    #
125
    #   Subcommand specific help
126
    #
127
    SubCommandHelp( $opt_help, "Subversion Paths") if ($opt_help || $#ARGV >= 0);
128
 
129
    #
130
    #   Display known PATHS
131
    #
132
    my ( $pSVN_URLS, $pSVN_URLS_LIST) = SvnPaths();
133
    print ("Configured SubVersion Repository Paths\n");
134
    print sprintf("    %-20s %s\n", 'Tag', 'URL Prefix');
135
 
136
    foreach my $key ( @{$pSVN_URLS_LIST} )
137
    {
138
        print sprintf("    %-20s %s\n", $key || 'Default', $pSVN_URLS->{$key} );
139
    }
140
 
141
    $opr_done = 1;
142
}
143
 
144
#-------------------------------------------------------------------------------
145
# Function        : ShowTag
146
#
147
# Description     : Convert a URL into a TAG
148
#                   Convert the current workspace info into a TAG
149
#
150
# Inputs          : url                     - Url to convert (optional)
151
#                   Options
152
#                       -help[=n]           - Show help
153
#                       -man                - Show manual
154
#                       -url=url            - Convert URL
155
#                       -path=path          - Convert Workspace
156
#
157
# Returns         : Nothing
158
#
159
sub ShowTag
160
{
161
    my $opt_path;
162
    my $opt_url;
163
 
164
    #
165
    #   Parse more options
166
    #
167
    GetOptions (
168
                "help:+"        => \$opt_help,
169
                "manual:3"      => \$opt_help,
170
                "path:s"        => \$opt_path,
171
                "url:s"         => \$opt_url,
172
                ) || Error ("Invalid command line" );
173
 
174
    #
175
    #   Subcommand specific help
176
    #
177
    SubCommandHelp( $opt_help, "Url to Tag") if ($opt_help);
178
 
179
    #
180
    #   Bare argument is a URL
181
    #   If no arguments provided assume a path of the current directory
182
    #
183
    $opt_url = shift (@ARGV) if ( $#ARGV == 0 );
184
    $opt_path = '.' unless ( defined $opt_path || defined $opt_url );
185
 
186
    #
187
    #   Sanity Tests
188
    #
189
    Error ("Cannot specify both a URL and a PATH")
190
            if ( defined $opt_url && defined $opt_path );
191
    Warning ("Too many arguments") if ( $#ARGV >= 0 );
192
 
193
    #   Do all the hard work
194
    #
195
    my $uref;
196
    if ( $opt_url )
197
    {
198
        $uref = NewSessionByUrl ( $opt_url );
199
        $uref->CalcRmReference($uref->Full());
200
    }
201
    else
202
    {
203
        $uref = NewSessionByWS($opt_path, 0, 1);
204
        my $ws_root = $uref->SvnLocateWsRoot(1);
205
        $uref->CalcRmReference($uref->FullWs());
206
    }
207
 
1348 dpurdie 208
    Message ("Tag is  : " . $uref->RmRef() );
209
    Message ("Vcs Tag : " . $uref->SvnTag  );
2048 dpurdie 210
 
369 dpurdie 211
    $opr_done = 1;
212
}
213
#-------------------------------------------------------------------------------
214
# Function        : ShowUrl
215
#
216
# Description     : Convert a TAG into a URL
217
#                   Show the current workspace URL
218
#
219
# Inputs          : tag                     - Tag to convert (optional)
220
#                   Options
221
#                       -help[=n]           - Show help
222
#                       -man                - Show manual
223
#                       -tag=tag            - Convert TAG
224
#                       -path=path          - Convert Workspace
225
#
226
# Returns         : Nothing
227
#
228
sub ShowUrl
229
{
230
    my $opt_path;
231
    my $opt_tag;
232
 
233
    #
234
    #   Parse more options
235
    #
236
    GetOptions (
237
                "help:+"        => \$opt_help,
238
                "manual:3"      => \$opt_help,
239
                "path:s"        => \$opt_path,
240
                "tag:s"         => \$opt_tag,
241
                ) || Error ("Invalid command line" );
242
 
243
    #
244
    #   Subcommand specific help
245
    #
246
    SubCommandHelp( $opt_help, "Tag to Url") if ($opt_help);
247
 
248
    #
249
    #   Bare argument is a TAG
250
    #   If no arguments provided assume a path of the current directory
251
    #
252
    $opt_tag = shift (@ARGV) if ( $#ARGV == 0 );
253
    $opt_path = '.' unless ( defined $opt_path || defined $opt_tag );
254
 
255
    #
256
    #   Sanity Tests
257
    #
258
    Error ("Cannot specify both a TAG and a PATH")
259
            if ( defined $opt_tag && defined $opt_path );
260
    Warning ("Too many arguments") if ( $#ARGV >= 0 );
261
 
262
    #   Do all the hard work
263
    #
264
    my $uref;
265
    my $url;
266
    if ( $opt_tag )
267
    {
268
        $url = SvnPath2Url($opt_tag);
269
    }
270
    else
271
    {
272
        $uref = NewSessionByWS($opt_path, 0, 1);
273
        my $ws_root = $uref->SvnLocateWsRoot(1);
274
        $url = $uref->FullWsRev();
275
    }
276
 
277
    Message ("Url: $url");
278
    $opr_done = 1;
279
}
280
 
281
#-------------------------------------------------------------------------------
363 dpurdie 282
# Function        : TestSvn
283
#
284
# Description     : Test access to subversion
285
#
286
# Inputs          : None
287
#
288
# Returns         :
289
#
290
sub TestSvn
291
{
292
    #
293
    #   Parse more options
294
    #
295
    GetOptions (
296
                "help:+"        => \$opt_help,
297
                "manual:3"      => \$opt_help,
298
                ) || Error ("Invalid command line" );
299
 
300
    #
301
    #   Subcommand specific help
302
    #
303
    SubCommandHelp( $opt_help, "Test Subversion") if ($opt_help || $#ARGV >= 0);
304
 
305
    SvnUserCmd( '--version');
306
    $opr_done = 1;
307
}
308
#-------------------------------------------------------------------------------
311 dpurdie 309
# Function        : SvnRepoCmd
310
#
311
# Description     : Execute a SVN command, where the first argument
312
#                   is a repository specifier
313
#
314
# Inputs          : $cmd
315
#                   $repo_url
316
#                   @opts
317
#
2048 dpurdie 318
# Returns         :
311 dpurdie 319
#
320
sub SvnRepoCmd
321
{
322
    my ( $cmd, $repo_url, @opts ) = @_;
323
    my $uref = NewSessionByUrl ( $repo_url );
324
 
325
    SvnUserCmd( $cmd,
326
            $uref->Full,
327
            @opts,
328
            { 'credentials' => 1 });
2048 dpurdie 329
 
311 dpurdie 330
    $opr_done = 1;
331
}
332
 
333
#-------------------------------------------------------------------------------
334
# Function        : DeletePackage
335
#
336
# Description     : Delete a Package structure within a Repository
337
#                   Intended for test usage
338
#
339
# Inputs          : URL                 - Url to Repo + Package Base
340
#
2048 dpurdie 341
# Returns         :
311 dpurdie 342
#
343
sub DeletePackage
344
{
379 dpurdie 345
    my $opt_error = 0;
311 dpurdie 346
    #
347
    #   Parse more options
348
    #
349
    GetOptions (
350
                "help:+"        => \$opt_help,
351
                "manual:3"      => \$opt_help,
379 dpurdie 352
                "error!"       => \$opt_error,
311 dpurdie 353
                ) || Error ("Invalid command line" );
354
 
355
    #
356
    #   Subcommand specific help
357
    #
358
    SubCommandHelp( $opt_help, "Delete a Package") if ($opt_help || $#ARGV < 0);
359
 
360
    #
361
    #   Sanity Tests
362
    #
363
    Message ("Delete Entire Package Tree" );
364
    Warning ("Too many arguments: @ARGV") if ( $#ARGV >= 1 );
365
 
366
    #
367
    #   Do all the hard work
368
    #       Create
369
    #       Import
370
    #       Label
371
    #
372
    my $uref = NewSessionByUrl ( $ARGV[0] );
379 dpurdie 373
    $uref->SvnValidatePackageRoot(!$opt_error);
311 dpurdie 374
    $uref->SvnDelete (
375
                      'target'      => $uref->Full,
385 dpurdie 376
                      'comment'   => [$uref->Path().": Delete Package",'Deleted by user command: jats svn delete-package'],
379 dpurdie 377
                      'noerror'   => !$opt_error,
311 dpurdie 378
                      );
379
    $opr_done = 1;
380
}
381
 
382
#-------------------------------------------------------------------------------
383
# Function        : CreatePackage
384
#
385
# Description     : Create a Package structure within a Repository
386
#                   Optionally Import Data
387
#                   Optionally Tag the import
388
#                   Optionally Tag the import on a branch
389
#
390
# Inputs          : URL                 - Url to Repo + Package Base
391
#                   Options             - Command modifiers
392
#                       -import=path    - Import named directory
393
#                       -label=name     - Label the result
394
#                       -tag=name       - Import to Tag Only
395
#                       -branch=name    - Import to Branch only
396
#                       -new            - Must be new package
397
#                       -replace        - Replace existing
398
#
2048 dpurdie 399
# Returns         :
311 dpurdie 400
#
401
sub CreatePackage
402
{
403
    my $opt_import;
404
    my $opt_tag;
405
    my $opt_branch;
406
    my $opt_trunk;
407
    my $opt_new;
408
    my $opt_label;
409
    my $opt_replace;
410
    my $pname;
411
    my $type;
385 dpurdie 412
    my $opt_author;
413
    my $opt_date;
311 dpurdie 414
    Message ("Create New Package Version" );
415
 
416
    #
417
    #   Parse more options
418
    #
419
    GetOptions (
420
                "help:+"        => \$opt_help,
421
                "manual:3"      => \$opt_help,
422
                "verbose:+"     => \$opt_verbose,
423
                "import=s"      => \$opt_import,
424
                "new"           => \$opt_new,
425
                "branch=s"      => \$opt_branch,
426
                "trunk"         => \$opt_trunk,
1347 dpurdie 427
                "tags=s"        => \$opt_tag,
311 dpurdie 428
                "label=s"       => \$opt_label,
429
                "replace"       => \$opt_replace,
385 dpurdie 430
                'author=s'      => \$opt_author,
431
                'date=s'        => \$opt_date,
311 dpurdie 432
 
433
                ) || Error ("Invalid command line" );
434
 
435
    #
436
    #   Subcommand specific help
437
    #
438
    SubCommandHelp( $opt_help, "Create a Package Version") if ($opt_help || $#ARGV < 0);
2048 dpurdie 439
 
311 dpurdie 440
    #
369 dpurdie 441
    #   Alter the error reporting parameters
311 dpurdie 442
    #
443
    ErrorConfig( 'verbose' => $opt_verbose );
444
 
445
    #
446
    #   Sanity Tests
447
    #
448
    my $count = 0;
449
    $count++ if ( $opt_trunk );
450
    $count++ if ( $opt_branch );
451
    $count++ if ( $opt_tag );
452
    Error ("Conflicting options: -trunk, -tag, -branch") if ( $count > 1 );
453
    Error ("Nothing imported to be labeled") if ( $count && !$opt_import );
454
    Error ("Import path does not exist: $opt_import") if ( $opt_import && ! -d $opt_import );
455
    Error ("Conflicting options: new and replace") if ( $opt_new && $opt_replace );
385 dpurdie 456
    Error ("Too many command line arguments") if ( exists $ARGV[1] );
311 dpurdie 457
 
1347 dpurdie 458
    $type = 'tags/' . $opt_tag          if ( $opt_tag);
459
    $type = 'branches/' . $opt_branch   if ( $opt_branch );
460
    $type = 'trunk'                     if ( $opt_trunk);
311 dpurdie 461
 
462
    #
463
    #   Do all the hard work
464
    #       Create
465
    #       Import
466
    #       Label
467
    #
468
    my $uref = NewSessionByUrl ( $ARGV[0] );
469
    $uref->SvnCreatePackage (
470
                      'import'  => $opt_import,
471
                      'label'   => $opt_label,
472
                      'type'    => $type,
473
                      'new'     => $opt_new,
474
                      'replace' => $opt_replace,
475
                      );
385 dpurdie 476
    #
477
    # Report RmPath as using a pegged version of a new package is a bit silly
478
    #
1356 dpurdie 479
#    Message ("Repository Ref: " . $uref->RmPath);
480
#    Message ("Vcs Tag       : " . $uref->SvnTag);
1270 dpurdie 481
    if ( $uref->{REVNO} )
482
    {
483
        $uref->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
484
        $uref->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
485
    }
311 dpurdie 486
    $opr_done = 1;
487
}
488
 
489
#-------------------------------------------------------------------------------
490
# Function        : ImportPackage
491
#
492
# Description     : Import a new version of a package
493
#                   Take great care to reuse file-versions that are already in
494
#                   the  package
495
#
369 dpurdie 496
#                   Intended to allow the importation of multiple
311 dpurdie 497
#                   versions of a package
498
#
2048 dpurdie 499
# Inputs          :
311 dpurdie 500
#
2048 dpurdie 501
# Returns         :
311 dpurdie 502
#
503
sub ImportPackage
504
{
505
    Message ("Import Package Version" );
506
 
507
    #
508
    #   Options
509
    #
510
    my $opt_package;
511
    my $opt_dir;
512
    my $opt_label;
513
    my $opt_replace = 0;
514
    my $opt_reuse;
515
    my $opt_workdir = "SvnImportDir";
516
    my $opt_delete = 1;
379 dpurdie 517
    my $opt_author;
518
    my $opt_date;
519
    my $opt_log = '';
520
    my $opt_branch;
521
    my $opt_datafile;
1348 dpurdie 522
    my $opt_printfiles;
311 dpurdie 523
 
524
    #
525
    #   Other globals
526
    #
527
    my $url_label;
379 dpurdie 528
    my $url_branch;
311 dpurdie 529
 
530
    #
531
    #   Configuration options
532
    #
533
    my $result = GetOptions (
379 dpurdie 534
                    'help:+'        => \$opt_help,
535
                    'manual:3'      => \$opt_help,
536
                    'verbose:+'     => \$opt_verbose,
537
                    'package=s'     => \$opt_package,
538
                    'dir=s'         => \$opt_dir,
539
                    'label=s'       => \$opt_label,
540
                    'branch=s'      => \$opt_branch,
541
                    'replace'       => \$opt_replace,
542
                    'reuse'         => \$opt_reuse,
543
                    'workspace=s'   => \$opt_workdir,
544
                    'delete!'       => \$opt_delete,
1348 dpurdie 545
                    'printfiles=i'  => \$opt_printfiles,
379 dpurdie 546
                    'author=s'      => \$opt_author,
547
                    'date=s'        => \$opt_date,
548
                    'log=s'         => \$opt_log,
549
                    'datafile=s'    => \$opt_datafile,
311 dpurdie 550
 
551
                    #
552
                    #   Update documentation at the end of the file
553
                    #
554
                    ) || Error ("Invalid command line" );
555
 
556
    #
557
    #   Insert defaults
341 dpurdie 558
    #   User can specify base package via -package or a non-options argument
311 dpurdie 559
    #
560
    $opt_package = $ARGV[0] unless ( $opt_package );
379 dpurdie 561
    unlink $opt_datafile if ( defined $opt_datafile );
2048 dpurdie 562
 
311 dpurdie 563
    #
564
    #   Subcommand specific help
565
    #
566
    SubCommandHelp( $opt_help, "Import directory to a Package")
567
        if ($opt_help || ! $opt_package );
568
 
569
    #
369 dpurdie 570
    #   Alter the error reporting parameters
311 dpurdie 571
    #
572
    ErrorConfig( 'verbose' => $opt_verbose );
573
 
574
    #
575
    #   Configure the error reporting process now that we have the user options
576
    #
577
    Error ("No package URL specified") unless ( $opt_package );
578
    Error ("No base directory specified") unless ( $opt_dir );
579
    Error ("Invalid base directory: $opt_dir") unless ( -d $opt_dir );
580
 
581
    #
582
    #   Create an SVN session
583
    #
584
    my $svn = NewSessionByUrl ( $opt_package );
585
 
586
    #
587
    #   Ensure that the required label is available
588
    #
589
    if ( $opt_label )
590
    {
591
        $opt_label = SvnIsaSimpleLabel ($opt_label);
592
        $url_label = $svn->BranchName( $opt_label, 'tags' );
593
        $svn->SvnValidateTarget (
594
                        'target' => $url_label,
595
                        'available' => 1,
596
                        ) unless ( $opt_replace );
597
    }
598
 
599
    #
379 dpurdie 600
    #   Validate the required branch
601
    #   It will be created if it doesn't exist
602
    #
603
    if ( $opt_branch )
604
    {
605
        $opt_branch = SvnIsaSimpleLabel($opt_branch);
606
        $url_branch = $svn->BranchName( $opt_branch, 'branches' );
385 dpurdie 607
        my $rv = $svn->SvnValidateTarget (
608
                        'cmd'    => 'SvnImporter. Create branch',
379 dpurdie 609
                        'target' => $url_branch,
610
                        'create' => 1,
611
                        );
385 dpurdie 612
        if ( $rv == 2 )
613
        {
614
            $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
615
            $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
616
        }
379 dpurdie 617
    }
618
 
619
    #
311 dpurdie 620
    #   Create a workspace based on the users package
621
    #   Allow the workspace to be reused to speed up multiple
622
    #   operations
623
    #
624
    unless ( $opt_reuse && -d $opt_workdir )
625
    {
626
        Message ("Creating Workspace");
627
        rmtree( $opt_workdir );
628
 
629
        $svn->SvnValidatePackageRoot ();
630
        #DebugDumpData( 'Svn', $svn );
631
        $svn->SvnValidateTarget (
632
                            'cmd'    => 'SvnImporter',
633
                            'target' => $svn->Full,
634
                            'require' => 1,
635
                            );
636
 
379 dpurdie 637
        my $url_co = $opt_branch ? $url_branch : $svn->Full . '/trunk';
1356 dpurdie 638
        $svn->SvnCo ( $url_co, $opt_workdir, 'print' => $opt_printfiles );
311 dpurdie 639
        Error ("Cannot locate the created Workspace")
640
            unless ( -d $opt_workdir );
641
    }
642
    else
643
    {
644
        Message ("Reusing Workspace");
645
    }
2048 dpurdie 646
 
311 dpurdie 647
    #
648
    #   Determine differences between the two folders
649
    #       Create structures for each directory
650
    #
651
    Message ("Determine Files in packages");
652
 
653
    my $search = JatsLocateFiles->new("--Recurse=1",
654
                                       "--DirsToo",
655
                                       "--FilterOutRe=/\.svn/",
656
                                       "--FilterOutRe=/\.svn\$",
657
                                       "--FilterOutRe=^/${opt_workdir}\$",
658
                                       "--FilterOutRe=^/${opt_workdir}/",
659
                                       );
660
    my @ws = $search->search($opt_workdir);
661
    my @dir = $search->search($opt_dir);
662
 
1270 dpurdie 663
    #
664
    #   Scan for a source file
665
    #   Trying to detect empty views
666
    #   Look for file, not directory
667
    #
668
    {
669
        my $fileFound = 0;
670
        foreach ( @dir )
671
        {
672
            next if ( m~/$~ );
673
            $fileFound++;
674
            last;
675
        }
676
 
677
        unless ( $fileFound )
678
        {
679
            Warning ("No source files found in source view");
680
            $opr_done = 1;
681
            return;
682
        }
683
    }
684
 
311 dpurdie 685
    #Information ("WS Results", @ws);
686
    #Information ("DIR Results", @dir);
1270 dpurdie 687
    #Information ("WS Results: ", scalar @ws);
688
    #Information ("DIR Results:", scalar @dir);
311 dpurdie 689
 
690
    #
691
    #   Create a hash the Workspace and the User dir
692
    #   The key will be file names
693
    #
694
    my %ws;  map ( $ws{$_} = 1 , @ws );
695
    my %dir; map ( $dir{$_} = 1 , @dir );
696
 
697
    #
698
    #   Create a hash of common elements
699
    #   Removing then from the other two
700
    #
701
    my %common;
702
    foreach ( keys %ws )
703
    {
704
        next unless ( exists $dir{$_} );
705
        $common{$_} = 1;
706
        delete $ws{$_};
707
        delete $dir{$_};
708
    }
709
 
710
    #DebugDumpData( 'WS', \%ws );
711
    #DebugDumpData( 'DIR', \%dir );
712
    #DebugDumpData( 'COMMON', \%common );
713
 
714
    #
379 dpurdie 715
    #   Need to consider the case where a file has been replaced with a directory
716
    #   and visa-versa. Delete files and directories first.
717
    #
718
    #
719
    #   Remove files
720
    #   Sort in reverse. This will ensure that we process directory
721
    #   contents before directories
722
    #
723
    my @rm_files = reverse sort keys %ws;
724
    if ( @rm_files )
725
    {
726
        foreach my $file ( @rm_files  )
727
        {
728
            Verbose ("Removing $file");
729
            unlink "$opt_workdir/$file";
730
        }
731
 
732
        #
733
        #   Inform Subversion about the removed files
734
        #
735
        my $base = 0;
736
        my $num = $#rm_files;
737
        Message ("Update the workspace: Removed " . ($num + 1) . " Files");
738
 
739
        while ( $base <= $num )
740
        {
741
            my $end = $base + 200;
742
            $end = $num if ( $end > $num );
743
 
744
            $svn->SvnCmd ( 'delete', map ("$opt_workdir/$_@", @rm_files[$base .. $end] ),
745
                            { 'error' => 'Deleting files from workspace' } );
2048 dpurdie 746
 
379 dpurdie 747
            $base = $end + 1;
748
        }
749
    }
2048 dpurdie 750
 
379 dpurdie 751
    #
311 dpurdie 752
    #   Add New Files
753
    #   Won't add empty directories at this point
754
    #
755
    #   Process by sorted list
756
    #   This will ensure we process parent directories first
757
    #
758
    my @added = sort keys %dir;
759
    if ( @added )
760
    {
761
        foreach my $file ( @added  )
762
        {
763
            my $src = "$opt_dir/$file";
764
            my $target = "$opt_workdir/$file";
765
 
766
            if ( -d $src )
767
            {
379 dpurdie 768
                Verbose ("Adding directory: $file");
311 dpurdie 769
                mkdir ( $target ) unless (-d $target);
770
            }
771
            else
772
            {
773
 
774
                my $path = dirname ( $target);
775
                mkdir ( $path ) unless (-d $path);
776
 
777
                Verbose ("Adding $file");
778
                unless (File::Copy::copy( $src, $target ))
779
                {
780
                    Error("Failed to transfer file [$file]: $!");
781
                }
782
            }
783
        }
784
 
785
        #
786
        #   Inform Subversion about the added files
787
        #   The command line does have a finite length, so add them 200 at a
788
        #   time.
789
        #
790
 
791
        my $base = 0;
792
        my $num = $#added;
379 dpurdie 793
        Message ("Update the workspace: Added " . (1 + $num) . " files");
311 dpurdie 794
 
795
        while ( $base <= $num )
796
        {
797
            my $end = $base + 200;
798
            $end = $num if ( $end > $num );
799
 
800
            $svn->SvnCmd ( 'add'
801
                            , '--depth=empty'
802
                            , '--parents'
379 dpurdie 803
                            , map ("$opt_workdir/$_@", @added[$base .. $end] ),
311 dpurdie 804
                            { 'error' => 'Adding files to workspace' } );
805
 
806
            $base = $end + 1;
807
        }
808
    }
809
 
810
    #
811
    #   The common files may have changed
812
    #   Simply copy them all in and let subversion figure it out
813
    #
814
    foreach my $file ( sort keys %common  )
815
    {
816
        my $src = "$opt_dir/$file";
817
        my $target = "$opt_workdir/$file";
818
 
819
        next if ( -d $src );
820
        if ( File::Compare::compare ($src, $target) )
821
        {
822
            Verbose ("Transfer $file");
823
            unlink $target;
824
            unless (File::Copy::copy( $src, $target ))
825
            {
826
                Error("Failed to transfer file [$file]: $!",
827
                      "Src: $src",
828
                      "Tgt: $target");
829
            }
830
        }
831
    }
832
 
833
    #
834
    #   Commit the workspace
835
    #   This will go back onto the trunk
836
    #
837
    $svn = NewSessionByWS( $opt_workdir );
379 dpurdie 838
    my $pkgPath = $svn->Path();
387 dpurdie 839
 
379 dpurdie 840
    my $ciComment = "$pkgPath: Checkin by Svn Import";
841
    $ciComment .= "\n" . $opt_log if ( $opt_log );
842
    $ciComment =~ s~\r\n~\n~g;
387 dpurdie 843
    $ciComment =~ s~\r~\n~g;
844
    $ciComment = encode('UTF-8', $ciComment, Encode::FB_DEFAULT);
845
 
379 dpurdie 846
    $svn->SvnCi ('comment' => $ciComment, 'allowSame' => 1 );
381 dpurdie 847
    Message ("Repository Ref: " . $svn->RmRef) unless( $opt_label );
379 dpurdie 848
    $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
849
    $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
311 dpurdie 850
 
851
    #
852
    #   Label the result
853
    #   The workspace will have been updated, so we can use it as the base for
854
    #   the labeling process
855
    #
856
    if ( $opt_label )
857
    {
858
        $svn->SvnCopyWs (
859
                       target => $url_label,
860
                       'noswitch' => 1,
861
                       'replace' => $opt_replace,
379 dpurdie 862
                       'comment' => "$pkgPath: Tagged by Jats Svn Import",
311 dpurdie 863
                       );
864
        Message ("Repository Ref: " . $svn->RmRef);
1347 dpurdie 865
        Message ("Vcs Tag       : " . $svn->SvnTag);
379 dpurdie 866
        $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
867
        $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
311 dpurdie 868
    }
869
 
870
    #
871
    #   Clean up
872
    #
873
    if ( $opt_delete && ! $opt_reuse )
874
    {
875
        Message ("Delete Workspace");
876
        rmtree( $opt_workdir );
877
    }
379 dpurdie 878
 
879
    #
880
    #   Automation data transfer
881
    #
882
    if ( defined $opt_datafile )
883
    {
884
        my $data = JatsProperties::New();
885
 
886
        $data->setProperty('Command'        , 'ImportPackage');
887
        $data->setProperty('Label'          , $opt_label);
1347 dpurdie 888
        $data->setProperty('subversion.url' , $svn->RmRef);
889
        $data->setProperty('subversion.tag' , $svn->SvnTag);
379 dpurdie 890
 
891
        $data->Dump('InfoFile') if ($opt_verbose);
892
        $data->store( $opt_datafile );
893
    }
894
 
311 dpurdie 895
    $opr_done = 1;
896
}
897
 
898
#-------------------------------------------------------------------------------
385 dpurdie 899
# Function        : DeleteBranch
900
#
901
# Description     : Delete the branch that a workspace is based upon
902
#
2048 dpurdie 903
# Inputs          :
385 dpurdie 904
#
2048 dpurdie 905
# Returns         :
385 dpurdie 906
#
907
sub DeleteBranch
908
{
909
    my $opt_path;
910
    my $opt_error = 0;
911
    #
912
    #   Parse more options
913
    #
914
    GetOptions (
915
                "help:+"        => \$opt_help,
916
                "manual:3"      => \$opt_help,
917
                "path:s"        => \$opt_path,
918
                ) || Error ("Invalid command line" );
919
 
920
    #
921
    #   Subcommand specific help
922
    #
923
    SubCommandHelp( $opt_help, "Delete Branch") if ($opt_help);
924
 
925
    #
926
    #   Sanity Tests
927
    #
928
    Message ("Delete Workspace Branch" );
929
    Error ("Too many arguments: @ARGV") if ( $#ARGV >= 0 );
930
 
931
    #
932
    #   Do all the hard work
933
    #
934
    $opt_path = '.' unless ( defined $opt_path );
935
    my $uref = NewSessionByWS($opt_path, 0, 1);
936
    my $ws_root = $uref->SvnLocateWsRoot(1);
937
    my $ws_url = $uref->FullWs();
938
 
939
    #
940
    #   Must be a branch
941
    #
942
    Error ("Workspace is not based on a branch")
943
        unless ( $ws_url =~ m ~/branches/~ );
944
 
945
    Message ("Deleting: " . $uref->{WSURL} );
946
    $uref->SvnDelete (
947
                      'target'    => $ws_url,
948
                      'comment'   => [$uref->Path().": Delete Branch",'Deleted by user command: jats svn delete-branch'],
949
                      );
950
    $opr_done = 1;
951
}
952
 
2048 dpurdie 953
#-------------------------------------------------------------------------------
954
# Function        : CreateBranch
955
#
956
# Description     : Branch a workspace and then switch to the new branch
957
#
958
# Inputs          :
959
#
960
# Returns         :
961
#
962
sub CreateBranch
963
{
964
    my $opt_path;
965
    my $opt_comment;
966
    my $opt_switch = 1;
967
    my $opt_branch;
385 dpurdie 968
 
2048 dpurdie 969
    #
970
    #   Parse more options
971
    #
972
    GetOptions (
973
                "help:+"        => \$opt_help,
974
                "manual:3"      => \$opt_help,
975
                "path:s"        => \$opt_path,
976
                "switch!"       => \$opt_switch,
977
                "comment:s"     => \$opt_comment,
978
                ) || Error ("Invalid command line" );
979
 
980
    #
981
    #   Subcommand specific help
982
    #
983
    SubCommandHelp( $opt_help, "Create Branch") if ($opt_help);
984
 
985
    #
986
    #   Sanity Tests
987
    #
988
    Message ("Create Workspace Branch" );
989
    Error ("Too many arguments: @ARGV") if ( $#ARGV > 0 );
990
    Error ("Not enough arguments. No branch name specified") if ( $#ARGV < 0 );
991
 
992
    #
993
    #   Sanity test the label
994
    #
995
    $opt_branch = SvnIsaSimpleLabel ($ARGV[0] );
996
 
997
    #
998
    #   Do all the hard work
999
    #
1000
    $opt_path = '.' unless ( defined $opt_path );
1001
    my $uref = NewSessionByWS($opt_path, 0, 1);
1002
    my $ws_root = $uref->SvnLocateWsRoot(1);
1003
    my $ws_url = $uref->Full();
1004
 
1005
    #
1006
    #   Use the verion of the branch that has been committed as the base of the
1007
    #   copy. If the user has modified files, then they won't be commited
1008
    #
1009
    #   This operation will be server-side only
1010
    #
1011
    Message ("Creating branch: $opt_branch");
1012
    my $repoLink = $uref->{InfoWs}{URL} . '@' . $uref->{InfoWs}{Revision};
1013
    $uref->{DEVBRANCH} =  join ('/', 'branches', $opt_branch);
1014
    my $branch_tag = $uref->SvnCopy (
1015
                'old' => $repoLink,
1016
                'new' => join ('/', $ws_url, $uref->{DEVBRANCH} ),
1017
                'comment' => $opt_comment ? $opt_comment : 'Created by Jats svn branch',
1018
                'replace' => 0,
1019
                );
1020
 
1021
    if ( $opt_switch )
1022
    {
1023
        Verbose ("Switching to new branch: $opt_branch");
1024
        $branch_tag = SvnPath2Url($branch_tag);
1025
        $uref->SvnSwitch ($branch_tag,
1026
                          $opt_path,
1027
                          '--Print' );
1028
    }
1029
    else
1030
    {
1031
        Warning ("Using existing workspace, not the created branch");
1032
    }
1033
    Message ("Repository Ref: " . $uref->RmRef);
1034
    Message ("Vcs Tag       : " . $uref->SvnTag);
1035
 
1036
#    #
1037
#    #   The copy operation *should* be a server side operation only
1038
#    #   If the user has commited changes, but not yet updated the local
1039
#    #   workspace, then subversion will do a client side copy
1040
#    #   This is not good.
1041
#    #
1042
#    $uref->SvnCopyWs (
1043
#                   target => join ('/', $ws_url, 'branches', $opt_branch),
1044
#                   'allowLocalMods' => 1,
1045
#                   'noupdatecheck' => 1,
1046
#                   'noswitch' => ! $opt_switch,
1047
#                   'replace' => 0,
1048
#                   'comment' => $opt_comment ? $opt_comment : 'Created by Jats svn branch',
1049
#                   );
1050
#
1051
#    Message ("Repository Ref: " . $uref->RmRef);
1052
#    Message ("Vcs Tag       : " . $uref->SvnTag);
1053
 
1054
    $opr_done = 1;
1055
}
1056
 
385 dpurdie 1057
#-------------------------------------------------------------------------------
2048 dpurdie 1058
# Function        : SwitchBranch
1059
#
1060
# Description     : Switch to a specified branch
1061
#
1062
# Inputs          :
1063
#
1064
# Returns         :
1065
#
1066
sub SwitchBranch
1067
{
1068
    my $opt_path = '.';
1069
    my $opt_branch;
1070
 
1071
    #
1072
    #   Parse more options
1073
    #
1074
    GetOptions (
1075
                "help:+"        => \$opt_help,
1076
                "manual:3"      => \$opt_help,
1077
                "path:s"        => \$opt_path,
1078
                ) || Error ("Invalid command line" );
1079
 
1080
    #
1081
    #   Subcommand specific help
1082
    #
1083
    SubCommandHelp( $opt_help, "Switch Branch") if ($opt_help);
1084
    return ShowBranches($opt_path) if ( $#ARGV < 0 );
1085
 
1086
    #
1087
    #   Sanity Tests
1088
    #
1089
    Error ("Too many arguments: @ARGV") if ( $#ARGV > 0 );
1090
 
1091
    #
1092
    #   Calculate the target name
1093
    #       trunk is special
1094
    #       tags/... is special
1095
    $opt_branch = $ARGV[0];
1096
    if ( $opt_branch eq 'trunk' ) {
1097
    } elsif ( $opt_branch =~ m~tags/.+~ ) {
1098
    } else {
1099
        $opt_branch = join ('/', 'branches', $opt_branch);
1100
    }
1101
    Message ("Switching to new branch: $opt_branch");
1102
 
1103
    #
1104
    #   Do all the hard work
1105
    #
1106
    my $uref = NewSessionByWS($opt_path, 0, 1);
1107
    my $ws_url = $uref->Full();
1108
    my $branch_tag = join ('/', $ws_url, $opt_branch);
1109
 
1110
    #
1111
    #   Validate the branch
1112
    #
1113
    $uref->SvnValidateTarget (
1114
                        'cmd'    => 'svn switch',
1115
                        'target' => $branch_tag,
1116
                        'require' => 1,
1117
                        );
1118
 
1119
    $uref->SvnSwitch ($branch_tag, $opt_path, '--Print' );
1120
    $opr_done = 1;
1121
}
1122
 
1123
#-------------------------------------------------------------------------------
1124
# Function        : ShowBranches
1125
#
1126
# Description     : Show branches in current workspace
1127
#                   Internal use only
1128
#
1129
# Inputs          : $opt_path           - Optional path
1130
#
1131
# Returns         :
1132
#
1133
sub ShowBranches
1134
{
1135
    my ($opt_path) = @_;
1136
 
1137
    my $uref = NewSessionByWS($opt_path, 0, 1);
1138
    my $ws_url = $uref->Full();
1139
 
1140
    #
1141
    #   Display the packages full URL - allow the user to manuallu look at more
1142
    #   List the bracnhes
1143
    #
1144
    Message ("Url: $ws_url", 'Available Branches');
1145
    SvnUserCmd( 'ls', join ('/', $ws_url, 'branches'), { 'credentials' => 1 });
1146
    $opr_done = 1;
1147
}
1148
#-------------------------------------------------------------------------------
311 dpurdie 1149
# Function        : SubCommandHelp
1150
#
1151
# Description     : Provide help on a subcommand
1152
#
1153
# Inputs          : $help_level             - Help Level 1,2,3
1154
#                   $topic                  - Topic Name
1155
#
1156
# Returns         : This function does not return
1157
#
1158
sub SubCommandHelp
1159
{
1160
    my ($help_level, $topic) = @_;
1161
    my @sections;
1162
    #
1163
    #   Spell out the section we want to display
1164
    #
1165
    #   Note:
1166
    #   Due to bug in pod2usage can't use 'head1' by itself
1167
    #   Each one needs a subsection.
1168
    #
1169
    push @sections, qw( NAME SYNOPSIS ) ;
1170
    push @sections, qw( ARGUMENTS OPTIONS ) if ( $help_level > 1 );
1171
    push @sections, qw( DESCRIPTION )       if ( $help_level > 2 );
1172
 
1173
    #
1174
    #   Extract section from the POD
1175
    #
1176
    pod2usage({-verbose => 99,
1177
               -noperldoc => 1,
1178
               -sections => $topic . '/' . join('|', @sections) } );
1179
}
1180
 
1181
#-------------------------------------------------------------------------------
1182
#   Documentation
1183
#   NOTE
1184
#
1185
#   Each subcommand MUST have
1186
#   head1 section as used by the subcommand
1187
#       This should be empty, as the contents will NOT be displayed
1188
#   head2 sections called
1189
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION
1190
#
1191
#=head1 xxxxxx
1192
#=head2 NAME
1193
#=head2 SYNOPSIS
1194
#=head2 ARGUMENTS
1195
#=head2 OPTIONS
1196
#=head2 DESCRIPTION
1197
#
1198
 
1199
=pod
1200
 
361 dpurdie 1201
=for htmltoc    GENERAL::Subversion::
1202
 
311 dpurdie 1203
=head1 NAME
1204
 
1205
jats svn - Miscellaneous SubVersion Operations
1206
 
1207
=head1 SYNOPSIS
1208
 
1209
jats svn [options] command [command options]
1210
 
1211
 Options:
1212
    -help[=n]              - Help message, [n=1,2,3]
1213
    -man                   - Full documentation [-help=3]
1214
    -verbose[=n]           - Verbose command operation
1215
 
1216
 Common Command Options:
1217
    All command support suboptions to provide command specific help
1218
 
1219
    -help[=n]              - Help message, [n=1,2,3]
1220
    -man                   - Full documentation [-help=3]
1221
 
1222
 Commands are:
363 dpurdie 1223
    test                   - Test access to subversion
369 dpurdie 1224
    paths                  - Display Subversion tag to URL conversions
311 dpurdie 1225
    ls URL                 - List Repo contents for URL
369 dpurdie 1226
    tag [URL]              - Convert URL or Path to a Release Manager Tag
1227
    url [TAG]              - Convert TAG or Path to a Subversion URL
2048 dpurdie 1228
    create-package URL     - Create a new package at URL
311 dpurdie 1229
    delete-package URL     - Delete Package Subtree
2048 dpurdie 1230
    branch BRANCH          - Create a Development Branch
1231
    switch [BRANCH]        - Switch to a Development Branch
385 dpurdie 1232
    delete-branch          - Delete a Development Branch
311 dpurdie 1233
    import URL             - Import files to package at URL
1234
 
1235
 Use the command
1236
    jats svn command -h
1237
 for command specific help
1238
 
1239
=head1 OPTIONS
1240
 
1241
=over
1242
 
1243
=item B<-help[=n]>
1244
 
1245
Print a help message and exit. The level of help may be either 1, 2 or
1246
3 for a full manual.
1247
 
1248
This option may be specified multiple times to increment the help level, or
1249
the help level may be directly specified as a number.
1250
 
1251
=item B<-man>
1252
 
1253
This is the same as '-help=3'.
1254
The complete help is produced in a man page format.
1255
 
1256
=item B<--verbose[=n]>
1257
 
1258
This option will increase the level of verbosity of the commands.
1259
 
1260
If an argument is provided, then it will be used to set the level, otherwise the
1261
existing level will be incremented. This option may be specified multiple times.
1262
 
1263
=back
1264
 
1265
=head1 DESCRIPTION
1266
 
1267
This program provides a number of useful Subversion based operations.
1268
 
363 dpurdie 1269
=head1 Test Subversion
1270
 
1271
=head2 NAME
1272
 
1273
Test Subversion
1274
 
1275
=head2 SYNOPSIS
1276
 
1277
    jats svn test
1278
 
1279
=head2 DESCRIPTION
1280
 
1281
This command will ensure that the subversion command line utility can be
1282
located. The command will report the version of the svn client found.
1283
 
369 dpurdie 1284
=head1 Subversion Paths
1285
 
1286
=head2 NAME
1287
 
1288
Subversion Paths
1289
 
1290
=head2 SYNOPSIS
1291
 
1292
    jats svn paths
1293
 
1294
=head2 DESCRIPTION
1295
 
1296
This command will display the base Tags and associated URLs that are used by
1297
JATS to convert a 'Subversion Tag' into a full URLs that will be used to access
1298
a physical repository.
1299
 
1300
The 'Tags' configuration is site-specific.
1301
 
311 dpurdie 1302
=head1 List Repository
1303
 
363 dpurdie 1304
=head2 NAME
1305
 
1306
List Repository
1307
 
1308
=head2 SYNOPSIS
1309
 
1310
    jats svn ls <URL>
1311
 
1312
=head2 DESCRIPTION
1313
 
311 dpurdie 1314
This command will take a URL and perform a 'svn' list operation. The URL will
1315
be expanded to include the site specific repository.
1316
 
369 dpurdie 1317
=head1 Url to Tag
1318
 
1319
=head2 NAME
1320
 
1321
Url to Tag
1322
 
1323
=head2 SYNOPSIS
1324
 
1325
    jats svn tag [Option] [tag]
1326
 
1327
 Options:
1328
    -help[=n]              - Help message, [n=1,2,3]
1329
    -man                   - Full documentation [-help=3]
1330
    -path=path             - Convert specified path
1331
    -url=url               - Convert specified URL
1332
 
1333
=head2 DESCRIPTION
1334
 
1335
This command will convert a URL or a PATH to a Subversion Tag that can
1336
be used within the remainder of the build system. If no PATH or URL is provided,
1337
then the command uses a path of the current directory.
1338
 
1339
The command will convert either a PATH or a URL. It will not do both.
1340
 
1341
The command will use the configured Subversion URL prefixes to create the Tag.
1342
 
1343
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1344
The conversion will return a Tag to the root of the Workspace and Peg it to
1345
the last committed version. The command will not determine if the workspace
1346
contains modified files.
1347
 
1348
If a URL is to be converted, then the resultant value should be used with
1349
caution. The result is only as good as the provided URL and may not address
1350
the root of a package.
1351
 
1352
=head1 Tag to Url
1353
 
1354
=head2 NAME
1355
 
1356
Tag to Url
1357
 
1358
=head2 SYNOPSIS
1359
 
1360
    jats svn url [Option] [url]
1361
 
1362
 Options:
1363
    -help[=n]              - Help message, [n=1,2,3]
1364
    -man                   - Full documentation [-help=3]
1365
    -path=path             - Convert specified path
1366
    -url=url               - Convert specified URL
1367
 
1368
=head2 DESCRIPTION
1369
 
1370
This command will convert a TAG or a PATH to a full URL that can be used
1371
directly by Subversion. If no PATH or TAG is provided, then the command uses a
1372
path of the current directory.
1373
 
1374
The command will convert either a TAG or a URL. It will not do both.
1375
 
1376
The command will use the configured Subversion URL prefixes to expand the TAG.
1377
 
1378
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1379
The conversion will return a URL to the root of the Workspace and Peg it to
1380
the last committed version. The command will not determine if the workspace
1381
contains modified files.
1382
 
1383
If a TAG is to be converted, then the resultant value should be used with
1384
caution. The result is only as good as the provided URL and may not address
1385
the root of a package.
1386
 
2048 dpurdie 1387
=head1 Create a Package Version
1388
 
1389
=head2 NAME
1390
 
1391
Create a Package Version
1392
 
1393
=head2 SYNOPSIS
1394
 
1395
jats svn [options] create-package URL [command options]
1396
 
1397
 Options:
1398
    -help[=n]               - Help message, [n=1,2,3]
1399
    -man                    - Full documentation [-help=3]
1400
    -verbose[=n]            - Verbose command operation
1401
 
1402
 Command Options
1403
    -help[=n]               - Provide command specific help
1404
    -new                    - Package must not exist
1405
    -replace                - Replace any existing versions
1406
    -import=nnn             - Import directory tree
1407
    -label=nnn              - Label imported package
1408
    -trunk                  - Import to trunk (default)
1409
    -tags=nnn               - Import to tags
1410
    -branch=nnn             - Import to branches
1411
 
1412
=head2 ARGUMENTS
1413
 
1414
The command takes one argument: The URL of the desired package.
1415
This may be be:
1416
 
1417
=over
1418
 
1419
=item * A full URL
1420
 
1421
Complete with protocol and path information.
1422
 
1423
=item * A simple URL
1424
 
1425
JATS will prepend the site-specific repository location to the user provided URL
1426
 
1427
=back
1428
 
1429
=head2 OPTIONS
1430
 
1431
=over
1432
 
1433
=item -help[=n]
1434
 
1435
Print a help message and exit. The level of help may be either 1, 2 or 3.
1436
 
1437
This option may be specified multiple times to increment the help level, or
1438
the help level may be directly specified as a number.
1439
 
1440
=item -new
1441
 
1442
This option specifies that the named package MUST not exist at all.
1443
 
1444
=item -replace
1445
 
1446
This option allows the program to replace any existing versions of the
1447
imported source. It will allow the deletion of any existing trunk, tags or
1448
branches.
1449
 
1450
=item -import=nnn
1451
 
1452
This option specifies the path of a subdirectory tree to import into the newly
1453
created package. In not provided, then only a package skeleton will be created.
1454
 
1455
=item -label=nnn
1456
 
1457
This option specifies a label to place the imported source.
1458
 
1459
=item -trunk
1460
 
1461
This option specifies that imported source will be placed on the trunk of the
1462
package. This is the default mode of import.
1463
 
1464
The options -trunk, -tags and -branch are mutually exclusive.
1465
 
1466
=item -tags=nnn
1467
 
1468
This option specifies that imported source will be placed directly on the
1469
named tag of the package.
1470
 
1471
The options -trunk, -tags and -branch are mutually exclusive.
1472
 
1473
=item -branch=nnn
1474
 
1475
This option specifies that imported source will be placed directly on the
1476
named branch of the package.
1477
 
1478
The options -trunk, -tags and -branch are mutually exclusive.
1479
 
1480
=back
1481
 
1482
=head2 DESCRIPTION
1483
 
1484
This command will create a new package within a repository. It will ensure
1485
that the package contains the three required subdirectories: trunk, tags and
1486
branches.
1487
 
1488
The command will also ensure that packages are not placed at inappropriate
1489
locations within the repository. It is not correct to place a package within
1490
another package.
1491
 
1492
The command will, optionally, import a directory tree into the repository and,
1493
optionally, label the package.
1494
 
1495
The package body may be imported to the 'trunk' or to a branch or a tag.
1496
By default the data will be imported to the trunk and may be labeled (tagged).
1497
 
1498
Options allow the targets to be deleted if they exist or to ensure that they
1499
are not present.
1500
 
1501
The command does not attempt to merge file versions within the repository. It
1502
may result in multiple instances of a file within the repository. Use only for
1503
simple imports. Use the 'import' command for more sophisticated import requirements.
1504
 
311 dpurdie 1505
=head1 Delete a Package
1506
 
1507
=head2 NAME
1508
 
1509
Delete a Package
1510
 
1511
=head2 SYNOPSIS
1512
 
1513
jats svn delete-package URL [options]
1514
 
1515
 Options:
1516
    -help[=n]              - Help message, [n=1,2,3]
1517
    -man                   - Full documentation [-help=3]
1518
    -verbose[=n]           - Verbose command operation
1519
 
1520
=head2 ARGUMENTS
1521
 
1522
The command takes one argument: The URL of the desired package.
1523
This may be be:
1524
 
1525
=over
1526
 
1527
=item * A full URL
1528
 
1529
Complete with protocol and path information.
1530
 
1531
=item * A simple URL
1532
 
1533
JATS will prepend the site-specific repository location to the user provided URL
1534
 
1535
=back
1536
 
1537
=head2 OPTIONS
1538
 
1539
This command has no significant options, other than the general help options.
1540
 
1541
=head2 DESCRIPTION
1542
 
1543
This command will delete a package from the repository. It will ensure
1544
that the package is a valid package, before it is deleted.
1545
 
1546
The command is intended to be used by test scripts, rather than users.
1547
 
2048 dpurdie 1548
=head1 Create Branch
385 dpurdie 1549
 
1550
=head2 NAME
1551
 
2048 dpurdie 1552
Create a Workspace Branch
385 dpurdie 1553
 
1554
=head2 SYNOPSIS
1555
 
2048 dpurdie 1556
jats svn branch branch-name [options]
385 dpurdie 1557
 
1558
 Options:
1559
    -help[=n]              - Help message, [n=1,2,3]
1560
    -man                   - Full documentation [-help=3]
1561
    -verbose[=n]           - Verbose command operation
1562
    -path=path             - Target workspace
2048 dpurdie 1563
    -[no]switch            - Switch to new branch(default)
1564
    -comment=text          - Comment to apply to the new branch
385 dpurdie 1565
 
1566
=head2 ARGUMENTS
1567
 
2048 dpurdie 1568
The command takes one argument. The name of the branch to be created.
385 dpurdie 1569
 
1570
=head2 OPTIONS
1571
 
1572
=over
1573
 
1574
=item B<-path=path>
1575
 
1576
This options specifies the path of the target workspace. If not provided the
1577
command will use the current directory.
1578
 
2048 dpurdie 1579
=item B<-[no]switch>
1580
 
1581
If enabled (the default) the workspace will be switched to the new branch at
1582
the end of the process.
1583
 
1584
=item B<-comment=text>
1585
 
1586
If present, the specified text will be used as a Subversion comment when the
1587
branch is created.
1588
 
1589
If not provided, then JATS will provide a basic comment.
1590
 
385 dpurdie 1591
=back
1592
 
1593
=head2 DESCRIPTION
1594
 
2048 dpurdie 1595
This command will create a named branch associated with the workspace in the
1596
specified path. It is intended to simplify the creation of Private or
385 dpurdie 1597
Development branches.
1598
 
2048 dpurdie 1599
If the named branch already exists, then the command will fail.
385 dpurdie 1600
 
2048 dpurdie 1601
The command performs a server-side copy. It will not commit any locally
1602
modified files. Nor will it inform you if there are any.
311 dpurdie 1603
 
2048 dpurdie 1604
By default, the user is 'switched' to the newly created branch.
1605
 
1606
=head1 Switch Branch
1607
 
311 dpurdie 1608
=head2 NAME
1609
 
2048 dpurdie 1610
Switch a Workspace Branch
311 dpurdie 1611
 
1612
=head2 SYNOPSIS
1613
 
2048 dpurdie 1614
jats svn switch [branch-name] [options]
311 dpurdie 1615
 
1616
 Options:
2048 dpurdie 1617
    -help[=n]              - Help message, [n=1,2,3]
1618
    -man                   - Full documentation [-help=3]
1619
    -verbose[=n]           - Verbose command operation
1620
    -path=path             - Target workspace
311 dpurdie 1621
 
1622
=head2 ARGUMENTS
1623
 
2048 dpurdie 1624
The command takes one optional argument. The name of the target branch.
311 dpurdie 1625
 
2048 dpurdie 1626
=head2 OPTIONS
1627
 
311 dpurdie 1628
=over
1629
 
2048 dpurdie 1630
=item B<-path=path>
311 dpurdie 1631
 
2048 dpurdie 1632
This options specifies the path of the target workspace. If not provided the
1633
command will use the current directory.
311 dpurdie 1634
 
2048 dpurdie 1635
=back
311 dpurdie 1636
 
2048 dpurdie 1637
=head2 DESCRIPTION
311 dpurdie 1638
 
2048 dpurdie 1639
This command will switch the users workspace to the named branch. This is
1640
identical to the Subversion switch command, except it is easier to user and
1641
has several validity checks and other enhancements.
311 dpurdie 1642
 
2048 dpurdie 1643
The command has two modes of operation:
311 dpurdie 1644
 
2048 dpurdie 1645
=over 4
311 dpurdie 1646
 
2048 dpurdie 1647
=item   1. Display a list of branched in the current package.
311 dpurdie 1648
 
2048 dpurdie 1649
If no branch is specified, then the utility will display a list of branches in
1650
the packages 'branches' directory.
311 dpurdie 1651
 
2048 dpurdie 1652
=item   2. Switch to the named branch.
311 dpurdie 1653
 
2048 dpurdie 1654
The named branch must exists otherwise the command will fail.
311 dpurdie 1655
 
2048 dpurdie 1656
There are two spcial variants of the branch name:
311 dpurdie 1657
 
2048 dpurdie 1658
=over 4
311 dpurdie 1659
 
2048 dpurdie 1660
=item trunk
311 dpurdie 1661
 
2048 dpurdie 1662
If the branch is named 'trunk' then it will refer to the packages truck
1356 dpurdie 1663
 
2048 dpurdie 1664
=item tags
1356 dpurdie 1665
 
2048 dpurdie 1666
If the branch name starts with 'tags/', then the command will refer to
1667
a tag within the package and not a branch.
1356 dpurdie 1668
 
2048 dpurdie 1669
=back
1356 dpurdie 1670
 
2048 dpurdie 1671
The command will add and remove unmodified files from the workspace during this
1672
operation.
311 dpurdie 1673
 
2048 dpurdie 1674
=back
311 dpurdie 1675
 
2048 dpurdie 1676
=head3 Examples
311 dpurdie 1677
 
2048 dpurdie 1678
To switch to the packages trunk
311 dpurdie 1679
 
2048 dpurdie 1680
    jats svn switch trunk
311 dpurdie 1681
 
2048 dpurdie 1682
To switch to the a branch called MyBranch
311 dpurdie 1683
 
2048 dpurdie 1684
    jats svn switch MyBranch
311 dpurdie 1685
 
2048 dpurdie 1686
To switch to a tagged version of the package
311 dpurdie 1687
 
2048 dpurdie 1688
    jats svn switch tags/MyPackage_1.0.0000.cr
311 dpurdie 1689
 
2048 dpurdie 1690
To display a list of available branches (not tags)
311 dpurdie 1691
 
2048 dpurdie 1692
    jats svn switch
311 dpurdie 1693
 
2048 dpurdie 1694
=head1 Delete Branch
311 dpurdie 1695
 
2048 dpurdie 1696
=head2 NAME
311 dpurdie 1697
 
2048 dpurdie 1698
Delete the Workspace Branch
311 dpurdie 1699
 
2048 dpurdie 1700
=head2 SYNOPSIS
311 dpurdie 1701
 
2048 dpurdie 1702
jats svn delete-branch [options]
311 dpurdie 1703
 
2048 dpurdie 1704
 Options:
1705
    -help[=n]              - Help message, [n=1,2,3]
1706
    -man                   - Full documentation [-help=3]
1707
    -verbose[=n]           - Verbose command operation
1708
    -path=path             - Target workspace
311 dpurdie 1709
 
2048 dpurdie 1710
=head2 ARGUMENTS
1711
 
1712
The command takes no arguments.
1713
 
1714
=head2 OPTIONS
1715
 
1716
=over
1717
 
1718
=item B<-path=path>
1719
 
1720
This options specifies the path of the target workspace. If not provided the
1721
command will use the current directory.
1722
 
1723
=back
1724
 
1725
=head2 DESCRIPTION
1726
 
1727
This command will delete the branch associated with the workspace in the
1728
specified path. It is intended to simplify the deletion of Private or
1729
Development branches.
1730
 
1731
If the workspace is not linked to a 'branch' then the command will fail.
1732
 
311 dpurdie 1733
=head1 Import directory to a Package
1734
 
1735
=head2 NAME
1736
 
1737
Import directory to a Package
1738
 
1739
=head2 SYNOPSIS
1740
 
1741
jats svn [options] import URL [command options]
1742
 
1743
 Options:
1744
    -help[=n]               - Help message, [n=1,2,3]
1745
    -man                    - Full documentation [-help=3]
1746
    -verbose[=n]            - Verbose command operation
1747
 
1748
 Command Options
1749
    -help[=n]               - Command specific help, [n=1,2,3]
1750
    -verbose[=n]            - Verbose operation
1751
    -package=name           - Name of source package
1752
    -dir=path               - Path to new version
379 dpurdie 1753
    -label=label            - Label the result
1754
    -branch=branchName      - Base import on a branch
311 dpurdie 1755
    -replace                - Allow the label to be replaced
1756
    -reuse                  - Reuse the import directory
1757
    -workspace=path         - Path and name of alternate workspace
1758
    -[no]delete             - Deletes workspace after use. Default:yes
379 dpurdie 1759
    -author=name            - Force author of changes
1760
    -date=dateString        - Force date of changes
1761
    -log=text               - Append text to the commit message
1762
    -datafile=path          - Export tag data for automation
311 dpurdie 1763
 
1764
=head2 ARGUMENTS
1765
 
1766
The command takes one argument: The URL of the desired package.
1767
This may be be:
1768
 
1769
=over
1770
 
1771
=item * A full URL
1772
 
1773
Complete with protocol and path information.
1774
 
1775
=item * A simple URL
1776
 
1777
JATS will prepend the site-specific repository location to the user provided URL
1778
 
1779
=back
1780
 
1781
=head2 OPTIONS
1782
 
1783
=over
1784
 
1785
=item -help[=n]
1786
 
1787
Print a help message and exit. The level of help may be either 1, 2 or 3.
1788
 
1789
This option may be specified multiple times to increment the help level, or
1790
the help level may be directly specified as a number.
1791
 
1792
=item -verbose[=n]
1793
 
1794
This option will increase the level of verbosity of the utility.
1795
 
1796
If an argument is provided, then it will be used to set the level, otherwise the
1797
existing level will be incremented. This option may be specified multiple times.
1798
 
1799
=item -package=name
1800
 
1801
Either this option or a bare URL on the command line must be provided. It
1802
specifies the repository and package to be used as a basis for the work.
1803
 
1804
=item -dir=path
1805
 
1806
This option is mandatory. It specifies the path to a local directory that
1807
contains a version of the software to be checked in.
1808
 
1809
=item -label=name
1810
 
1811
The resulting software version will be labeled with this tag, if it is provided.
1812
 
383 dpurdie 1813
A label name of TIMESTAMP will be treated in special manner. The name will be
1814
replaced with a unique name based on the users name and the current date time.
1815
 
379 dpurdie 1816
=item -branch=branchName
1817
 
1818
This option will cause the importation to be referenced to the named branch.
1819
If the branch does not exist it will be created. If it does exist then it will
1820
be used.
1821
 
1822
If this option is not specified, then the importation will be based on the 'trunk'.
1823
 
1824
If the Workspace is provided, then it will be used independently of this option.
1825
 
383 dpurdie 1826
A branchName of TIMESTAMP will be treated in special manner. The name will be
1827
replaced with a unique name based on the users name and the current date time.
1828
 
311 dpurdie 1829
=item -replace
1830
 
1831
This option, if provided, allows the label to be replaced.
1832
 
1833
=item -reuse
1834
 
1835
This option can be used to speed the creation of multiple versions in a scripted
1836
environment. The option allows the utility to reuse the workspace if it exists.
1837
 
1838
=item -workspace=path
1839
 
1840
This option specifies an alternate workspace directory to create and use. The
1841
default directory is "SvnImportDir" within the users current directory.
1842
 
1843
=item [no]delete
1844
 
341 dpurdie 1845
This option control the deletion of the workspace directory. By default the
311 dpurdie 1846
directory will be deleted, unless re-use is also used.
1847
 
379 dpurdie 1848
=item -author=name
1849
 
1850
This option will force the author of changes as recorded in the repository.
385 dpurdie 1851
The repository must be configured to allow such changes.
379 dpurdie 1852
 
1853
This option may not work for non-admin users.
1854
 
1855
=item -date=dateString
1856
 
1857
This option will force the date of the changes as recorded in the repository.
385 dpurdie 1858
The repository must be configured to allow such changes.
379 dpurdie 1859
The dateString is in a restricted ISO 8601 format: ie 2009-02-12T00:44:04.921324Z
1860
 
1861
This option may not work for non-admin users.
1862
 
1863
=item -log=text
1864
 
1865
This option will append the specified text to the commit message.
1866
The first line of the commit message is fixed by the import tool.
1867
 
1868
=item -datafile=path
1869
 
1870
This option will cause the utility to create a data file to record the import
1871
tag. It is used for automation of the import process.
1872
 
311 dpurdie 1873
=back
1874
 
1875
=head2 DESCRIPTION
1876
 
1877
Import a new version of a package to the trunk of the package. The utility
1878
will only import changed files so that file history is preserved within the
1879
repository.
1880
 
1881
This utility is used import software from another version control system
1882
The utility will:
1883
 
1884
=over
1885
 
361 dpurdie 1886
=item *
311 dpurdie 1887
 
361 dpurdie 1888
Create a Work Space based on the current package version
1889
 
379 dpurdie 1890
The 'trunk' of the named package will be used as the base for the workspace,
1891
unless modified with the -branch option.
311 dpurdie 1892
 
361 dpurdie 1893
=item *
311 dpurdie 1894
 
361 dpurdie 1895
Update files and directories
1896
 
311 dpurdie 1897
Determines the files and directories that have been added and deleted and
1898
update the Workspace to reflect the new structure.
1899
 
361 dpurdie 1900
=item *
311 dpurdie 1901
 
361 dpurdie 1902
Check in the new version
311 dpurdie 1903
 
361 dpurdie 1904
=item *
1905
 
1906
Label the new version
1907
 
311 dpurdie 1908
=back
1909
 
1910
=cut
1911