Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
311 dpurdie 1
########################################################################
7300 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
311 dpurdie 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/ );
2049 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
#
2049 dpurdie 110
# Inputs          :
369 dpurdie 111
#
2049 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
 
1403 dpurdie 208
    Message ("Tag is  : " . $uref->RmRef() );
209
    Message ("Vcs Tag : " . $uref->SvnTag  );
2049 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
    {
2429 dpurdie 268
        my $path = $opt_tag;
269
        my $label;
270
 
271
        $path =~ s~^SVN::~~;
272
        if ( $path =~ m~(.+)::(.+)~ )
273
        {
274
            $path = $1;
275
            $label = $2;
276
        }
277
        $url = SvnPath2Url($path);
278
        if ( $label && $label =~ m~^\d+$~ )
279
        {
280
            $url .= '@' . $label;
281
        }
282
        elsif ( $label )
283
        {
284
            $url =~ m~(.+)(/(tags|branches|trunk)(/|$|@))~;
285
            $url = $1 . '/tags/'. $label;
286
        }
369 dpurdie 287
    }
288
    else
289
    {
290
        $uref = NewSessionByWS($opt_path, 0, 1);
291
        my $ws_root = $uref->SvnLocateWsRoot(1);
292
        $url = $uref->FullWsRev();
293
    }
294
 
295
    Message ("Url: $url");
296
    $opr_done = 1;
297
}
298
 
299
#-------------------------------------------------------------------------------
363 dpurdie 300
# Function        : TestSvn
301
#
302
# Description     : Test access to subversion
303
#
304
# Inputs          : None
305
#
306
# Returns         :
307
#
308
sub TestSvn
309
{
310
    #
311
    #   Parse more options
312
    #
313
    GetOptions (
314
                "help:+"        => \$opt_help,
315
                "manual:3"      => \$opt_help,
316
                ) || Error ("Invalid command line" );
317
 
318
    #
319
    #   Subcommand specific help
320
    #
321
    SubCommandHelp( $opt_help, "Test Subversion") if ($opt_help || $#ARGV >= 0);
322
 
323
    SvnUserCmd( '--version');
324
    $opr_done = 1;
325
}
326
#-------------------------------------------------------------------------------
311 dpurdie 327
# Function        : SvnRepoCmd
328
#
329
# Description     : Execute a SVN command, where the first argument
330
#                   is a repository specifier
331
#
332
# Inputs          : $cmd
333
#                   $repo_url
334
#                   @opts
335
#
2049 dpurdie 336
# Returns         :
311 dpurdie 337
#
338
sub SvnRepoCmd
339
{
340
    my ( $cmd, $repo_url, @opts ) = @_;
341
    my $uref = NewSessionByUrl ( $repo_url );
342
 
343
    SvnUserCmd( $cmd,
344
            $uref->Full,
345
            @opts,
346
            { 'credentials' => 1 });
2049 dpurdie 347
 
311 dpurdie 348
    $opr_done = 1;
349
}
350
 
351
#-------------------------------------------------------------------------------
352
# Function        : DeletePackage
353
#
354
# Description     : Delete a Package structure within a Repository
355
#                   Intended for test usage
356
#
357
# Inputs          : URL                 - Url to Repo + Package Base
358
#
2049 dpurdie 359
# Returns         :
311 dpurdie 360
#
361
sub DeletePackage
362
{
379 dpurdie 363
    my $opt_error = 0;
311 dpurdie 364
    #
365
    #   Parse more options
366
    #
367
    GetOptions (
368
                "help:+"        => \$opt_help,
369
                "manual:3"      => \$opt_help,
379 dpurdie 370
                "error!"       => \$opt_error,
311 dpurdie 371
                ) || Error ("Invalid command line" );
372
 
373
    #
374
    #   Subcommand specific help
375
    #
376
    SubCommandHelp( $opt_help, "Delete a Package") if ($opt_help || $#ARGV < 0);
377
 
378
    #
379
    #   Sanity Tests
380
    #
381
    Message ("Delete Entire Package Tree" );
382
    Warning ("Too many arguments: @ARGV") if ( $#ARGV >= 1 );
383
 
384
    #
385
    #   Do all the hard work
386
    #       Create
387
    #       Import
388
    #       Label
389
    #
390
    my $uref = NewSessionByUrl ( $ARGV[0] );
379 dpurdie 391
    $uref->SvnValidatePackageRoot(!$opt_error);
311 dpurdie 392
    $uref->SvnDelete (
393
                      'target'      => $uref->Full,
385 dpurdie 394
                      'comment'   => [$uref->Path().": Delete Package",'Deleted by user command: jats svn delete-package'],
379 dpurdie 395
                      'noerror'   => !$opt_error,
311 dpurdie 396
                      );
397
    $opr_done = 1;
398
}
399
 
400
#-------------------------------------------------------------------------------
401
# Function        : CreatePackage
402
#
403
# Description     : Create a Package structure within a Repository
404
#                   Optionally Import Data
405
#                   Optionally Tag the import
406
#                   Optionally Tag the import on a branch
407
#
408
# Inputs          : URL                 - Url to Repo + Package Base
409
#                   Options             - Command modifiers
410
#                       -import=path    - Import named directory
411
#                       -label=name     - Label the result
412
#                       -tag=name       - Import to Tag Only
413
#                       -branch=name    - Import to Branch only
414
#                       -new            - Must be new package
415
#                       -replace        - Replace existing
416
#
2049 dpurdie 417
# Returns         :
311 dpurdie 418
#
419
sub CreatePackage
420
{
421
    my $opt_import;
422
    my $opt_tag;
423
    my $opt_branch;
424
    my $opt_trunk;
425
    my $opt_new;
426
    my $opt_label;
427
    my $opt_replace;
428
    my $pname;
429
    my $type;
385 dpurdie 430
    my $opt_author;
431
    my $opt_date;
311 dpurdie 432
    Message ("Create New Package Version" );
433
 
434
    #
435
    #   Parse more options
436
    #
437
    GetOptions (
438
                "help:+"        => \$opt_help,
439
                "manual:3"      => \$opt_help,
440
                "verbose:+"     => \$opt_verbose,
441
                "import=s"      => \$opt_import,
442
                "new"           => \$opt_new,
443
                "branch=s"      => \$opt_branch,
444
                "trunk"         => \$opt_trunk,
1403 dpurdie 445
                "tags=s"        => \$opt_tag,
311 dpurdie 446
                "label=s"       => \$opt_label,
447
                "replace"       => \$opt_replace,
385 dpurdie 448
                'author=s'      => \$opt_author,
449
                'date=s'        => \$opt_date,
311 dpurdie 450
 
451
                ) || Error ("Invalid command line" );
452
 
453
    #
454
    #   Subcommand specific help
455
    #
456
    SubCommandHelp( $opt_help, "Create a Package Version") if ($opt_help || $#ARGV < 0);
2049 dpurdie 457
 
311 dpurdie 458
    #
369 dpurdie 459
    #   Alter the error reporting parameters
311 dpurdie 460
    #
461
    ErrorConfig( 'verbose' => $opt_verbose );
462
 
463
    #
464
    #   Sanity Tests
465
    #
466
    my $count = 0;
467
    $count++ if ( $opt_trunk );
468
    $count++ if ( $opt_branch );
469
    $count++ if ( $opt_tag );
470
    Error ("Conflicting options: -trunk, -tag, -branch") if ( $count > 1 );
471
    Error ("Nothing imported to be labeled") if ( $count && !$opt_import );
472
    Error ("Import path does not exist: $opt_import") if ( $opt_import && ! -d $opt_import );
473
    Error ("Conflicting options: new and replace") if ( $opt_new && $opt_replace );
385 dpurdie 474
    Error ("Too many command line arguments") if ( exists $ARGV[1] );
311 dpurdie 475
 
1403 dpurdie 476
    $type = 'tags/' . $opt_tag          if ( $opt_tag);
477
    $type = 'branches/' . $opt_branch   if ( $opt_branch );
478
    $type = 'trunk'                     if ( $opt_trunk);
311 dpurdie 479
 
480
    #
481
    #   Do all the hard work
482
    #       Create
483
    #       Import
484
    #       Label
485
    #
486
    my $uref = NewSessionByUrl ( $ARGV[0] );
487
    $uref->SvnCreatePackage (
488
                      'import'  => $opt_import,
489
                      'label'   => $opt_label,
490
                      'type'    => $type,
491
                      'new'     => $opt_new,
492
                      'replace' => $opt_replace,
493
                      );
385 dpurdie 494
    #
495
    # Report RmPath as using a pegged version of a new package is a bit silly
496
    #
1403 dpurdie 497
#    Message ("Repository Ref: " . $uref->RmPath);
498
#    Message ("Vcs Tag       : " . $uref->SvnTag);
1329 dpurdie 499
    if ( $uref->{REVNO} )
500
    {
501
        $uref->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
502
        $uref->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
503
    }
311 dpurdie 504
    $opr_done = 1;
505
}
506
 
507
#-------------------------------------------------------------------------------
508
# Function        : ImportPackage
509
#
510
# Description     : Import a new version of a package
511
#                   Take great care to reuse file-versions that are already in
512
#                   the  package
513
#
369 dpurdie 514
#                   Intended to allow the importation of multiple
311 dpurdie 515
#                   versions of a package
516
#
2049 dpurdie 517
# Inputs          :
311 dpurdie 518
#
2049 dpurdie 519
# Returns         :
311 dpurdie 520
#
521
sub ImportPackage
522
{
523
    Message ("Import Package Version" );
524
 
525
    #
526
    #   Options
527
    #
528
    my $opt_package;
529
    my $opt_dir;
530
    my $opt_label;
531
    my $opt_replace = 0;
532
    my $opt_reuse;
533
    my $opt_workdir = "SvnImportDir";
534
    my $opt_delete = 1;
379 dpurdie 535
    my $opt_author;
536
    my $opt_date;
537
    my $opt_log = '';
538
    my $opt_branch;
539
    my $opt_datafile;
1403 dpurdie 540
    my $opt_printfiles;
2429 dpurdie 541
    my $opt_commit = 1;
2764 dpurdie 542
    my $opt_mergePaths;
311 dpurdie 543
 
544
    #
545
    #   Other globals
546
    #
547
    my $url_label;
379 dpurdie 548
    my $url_branch;
311 dpurdie 549
 
2764 dpurdie 550
    my $filesBase = 0;                  # Files in Base workspace
551
    my $filesDeleted = 0;               # Files Deleted
552
    my $filesAdded = 0;                 # Files Added
553
    my $filesTransferred = 0;           # Files Copied
554
    my $dirsDeleted = 0;                # Directories Deleted
555
    my $dirsAdded = 0;                  # Directories Added
556
    my $dirsTransferred = 0;            # Directories Copied
557
 
558
 
311 dpurdie 559
    #
560
    #   Configuration options
561
    #
562
    my $result = GetOptions (
379 dpurdie 563
                    'help:+'        => \$opt_help,
564
                    'manual:3'      => \$opt_help,
565
                    'verbose:+'     => \$opt_verbose,
566
                    'package=s'     => \$opt_package,
567
                    'dir=s'         => \$opt_dir,
568
                    'label=s'       => \$opt_label,
569
                    'branch=s'      => \$opt_branch,
570
                    'replace'       => \$opt_replace,
571
                    'reuse'         => \$opt_reuse,
572
                    'workspace=s'   => \$opt_workdir,
573
                    'delete!'       => \$opt_delete,
1403 dpurdie 574
                    'printfiles=i'  => \$opt_printfiles,
379 dpurdie 575
                    'author=s'      => \$opt_author,
576
                    'date=s'        => \$opt_date,
577
                    'log=s'         => \$opt_log,
578
                    'datafile=s'    => \$opt_datafile,
2429 dpurdie 579
                    'commit!'       => \$opt_commit,
2764 dpurdie 580
                    'mergePaths=s'  => \$opt_mergePaths,
311 dpurdie 581
 
582
                    #
583
                    #   Update documentation at the end of the file
584
                    #
585
                    ) || Error ("Invalid command line" );
586
 
587
    #
588
    #   Insert defaults
341 dpurdie 589
    #   User can specify base package via -package or a non-options argument
311 dpurdie 590
    #
591
    $opt_package = $ARGV[0] unless ( $opt_package );
379 dpurdie 592
    unlink $opt_datafile if ( defined $opt_datafile );
2049 dpurdie 593
 
311 dpurdie 594
    #
595
    #   Subcommand specific help
596
    #
597
    SubCommandHelp( $opt_help, "Import directory to a Package")
598
        if ($opt_help || ! $opt_package );
599
 
600
    #
369 dpurdie 601
    #   Alter the error reporting parameters
311 dpurdie 602
    #
603
    ErrorConfig( 'verbose' => $opt_verbose );
604
 
605
    #
606
    #   Configure the error reporting process now that we have the user options
607
    #
608
    Error ("No package URL specified") unless ( $opt_package );
609
    Error ("No base directory specified") unless ( $opt_dir );
610
    Error ("Invalid base directory: $opt_dir") unless ( -d $opt_dir );
2429 dpurdie 611
    Error ("Cannot label if not committing") if ( $opt_label && ! $opt_commit );
311 dpurdie 612
 
613
    #
614
    #   Create an SVN session
615
    #
616
    my $svn = NewSessionByUrl ( $opt_package );
617
 
618
    #
619
    #   Ensure that the required label is available
620
    #
621
    if ( $opt_label )
622
    {
623
        $opt_label = SvnIsaSimpleLabel ($opt_label);
624
        $url_label = $svn->BranchName( $opt_label, 'tags' );
625
        $svn->SvnValidateTarget (
626
                        'target' => $url_label,
627
                        'available' => 1,
628
                        ) unless ( $opt_replace );
629
    }
630
 
631
    #
379 dpurdie 632
    #   Validate the required branch
633
    #   It will be created if it doesn't exist
634
    #
635
    if ( $opt_branch )
636
    {
637
        $opt_branch = SvnIsaSimpleLabel($opt_branch);
638
        $url_branch = $svn->BranchName( $opt_branch, 'branches' );
385 dpurdie 639
        my $rv = $svn->SvnValidateTarget (
640
                        'cmd'    => 'SvnImporter. Create branch',
379 dpurdie 641
                        'target' => $url_branch,
642
                        'create' => 1,
643
                        );
385 dpurdie 644
        if ( $rv == 2 )
645
        {
646
            $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
647
            $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
648
        }
379 dpurdie 649
    }
650
 
651
    #
311 dpurdie 652
    #   Create a workspace based on the users package
653
    #   Allow the workspace to be reused to speed up multiple
654
    #   operations
655
    #
656
    unless ( $opt_reuse && -d $opt_workdir )
657
    {
658
        Message ("Creating Workspace");
659
        rmtree( $opt_workdir );
660
 
661
        $svn->SvnValidatePackageRoot ();
662
        #DebugDumpData( 'Svn', $svn );
663
        $svn->SvnValidateTarget (
664
                            'cmd'    => 'SvnImporter',
665
                            'target' => $svn->Full,
666
                            'require' => 1,
667
                            );
668
 
379 dpurdie 669
        my $url_co = $opt_branch ? $url_branch : $svn->Full . '/trunk';
1403 dpurdie 670
        $svn->SvnCo ( $url_co, $opt_workdir, 'print' => $opt_printfiles );
311 dpurdie 671
        Error ("Cannot locate the created Workspace")
672
            unless ( -d $opt_workdir );
673
    }
674
    else
675
    {
676
        Message ("Reusing Workspace");
677
    }
2049 dpurdie 678
 
311 dpurdie 679
    #
680
    #   Determine differences between the two folders
681
    #       Create structures for each directory
682
    #
683
    Message ("Determine Files in packages");
684
 
685
    my $search = JatsLocateFiles->new("--Recurse=1",
686
                                       "--DirsToo",
687
                                       "--FilterOutRe=/\.svn/",
688
                                       "--FilterOutRe=/\.svn\$",
689
                                       "--FilterOutRe=^/${opt_workdir}\$",
690
                                       "--FilterOutRe=^/${opt_workdir}/",
691
                                       );
692
    my @ws = $search->search($opt_workdir);
693
    my @dir = $search->search($opt_dir);
694
 
1329 dpurdie 695
    #
696
    #   Scan for a source file
697
    #   Trying to detect empty views
698
    #   Look for file, not directory
2764 dpurdie 699
    #       Keep a count for reporting
1329 dpurdie 700
    #
701
    {
2764 dpurdie 702
        foreach ( @ws )
703
        {
704
            $filesBase++ unless ( m~/$~ );
705
        }
706
 
1329 dpurdie 707
        my $fileFound = 0;
708
        foreach ( @dir )
709
        {
710
            next if ( m~/$~ );
2764 dpurdie 711
            $fileFound = 1;
1329 dpurdie 712
            last;
713
        }
714
 
715
        unless ( $fileFound )
716
        {
717
            Warning ("No source files found in source view");
718
            $opr_done = 1;
719
            return;
720
        }
721
    }
722
 
311 dpurdie 723
    #Information ("WS Results", @ws);
724
    #Information ("DIR Results", @dir);
1329 dpurdie 725
    #Information ("WS Results: ", scalar @ws);
726
    #Information ("DIR Results:", scalar @dir);
311 dpurdie 727
 
4086 dpurdie 728
 
311 dpurdie 729
    #
730
    #   Create a hash the Workspace and the User dir
731
    #   The key will be file names
732
    #
733
    my %ws;  map ( $ws{$_} = 1 , @ws );
734
    my %dir; map ( $dir{$_} = 1 , @dir );
735
 
736
    #
4086 dpurdie 737
    #   Create hash of paths to persist
738
    #       build/*   -> Persist directory. Keep dir tree if not
739
    #                    being imported, otherwise delete.
740
    #
741
    my %persistPaths;
742
    if ( $opt_mergePaths )
743
    {
744
        foreach ( split(',', $opt_mergePaths) )
745
        {
746
            if ( m~(.+/)\*$~ )
747
            {
748
                my $base = $1;
749
                $persistPaths{$base} = 1 unless( exists $dir{$base});
750
            }
751
        }
752
        Verbose0("Persist Paths:" , sort keys %persistPaths);
753
    }
754
 
755
    #
311 dpurdie 756
    #   Create a hash of common elements
757
    #   Removing then from the other two
758
    #
759
    my %common;
760
    foreach ( keys %ws )
761
    {
762
        next unless ( exists $dir{$_} );
763
        $common{$_} = 1;
764
        delete $ws{$_};
765
        delete $dir{$_};
766
    }
767
 
2764 dpurdie 768
    #
769
    #   Now have:
770
    #       %ws     - Hash of paths that are only in the Workspace
771
    #       %dir    - Hash of paths that are only in New Import
772
    #       %common - Hash of paths that are common to both
773
    #
311 dpurdie 774
    #DebugDumpData( 'WS', \%ws );
775
    #DebugDumpData( 'DIR', \%dir );
776
    #DebugDumpData( 'COMMON', \%common );
777
 
2764 dpurdie 778
 
311 dpurdie 779
    #
379 dpurdie 780
    #   Need to consider the case where a file has been replaced with a directory
781
    #   and visa-versa. Delete files and directories first.
782
    #
783
    #
784
    #   Remove files
785
    #   Sort in reverse. This will ensure that we process directory
786
    #   contents before directories
787
    #
2764 dpurdie 788
 
379 dpurdie 789
    my @rm_files = reverse sort keys %ws;
790
    if ( @rm_files )
791
    {
2764 dpurdie 792
        #
793
        #   Calculate new top level paths
794
        #   These are of the form xxxxx/
795
        #
796
        my @newTldPaths;
797
        if ( $opt_mergePaths )
798
        {
4086 dpurdie 799
            foreach (@rm_files)
2764 dpurdie 800
            {
801
                push (@newTldPaths, $1 ) if ( m~^([^/]+)/$~ );
802
            }
803
        }
804
 
805
        my @processedFiles;
379 dpurdie 806
        foreach my $file ( @rm_files  )
807
        {
2764 dpurdie 808
            #
809
            #   Detect items that are to be retained
810
            #   Do not delete items that are a part of a top level path that
3347 dpurdie 811
            #   are not present in the New Import
2764 dpurdie 812
            #
813
            if ( $opt_mergePaths )
814
            {
815
                my $keep = 0;
4086 dpurdie 816
                ##
817
                ##  Following removed because it did the wrong thing and I'm not too sure
818
                ##  under what conditions its needed.
819
                ##  It did the wrong thing when used with '++,XXXX/**'
820
                ##  Perhaps its only these that cause problems
821
 
822
                ##
823
                ##foreach ( @newTldPaths )
824
                ##{
825
                ##    if ( $file =~ m~^$_/~ )
826
                ##    {
827
                ##        Verbose("Merge Retain(0): $file, $_");
828
                ##        $keep = 1;
829
                ##        last;
830
                ##    }
831
                ##}
832
 
833
                if ( $file =~ m~(^.*/)~ )
2764 dpurdie 834
                {
4086 dpurdie 835
                    my $tpath = $1;
836
                    foreach ( keys %persistPaths)
2764 dpurdie 837
                    {
4086 dpurdie 838
                        if ( $file =~ m~^$_~ )
839
                        {
840
                            Verbose0("Merge Retain(1): $file");
841
                            $keep = 1;
842
                            last;
843
                        }
2764 dpurdie 844
                    }
845
                }
3347 dpurdie 846
 
847
                #
848
                #   Examine $opt_mergPaths and process entries that look like
849
                #       build/**  -> keep the directory and every think under it
4086 dpurdie 850
                #       build/*   -> Persist directory. Keep dir tree if not
851
                #                    being imported, otherwise delete.
3347 dpurdie 852
                #
853
                foreach ( split(',', $opt_mergePaths) )
854
                {
855
                    if ( m~(.+/)\*\*$~ )
856
                    {
857
                        my $base = $1;
858
                        if ( $file =~ m~^$base~ )
859
                        {
4086 dpurdie 860
                            Verbose0("Merge Retain(2): $file");
3347 dpurdie 861
                            $keep = 1;
862
                            last;
863
                        }
864
                    }
865
                }
866
 
2764 dpurdie 867
                next if ($keep);
868
            }
869
 
4086 dpurdie 870
            Verbose0("Removing $file");
2764 dpurdie 871
            $filesDeleted++ unless ( $file =~ m~/$~ );
872
            $dirsDeleted++ if ( $file =~ m~/$~ );
379 dpurdie 873
            unlink "$opt_workdir/$file";
2764 dpurdie 874
            push @processedFiles, $file;
379 dpurdie 875
        }
2764 dpurdie 876
        @rm_files = @processedFiles;
379 dpurdie 877
 
878
        #
879
        #   Inform Subversion about the removed files
880
        #
881
        my $base = 0;
882
        my $num = $#rm_files;
2764 dpurdie 883
        Message ("Update the workspace: Removed $filesDeleted Files, $dirsDeleted directories");
379 dpurdie 884
 
885
        while ( $base <= $num )
886
        {
887
            my $end = $base + 200;
888
            $end = $num if ( $end > $num );
889
 
890
            $svn->SvnCmd ( 'delete', map ("$opt_workdir/$_@", @rm_files[$base .. $end] ),
891
                            { 'error' => 'Deleting files from workspace' } );
2049 dpurdie 892
 
379 dpurdie 893
            $base = $end + 1;
894
        }
895
    }
2049 dpurdie 896
 
379 dpurdie 897
    #
311 dpurdie 898
    #   Add New Files
899
    #   Won't add empty directories at this point
900
    #
901
    #   Process by sorted list
902
    #   This will ensure we process parent directories first
903
    #
904
    my @added = sort keys %dir;
905
    if ( @added )
906
    {
2764 dpurdie 907
        my @processedFiles;
311 dpurdie 908
        foreach my $file ( @added  )
909
        {
2764 dpurdie 910
            #
911
            #   Detect items that are to be merged
912
            #   Only specified top level paths are to be imported
3347 dpurdie 913
            #   Special mergePath names
914
            #       ++              - All files and directories
915
            #       +               - All files in the root
916
            #       path/**         - Keep all items under path
917
            #       Otherwise       - name of a directory
2764 dpurdie 918
            #
919
            if ( $opt_mergePaths )
920
            {
921
                my $discard = 1;
922
                foreach ( split(',', $opt_mergePaths) )
923
                {
3347 dpurdie 924
                    next if ( m ~\*\*$~ );
925
                    if ( $_ eq '++' )
2764 dpurdie 926
                    {
3347 dpurdie 927
                        $discard = 0;
928
                        last;
929
                    }
930
                    elsif ( $_ eq '+' )
931
                    {
2764 dpurdie 932
                        if ( ($file =~ tr~/~/~) eq 0 )
933
                        {
934
                            $discard = 0;
935
                            last;
936
                        }
937
                    }
938
                    elsif ( $file =~ m~^$_/~ )
939
                    {
940
                        $discard = 0;
941
                        last;
942
                    }
943
                }
4086 dpurdie 944
                Verbose0("Not Importing: $file") if ( $discard ) ;
2764 dpurdie 945
                next if ( $discard );
946
            }
947
 
311 dpurdie 948
            my $src = "$opt_dir/$file";
949
            my $target = "$opt_workdir/$file";
2764 dpurdie 950
            $filesAdded++ unless ( $file =~ m~/$~ );
951
            $dirsAdded++ if ( $file =~ m~/$~ );
952
            push @processedFiles, $file;
311 dpurdie 953
 
954
            if ( -d $src )
955
            {
4086 dpurdie 956
                Verbose0("Adding directory: $file");
311 dpurdie 957
                mkdir ( $target ) unless (-d $target);
958
            }
959
            else
960
            {
961
 
962
                my $path = dirname ( $target);
963
                mkdir ( $path ) unless (-d $path);
964
 
4086 dpurdie 965
                Verbose0("Adding $file");
311 dpurdie 966
                unless (File::Copy::copy( $src, $target ))
967
                {
968
                    Error("Failed to transfer file [$file]: $!");
969
                }
970
            }
971
        }
2764 dpurdie 972
        @added = @processedFiles;
973
 
311 dpurdie 974
        #
975
        #   Inform Subversion about the added files
976
        #   The command line does have a finite length, so add them 200 at a
977
        #   time.
978
        #
979
 
980
        my $base = 0;
981
        my $num = $#added;
2764 dpurdie 982
        Message ("Update the workspace: Added $filesAdded Files, $dirsAdded directories");
311 dpurdie 983
 
984
        while ( $base <= $num )
985
        {
986
            my $end = $base + 200;
987
            $end = $num if ( $end > $num );
988
 
989
            $svn->SvnCmd ( 'add'
990
                            , '--depth=empty'
991
                            , '--parents'
379 dpurdie 992
                            , map ("$opt_workdir/$_@", @added[$base .. $end] ),
311 dpurdie 993
                            { 'error' => 'Adding files to workspace' } );
994
 
995
            $base = $end + 1;
996
        }
997
    }
998
 
999
    #
1000
    #   The common files may have changed
1001
    #   Simply copy them all in and let subversion figure it out
1002
    #
1003
    foreach my $file ( sort keys %common  )
1004
    {
1005
        my $src = "$opt_dir/$file";
1006
        my $target = "$opt_workdir/$file";
1007
 
2764 dpurdie 1008
        $filesTransferred++ unless ( $file =~ m~/$~ );
1009
        $dirsTransferred++ if ( $file =~ m~/$~ );
1010
 
311 dpurdie 1011
        next if ( -d $src );
1012
        if ( File::Compare::compare ($src, $target) )
1013
        {
1014
            Verbose ("Transfer $file");
1015
            unlink $target;
1016
            unless (File::Copy::copy( $src, $target ))
1017
            {
1018
                Error("Failed to transfer file [$file]: $!",
1019
                      "Src: $src",
1020
                      "Tgt: $target");
1021
            }
1022
        }
1023
    }
2764 dpurdie 1024
    Message ("Update the workspace: Transferred $filesTransferred Files, $dirsTransferred directories")
1025
        if ($filesTransferred);
311 dpurdie 1026
 
1027
    #
1028
    #   Commit the workspace
1029
    #   This will go back onto the trunk
1030
    #
2429 dpurdie 1031
    if ( $opt_commit )
1032
    {
1033
        $svn = NewSessionByWS( $opt_workdir );
1034
        my $pkgPath = $svn->Path();
387 dpurdie 1035
 
2429 dpurdie 1036
        my $ciComment = "$pkgPath: Checkin by Svn Import";
1037
        $ciComment .= "\n" . $opt_log if ( $opt_log );
1038
        $ciComment =~ s~\r\n~\n~g;
1039
        $ciComment =~ s~\r~\n~g;
1040
        $ciComment = encode('UTF-8', $ciComment, Encode::FB_DEFAULT);
387 dpurdie 1041
 
2429 dpurdie 1042
        $svn->SvnCi ('comment' => $ciComment, 'allowSame' => 1 );
1043
        Message ("Repository Ref: " . $svn->RmRef) unless( $opt_label );
4076 dpurdie 1044
        unless ($svn->{NoRepoChanges}) {
1045
            $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
1046
            $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
1047
        }
2429 dpurdie 1048
 
1049
        #
1050
        #   Label the result
1051
        #   The workspace will have been updated, so we can use it as the base for
1052
        #   the labeling process
1053
        #
1054
        if ( $opt_label )
1055
        {
4076 dpurdie 1056
            my $tagComment = "$pkgPath: Tagged by Jats Svn Import";
1057
            if ($svn->{NoRepoChanges} && $opt_log )
1058
            {
1059
                $tagComment .= "\nNo Repository changes on last commit. Comment was:";
1060
                $tagComment .= "\n" . $opt_log;
1061
                $tagComment =~ s~\r\n~\n~g;
1062
                $tagComment =~ s~\r~\n~g;
1063
                $tagComment = encode('UTF-8', $tagComment, Encode::FB_DEFAULT);
1064
            }
2429 dpurdie 1065
            $svn->SvnCopyWs (
1066
                           target => $url_label,
1067
                           'noswitch' => 1,
1068
                           'replace' => $opt_replace,
4076 dpurdie 1069
                           'comment' => $tagComment,
2429 dpurdie 1070
                           );
1071
            Message ("Repository Ref: " . $svn->RmRef);
1072
            Message ("Vcs Tag       : " . $svn->SvnTag);
1073
            $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
1074
            $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
1075
        }
311 dpurdie 1076
    }
2429 dpurdie 1077
    else
1078
    {
1079
        Message ("Workspace not commited","Workspace: $opt_workdir");
1080
    }
311 dpurdie 1081
 
1082
    #
1083
    #   Clean up
1084
    #
2429 dpurdie 1085
    if ( $opt_delete && ! $opt_reuse  && $opt_commit )
311 dpurdie 1086
    {
1087
        Message ("Delete Workspace");
1088
        rmtree( $opt_workdir );
1089
    }
379 dpurdie 1090
 
1091
    #
1092
    #   Automation data transfer
1093
    #
1094
    if ( defined $opt_datafile )
1095
    {
1096
        my $data = JatsProperties::New();
1097
 
1098
        $data->setProperty('Command'        , 'ImportPackage');
1099
        $data->setProperty('Label'          , $opt_label);
1403 dpurdie 1100
        $data->setProperty('subversion.url' , $svn->RmRef);
1101
        $data->setProperty('subversion.tag' , $svn->SvnTag);
379 dpurdie 1102
 
2764 dpurdie 1103
        $data->setProperty('files.base'     , $filesBase);
1104
        $data->setProperty('files.removed'  , $filesDeleted);
1105
        $data->setProperty('files.added'    , $filesAdded);
1106
 
379 dpurdie 1107
        $data->Dump('InfoFile') if ($opt_verbose);
1108
        $data->store( $opt_datafile );
1109
    }
1110
 
311 dpurdie 1111
    $opr_done = 1;
1112
}
1113
 
1114
#-------------------------------------------------------------------------------
385 dpurdie 1115
# Function        : DeleteBranch
1116
#
1117
# Description     : Delete the branch that a workspace is based upon
1118
#
2049 dpurdie 1119
# Inputs          :
385 dpurdie 1120
#
2049 dpurdie 1121
# Returns         :
385 dpurdie 1122
#
1123
sub DeleteBranch
1124
{
1125
    my $opt_path;
1126
    my $opt_error = 0;
1127
    #
1128
    #   Parse more options
1129
    #
1130
    GetOptions (
1131
                "help:+"        => \$opt_help,
1132
                "manual:3"      => \$opt_help,
1133
                "path:s"        => \$opt_path,
1134
                ) || Error ("Invalid command line" );
1135
 
1136
    #
1137
    #   Subcommand specific help
1138
    #
1139
    SubCommandHelp( $opt_help, "Delete Branch") if ($opt_help);
1140
 
1141
    #
1142
    #   Sanity Tests
1143
    #
2429 dpurdie 1144
    Message ("Delete Workspace Branchs" );
385 dpurdie 1145
 
1146
    #
1147
    #   Do all the hard work
1148
    #
1149
    $opt_path = '.' unless ( defined $opt_path );
1150
    my $uref = NewSessionByWS($opt_path, 0, 1);
1151
    my $ws_root = $uref->SvnLocateWsRoot(1);
1152
    my $ws_url = $uref->FullWs();
1153
 
1154
    #
2931 dpurdie 1155
    #   What we do depends what arguments the user provided
385 dpurdie 1156
    #
2429 dpurdie 1157
    unless ( @ARGV )
1158
    {
1159
        #
1160
        #   If no branch was specified - then display the workspace branch
1161
        #
1162
        Error ('The workspace is not based on a branch')
1163
            unless ( $ws_url =~ m ~/branches/(.*)~ );
1164
        Message('The workspace is based on the branch: '. $1);
1165
    }
1166
    else
1167
    {
1168
        #
1169
        #   Delete all specified branches
1170
        #
1171
        foreach my $branch ( @ARGV )
1172
        {
1173
            Message ("Deleting: " . $branch );
1174
            my $target = join( '/', $uref->FullPath(), 'branches', $branch);
1175
            if ( $uref->SvnDelete (
1176
                              'target'    => $target,
1177
                              'comment'   => [$uref->Path().": Delete Branch",'Deleted by user command: jats svn delete-branch'],
1178
                              'noerror'   => 1,
1179
                              )
1180
               )
1181
            {
1182
                Warning ("Branch deletion failed: $branch");
1183
            }
1184
        }
1185
    }
385 dpurdie 1186
    $opr_done = 1;
1187
}
1188
 
2049 dpurdie 1189
#-------------------------------------------------------------------------------
1190
# Function        : CreateBranch
1191
#
1192
# Description     : Branch a workspace and then switch to the new branch
1193
#
1194
# Inputs          :
1195
#
1196
# Returns         :
1197
#
1198
sub CreateBranch
1199
{
1200
    my $opt_path;
1201
    my $opt_comment;
1202
    my $opt_switch = 1;
1203
    my $opt_branch;
385 dpurdie 1204
 
2049 dpurdie 1205
    #
1206
    #   Parse more options
1207
    #
1208
    GetOptions (
1209
                "help:+"        => \$opt_help,
1210
                "manual:3"      => \$opt_help,
1211
                "path:s"        => \$opt_path,
1212
                "switch!"       => \$opt_switch,
1213
                "comment:s"     => \$opt_comment,
1214
                ) || Error ("Invalid command line" );
1215
 
1216
    #
1217
    #   Subcommand specific help
1218
    #
1219
    SubCommandHelp( $opt_help, "Create Branch") if ($opt_help);
1220
 
1221
    #
1222
    #   Sanity Tests
1223
    #
1224
    Message ("Create Workspace Branch" );
1225
    Error ("Too many arguments: @ARGV") if ( $#ARGV > 0 );
1226
    Error ("Not enough arguments. No branch name specified") if ( $#ARGV < 0 );
1227
 
1228
    #
1229
    #   Sanity test the label
1230
    #
1231
    $opt_branch = SvnIsaSimpleLabel ($ARGV[0] );
1232
 
1233
    #
1234
    #   Do all the hard work
1235
    #
1236
    $opt_path = '.' unless ( defined $opt_path );
1237
    my $uref = NewSessionByWS($opt_path, 0, 1);
1238
    my $ws_root = $uref->SvnLocateWsRoot(1);
1239
    my $ws_url = $uref->Full();
1240
 
1241
    #
2931 dpurdie 1242
    #   Use the version of the branch that has been committed as the base of the
1243
    #   copy. If the user has modified files, then they won't be committed
2049 dpurdie 1244
    #
1245
    #   This operation will be server-side only
1246
    #
1247
    Message ("Creating branch: $opt_branch");
1248
    my $repoLink = $uref->{InfoWs}{URL} . '@' . $uref->{InfoWs}{Revision};
1249
    $uref->{DEVBRANCH} =  join ('/', 'branches', $opt_branch);
1250
    my $branch_tag = $uref->SvnCopy (
1251
                'old' => $repoLink,
1252
                'new' => join ('/', $ws_url, $uref->{DEVBRANCH} ),
5073 dpurdie 1253
                'comment' => $opt_comment ? $opt_comment : ('Created by Jats svn branch:' . $opt_branch),
2049 dpurdie 1254
                'replace' => 0,
7322 dpurdie 1255
                'parents' => 1,
2049 dpurdie 1256
                );
1257
 
2054 dpurdie 1258
 
2049 dpurdie 1259
    if ( $opt_switch )
1260
    {
1261
        Verbose ("Switching to new branch: $opt_branch");
1262
        $branch_tag = SvnPath2Url($branch_tag);
2054 dpurdie 1263
        chdir ($ws_root) || Error ("Cannot cd to: " .$ws_root);
1264
        $uref->SvnSwitch ($branch_tag, $opt_path, '--Print', '--KeepWs' );
2049 dpurdie 1265
    }
1266
    else
1267
    {
1268
        Warning ("Using existing workspace, not the created branch");
1269
    }
1270
    Message ("Repository Ref: " . $uref->RmRef);
1271
    Message ("Vcs Tag       : " . $uref->SvnTag);
1272
 
1273
#    #
1274
#    #   The copy operation *should* be a server side operation only
2931 dpurdie 1275
#    #   If the user has committed changes, but not yet updated the local
2049 dpurdie 1276
#    #   workspace, then subversion will do a client side copy
1277
#    #   This is not good.
1278
#    #
1279
#    $uref->SvnCopyWs (
1280
#                   target => join ('/', $ws_url, 'branches', $opt_branch),
1281
#                   'allowLocalMods' => 1,
1282
#                   'noupdatecheck' => 1,
1283
#                   'noswitch' => ! $opt_switch,
1284
#                   'replace' => 0,
5073 dpurdie 1285
#                   'comment' => $opt_comment ? $opt_comment : ('Created by Jats svn branch:' . $opt_branch),
2049 dpurdie 1286
#                   );
1287
#
1288
#    Message ("Repository Ref: " . $uref->RmRef);
1289
#    Message ("Vcs Tag       : " . $uref->SvnTag);
1290
 
1291
    $opr_done = 1;
1292
}
1293
 
385 dpurdie 1294
#-------------------------------------------------------------------------------
2049 dpurdie 1295
# Function        : SwitchBranch
1296
#
1297
# Description     : Switch to a specified branch
1298
#
1299
# Inputs          :
1300
#
1301
# Returns         :
1302
#
1303
sub SwitchBranch
1304
{
1305
    my $opt_path = '.';
1306
    my $opt_branch;
1307
 
1308
    #
1309
    #   Parse more options
1310
    #
1311
    GetOptions (
1312
                "help:+"        => \$opt_help,
1313
                "manual:3"      => \$opt_help,
1314
                "path:s"        => \$opt_path,
1315
                ) || Error ("Invalid command line" );
1316
 
1317
    #
1318
    #   Subcommand specific help
1319
    #
1320
    SubCommandHelp( $opt_help, "Switch Branch") if ($opt_help);
1321
    return ShowBranches($opt_path) if ( $#ARGV < 0 );
1322
 
1323
    #
1324
    #   Sanity Tests
1325
    #
1326
    Error ("Too many arguments: @ARGV") if ( $#ARGV > 0 );
1327
 
1328
    #
1329
    #   Calculate the target name
1330
    #       trunk is special
1331
    #       tags/... is special
1332
    $opt_branch = $ARGV[0];
1333
    if ( $opt_branch eq 'trunk' ) {
1334
    } elsif ( $opt_branch =~ m~tags/.+~ ) {
1335
    } else {
1336
        $opt_branch = join ('/', 'branches', $opt_branch);
1337
    }
1338
    Message ("Switching to new branch: $opt_branch");
1339
 
1340
    #
1341
    #   Do all the hard work
1342
    #
1343
    my $uref = NewSessionByWS($opt_path, 0, 1);
2054 dpurdie 1344
    my $ws_root = $uref->SvnLocateWsRoot(1);
2049 dpurdie 1345
    my $ws_url = $uref->Full();
1346
    my $branch_tag = join ('/', $ws_url, $opt_branch);
1347
 
1348
    #
1349
    #   Validate the branch
1350
    #
1351
    $uref->SvnValidateTarget (
1352
                        'cmd'    => 'svn switch',
1353
                        'target' => $branch_tag,
1354
                        'require' => 1,
1355
                        );
1356
 
2054 dpurdie 1357
    #
1358
    #   Must Change directory before we switch
2931 dpurdie 1359
    #   Otherwise we will import changes into the wrong place
2054 dpurdie 1360
    #
1361
    chdir ($ws_root) || Error ("Cannot cd to: " . $ws_root);
1362
    $uref->SvnSwitch ($branch_tag, $opt_path, '--Print', '--KeepWs' );
2049 dpurdie 1363
    $opr_done = 1;
1364
}
1365
 
1366
#-------------------------------------------------------------------------------
1367
# Function        : ShowBranches
1368
#
1369
# Description     : Show branches in current workspace
1370
#                   Internal use only
1371
#
1372
# Inputs          : $opt_path           - Optional path
1373
#
1374
# Returns         :
1375
#
1376
sub ShowBranches
1377
{
1378
    my ($opt_path) = @_;
1379
 
1380
    my $uref = NewSessionByWS($opt_path, 0, 1);
1381
    my $ws_url = $uref->Full();
1382
 
1383
    #
2931 dpurdie 1384
    #   Display the packages full URL - allow the user to manually look at more
1385
    #   List the branches
2049 dpurdie 1386
    #
1387
    Message ("Url: $ws_url", 'Available Branches');
1388
    SvnUserCmd( 'ls', join ('/', $ws_url, 'branches'), { 'credentials' => 1 });
1389
    $opr_done = 1;
1390
}
1391
#-------------------------------------------------------------------------------
311 dpurdie 1392
# Function        : SubCommandHelp
1393
#
1394
# Description     : Provide help on a subcommand
1395
#
1396
# Inputs          : $help_level             - Help Level 1,2,3
1397
#                   $topic                  - Topic Name
1398
#
1399
# Returns         : This function does not return
1400
#
1401
sub SubCommandHelp
1402
{
1403
    my ($help_level, $topic) = @_;
1404
    my @sections;
1405
    #
1406
    #   Spell out the section we want to display
1407
    #
1408
    #   Note:
1409
    #   Due to bug in pod2usage can't use 'head1' by itself
1410
    #   Each one needs a subsection.
1411
    #
1412
    push @sections, qw( NAME SYNOPSIS ) ;
1413
    push @sections, qw( ARGUMENTS OPTIONS ) if ( $help_level > 1 );
1414
    push @sections, qw( DESCRIPTION )       if ( $help_level > 2 );
1415
 
1416
    #
1417
    #   Extract section from the POD
1418
    #
1419
    pod2usage({-verbose => 99,
1420
               -noperldoc => 1,
1421
               -sections => $topic . '/' . join('|', @sections) } );
1422
}
1423
 
1424
#-------------------------------------------------------------------------------
1425
#   Documentation
1426
#   NOTE
1427
#
1428
#   Each subcommand MUST have
1429
#   head1 section as used by the subcommand
1430
#       This should be empty, as the contents will NOT be displayed
1431
#   head2 sections called
1432
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION
1433
#
1434
#=head1 xxxxxx
1435
#=head2 NAME
1436
#=head2 SYNOPSIS
1437
#=head2 ARGUMENTS
1438
#=head2 OPTIONS
1439
#=head2 DESCRIPTION
1440
#
1441
 
1442
=pod
1443
 
361 dpurdie 1444
=for htmltoc    GENERAL::Subversion::
1445
 
311 dpurdie 1446
=head1 NAME
1447
 
1448
jats svn - Miscellaneous SubVersion Operations
1449
 
1450
=head1 SYNOPSIS
1451
 
1452
jats svn [options] command [command options]
1453
 
1454
 Options:
1455
    -help[=n]              - Help message, [n=1,2,3]
1456
    -man                   - Full documentation [-help=3]
1457
    -verbose[=n]           - Verbose command operation
1458
 
1459
 Common Command Options:
1460
    All command support suboptions to provide command specific help
1461
 
1462
    -help[=n]              - Help message, [n=1,2,3]
1463
    -man                   - Full documentation [-help=3]
1464
 
1465
 Commands are:
363 dpurdie 1466
    test                   - Test access to subversion
369 dpurdie 1467
    paths                  - Display Subversion tag to URL conversions
311 dpurdie 1468
    ls URL                 - List Repo contents for URL
369 dpurdie 1469
    tag [URL]              - Convert URL or Path to a Release Manager Tag
1470
    url [TAG]              - Convert TAG or Path to a Subversion URL
2049 dpurdie 1471
    create-package URL     - Create a new package at URL
311 dpurdie 1472
    delete-package URL     - Delete Package Subtree
2049 dpurdie 1473
    branch BRANCH          - Create a Development Branch
1474
    switch [BRANCH]        - Switch to a Development Branch
385 dpurdie 1475
    delete-branch          - Delete a Development Branch
311 dpurdie 1476
    import URL             - Import files to package at URL
1477
 
1478
 Use the command
1479
    jats svn command -h
1480
 for command specific help
1481
 
1482
=head1 OPTIONS
1483
 
1484
=over
1485
 
1486
=item B<-help[=n]>
1487
 
1488
Print a help message and exit. The level of help may be either 1, 2 or
1489
3 for a full manual.
1490
 
1491
This option may be specified multiple times to increment the help level, or
1492
the help level may be directly specified as a number.
1493
 
1494
=item B<-man>
1495
 
1496
This is the same as '-help=3'.
1497
The complete help is produced in a man page format.
1498
 
2429 dpurdie 1499
=item B<-verbose[=n]>
311 dpurdie 1500
 
1501
This option will increase the level of verbosity of the commands.
1502
 
1503
If an argument is provided, then it will be used to set the level, otherwise the
1504
existing level will be incremented. This option may be specified multiple times.
1505
 
1506
=back
1507
 
1508
=head1 DESCRIPTION
1509
 
1510
This program provides a number of useful Subversion based operations.
1511
 
363 dpurdie 1512
=head1 Test Subversion
1513
 
1514
=head2 NAME
1515
 
1516
Test Subversion
1517
 
1518
=head2 SYNOPSIS
1519
 
1520
    jats svn test
1521
 
1522
=head2 DESCRIPTION
1523
 
1524
This command will ensure that the subversion command line utility can be
1525
located. The command will report the version of the svn client found.
1526
 
369 dpurdie 1527
=head1 Subversion Paths
1528
 
1529
=head2 NAME
1530
 
1531
Subversion Paths
1532
 
1533
=head2 SYNOPSIS
1534
 
1535
    jats svn paths
1536
 
1537
=head2 DESCRIPTION
1538
 
1539
This command will display the base Tags and associated URLs that are used by
1540
JATS to convert a 'Subversion Tag' into a full URLs that will be used to access
1541
a physical repository.
1542
 
1543
The 'Tags' configuration is site-specific.
1544
 
311 dpurdie 1545
=head1 List Repository
1546
 
363 dpurdie 1547
=head2 NAME
1548
 
1549
List Repository
1550
 
1551
=head2 SYNOPSIS
1552
 
1553
    jats svn ls <URL>
1554
 
1555
=head2 DESCRIPTION
1556
 
311 dpurdie 1557
This command will take a URL and perform a 'svn' list operation. The URL will
1558
be expanded to include the site specific repository.
1559
 
369 dpurdie 1560
=head1 Url to Tag
1561
 
1562
=head2 NAME
1563
 
1564
Url to Tag
1565
 
1566
=head2 SYNOPSIS
1567
 
1568
    jats svn tag [Option] [tag]
1569
 
1570
 Options:
1571
    -help[=n]              - Help message, [n=1,2,3]
1572
    -man                   - Full documentation [-help=3]
1573
    -path=path             - Convert specified path
1574
    -url=url               - Convert specified URL
1575
 
1576
=head2 DESCRIPTION
1577
 
1578
This command will convert a URL or a PATH to a Subversion Tag that can
1579
be used within the remainder of the build system. If no PATH or URL is provided,
1580
then the command uses a path of the current directory.
1581
 
1582
The command will convert either a PATH or a URL. It will not do both.
1583
 
1584
The command will use the configured Subversion URL prefixes to create the Tag.
1585
 
1586
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1587
The conversion will return a Tag to the root of the Workspace and Peg it to
1588
the last committed version. The command will not determine if the workspace
1589
contains modified files.
1590
 
1591
If a URL is to be converted, then the resultant value should be used with
1592
caution. The result is only as good as the provided URL and may not address
1593
the root of a package.
1594
 
1595
=head1 Tag to Url
1596
 
1597
=head2 NAME
1598
 
1599
Tag to Url
1600
 
1601
=head2 SYNOPSIS
1602
 
1603
    jats svn url [Option] [url]
1604
 
1605
 Options:
1606
    -help[=n]              - Help message, [n=1,2,3]
1607
    -man                   - Full documentation [-help=3]
1608
    -path=path             - Convert specified path
1609
    -url=url               - Convert specified URL
1610
 
1611
=head2 DESCRIPTION
1612
 
1613
This command will convert a TAG or a PATH to a full URL that can be used
1614
directly by Subversion. If no PATH or TAG is provided, then the command uses a
1615
path of the current directory.
1616
 
2429 dpurdie 1617
The command will convert either a TAG or a PATH. It will not do both.
369 dpurdie 1618
 
1619
The command will use the configured Subversion URL prefixes to expand the TAG.
1620
 
1621
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1622
The conversion will return a URL to the root of the Workspace and Peg it to
1623
the last committed version. The command will not determine if the workspace
1624
contains modified files.
1625
 
1626
If a TAG is to be converted, then the resultant value should be used with
1627
caution. The result is only as good as the provided URL and may not address
1628
the root of a package.
1629
 
2429 dpurdie 1630
=head3 Examples
1631
 
1632
To display the URL of the current workspace
1633
 
1634
    jats svn url
1635
 
1636
To display the URL of a known workspace
1637
 
1638
    jats svn url -path=myWorkSpace
1639
 
1640
To convert a TAG from Release Manager or other JATS commands
1641
 
1642
    jats svn url AUPERASVN01/COTS
1643
    jats svn url SVN::AUPERASVN01/COTS/bouncycastle/trunk::bouncycastle_1.3.1.cots@502
1644
 
2049 dpurdie 1645
=head1 Create a Package Version
1646
 
1647
=head2 NAME
1648
 
1649
Create a Package Version
1650
 
1651
=head2 SYNOPSIS
1652
 
1653
jats svn [options] create-package URL [command options]
1654
 
1655
 Options:
1656
    -help[=n]               - Help message, [n=1,2,3]
1657
    -man                    - Full documentation [-help=3]
1658
    -verbose[=n]            - Verbose command operation
1659
 
1660
 Command Options
1661
    -help[=n]               - Provide command specific help
1662
    -new                    - Package must not exist
1663
    -replace                - Replace any existing versions
2429 dpurdie 1664
    -import=path            - Import directory tree
2049 dpurdie 1665
    -label=nnn              - Label imported package
1666
    -trunk                  - Import to trunk (default)
1667
    -tags=nnn               - Import to tags
1668
    -branch=nnn             - Import to branches
1669
 
1670
=head2 ARGUMENTS
1671
 
1672
The command takes one argument: The URL of the desired package.
1673
This may be be:
1674
 
1675
=over
1676
 
1677
=item * A full URL
1678
 
1679
Complete with protocol and path information.
1680
 
1681
=item * A simple URL
1682
 
1683
JATS will prepend the site-specific repository location to the user provided URL
1684
 
1685
=back
1686
 
1687
=head2 OPTIONS
1688
 
1689
=over
1690
 
1691
=item -help[=n]
1692
 
1693
Print a help message and exit. The level of help may be either 1, 2 or 3.
1694
 
1695
This option may be specified multiple times to increment the help level, or
1696
the help level may be directly specified as a number.
1697
 
1698
=item -new
1699
 
1700
This option specifies that the named package MUST not exist at all.
1701
 
1702
=item -replace
1703
 
1704
This option allows the program to replace any existing versions of the
1705
imported source. It will allow the deletion of any existing trunk, tags or
1706
branches.
1707
 
2429 dpurdie 1708
=item -import=path
2049 dpurdie 1709
 
1710
This option specifies the path of a subdirectory tree to import into the newly
1711
created package. In not provided, then only a package skeleton will be created.
1712
 
2429 dpurdie 1713
All files and directories below, but not including, the named path will be
1714
imported into the package.
1715
 
4096 dpurdie 1716
The imported directory tree will be scanned to ensure that the following subdirectories
1717
do not exist: .svn, .hg, .git, .cvs, tags, trunk and branches. These directories are
1718
either reserved or indicative that the import tree is already version controlled.
1719
 
2049 dpurdie 1720
=item -label=nnn
1721
 
1722
This option specifies a label to place the imported source.
1723
 
1724
=item -trunk
1725
 
1726
This option specifies that imported source will be placed on the trunk of the
1727
package. This is the default mode of import.
1728
 
1729
The options -trunk, -tags and -branch are mutually exclusive.
1730
 
1731
=item -tags=nnn
1732
 
1733
This option specifies that imported source will be placed directly on the
1734
named tag of the package.
1735
 
1736
The options -trunk, -tags and -branch are mutually exclusive.
1737
 
1738
=item -branch=nnn
1739
 
1740
This option specifies that imported source will be placed directly on the
1741
named branch of the package.
1742
 
1743
The options -trunk, -tags and -branch are mutually exclusive.
1744
 
1745
=back
1746
 
1747
=head2 DESCRIPTION
1748
 
1749
This command will create a new package within a repository. It will ensure
1750
that the package contains the three required subdirectories: trunk, tags and
1751
branches.
1752
 
1753
The command will also ensure that packages are not placed at inappropriate
1754
locations within the repository. It is not correct to place a package within
1755
another package.
1756
 
1757
The command will, optionally, import a directory tree into the repository and,
1758
optionally, label the package.
1759
 
1760
The package body may be imported to the 'trunk' or to a branch or a tag.
1761
By default the data will be imported to the trunk and may be labeled (tagged).
1762
 
1763
Options allow the targets to be deleted if they exist or to ensure that they
1764
are not present.
1765
 
1766
The command does not attempt to merge file versions within the repository. It
1767
may result in multiple instances of a file within the repository. Use only for
1768
simple imports. Use the 'import' command for more sophisticated import requirements.
1769
 
2429 dpurdie 1770
=head3 Examples
1771
 
1772
To create a package skeleton in the Perth MREF_Package repository for a package
1773
called 'VIXmyPackage':
1774
 
1775
    jats svn create-package AUPERASVN01/MREF_Package/VIXmyPackage
1776
 
1777
To create a package skeleton in the Perth MREF_Package repository, import code
1778
into the trunk of the package and label (tag) it:
1779
 
1780
    jats svn create-package \
1781
           AUPERASVN01/MREF_Package/VIXmyPackage \
1782
           -import=VIXmyNewPackage \
1783
           -label=VIXmyPackage.WIP
1784
 
311 dpurdie 1785
=head1 Delete a Package
1786
 
1787
=head2 NAME
1788
 
1789
Delete a Package
1790
 
1791
=head2 SYNOPSIS
1792
 
1793
jats svn delete-package URL [options]
1794
 
1795
 Options:
1796
    -help[=n]              - Help message, [n=1,2,3]
1797
    -man                   - Full documentation [-help=3]
1798
    -verbose[=n]           - Verbose command operation
1799
 
1800
=head2 ARGUMENTS
1801
 
1802
The command takes one argument: The URL of the desired package.
1803
This may be be:
1804
 
1805
=over
1806
 
1807
=item * A full URL
1808
 
1809
Complete with protocol and path information.
1810
 
1811
=item * A simple URL
1812
 
1813
JATS will prepend the site-specific repository location to the user provided URL
1814
 
1815
=back
1816
 
1817
=head2 OPTIONS
1818
 
1819
This command has no significant options, other than the general help options.
1820
 
1821
=head2 DESCRIPTION
1822
 
1823
This command will delete a package from the repository. It will ensure
1824
that the package is a valid package, before it is deleted.
1825
 
1826
The command is intended to be used by test scripts, rather than users.
1827
 
2049 dpurdie 1828
=head1 Create Branch
385 dpurdie 1829
 
1830
=head2 NAME
1831
 
2049 dpurdie 1832
Create a Workspace Branch
385 dpurdie 1833
 
1834
=head2 SYNOPSIS
1835
 
2049 dpurdie 1836
jats svn branch branch-name [options]
385 dpurdie 1837
 
1838
 Options:
1839
    -help[=n]              - Help message, [n=1,2,3]
1840
    -man                   - Full documentation [-help=3]
1841
    -verbose[=n]           - Verbose command operation
1842
    -path=path             - Target workspace
2049 dpurdie 1843
    -[no]switch            - Switch to new branch(default)
1844
    -comment=text          - Comment to apply to the new branch
385 dpurdie 1845
 
1846
=head2 ARGUMENTS
1847
 
2049 dpurdie 1848
The command takes one argument. The name of the branch to be created.
385 dpurdie 1849
 
1850
=head2 OPTIONS
1851
 
1852
=over
1853
 
1854
=item B<-path=path>
1855
 
1856
This options specifies the path of the target workspace. If not provided the
1857
command will use the current directory.
1858
 
2049 dpurdie 1859
=item B<-[no]switch>
1860
 
1861
If enabled (the default) the workspace will be switched to the new branch at
1862
the end of the process.
1863
 
1864
=item B<-comment=text>
1865
 
1866
If present, the specified text will be used as a Subversion comment when the
1867
branch is created.
1868
 
1869
If not provided, then JATS will provide a basic comment.
1870
 
385 dpurdie 1871
=back
1872
 
1873
=head2 DESCRIPTION
1874
 
2049 dpurdie 1875
This command will create a named branch associated with the workspace in the
1876
specified path. It is intended to simplify the creation of Private or
385 dpurdie 1877
Development branches.
1878
 
2049 dpurdie 1879
If the named branch already exists, then the command will fail.
385 dpurdie 1880
 
2049 dpurdie 1881
The command performs a server-side copy. It will not commit any locally
1882
modified files. Nor will it inform you if there are any.
311 dpurdie 1883
 
2049 dpurdie 1884
By default, the user is 'switched' to the newly created branch.
1885
 
1886
=head1 Switch Branch
1887
 
311 dpurdie 1888
=head2 NAME
1889
 
2049 dpurdie 1890
Switch a Workspace Branch
311 dpurdie 1891
 
1892
=head2 SYNOPSIS
1893
 
2049 dpurdie 1894
jats svn switch [branch-name] [options]
311 dpurdie 1895
 
1896
 Options:
2049 dpurdie 1897
    -help[=n]              - Help message, [n=1,2,3]
1898
    -man                   - Full documentation [-help=3]
1899
    -verbose[=n]           - Verbose command operation
1900
    -path=path             - Target workspace
311 dpurdie 1901
 
1902
=head2 ARGUMENTS
1903
 
2049 dpurdie 1904
The command takes one optional argument. The name of the target branch.
311 dpurdie 1905
 
2049 dpurdie 1906
=head2 OPTIONS
1907
 
311 dpurdie 1908
=over
1909
 
2049 dpurdie 1910
=item B<-path=path>
311 dpurdie 1911
 
2049 dpurdie 1912
This options specifies the path of the target workspace. If not provided the
1913
command will use the current directory.
311 dpurdie 1914
 
2049 dpurdie 1915
=back
311 dpurdie 1916
 
2049 dpurdie 1917
=head2 DESCRIPTION
311 dpurdie 1918
 
2049 dpurdie 1919
This command will switch the users workspace to the named branch. This is
1920
identical to the Subversion switch command, except it is easier to user and
1921
has several validity checks and other enhancements.
311 dpurdie 1922
 
2049 dpurdie 1923
The command has two modes of operation:
311 dpurdie 1924
 
2049 dpurdie 1925
=over 4
311 dpurdie 1926
 
2049 dpurdie 1927
=item   1. Display a list of branched in the current package.
311 dpurdie 1928
 
2049 dpurdie 1929
If no branch is specified, then the utility will display a list of branches in
1930
the packages 'branches' directory.
311 dpurdie 1931
 
2049 dpurdie 1932
=item   2. Switch to the named branch.
311 dpurdie 1933
 
2049 dpurdie 1934
The named branch must exists otherwise the command will fail.
311 dpurdie 1935
 
2429 dpurdie 1936
There are two special variants of the branch name:
311 dpurdie 1937
 
2049 dpurdie 1938
=over 4
311 dpurdie 1939
 
2049 dpurdie 1940
=item trunk
311 dpurdie 1941
 
2049 dpurdie 1942
If the branch is named 'trunk' then it will refer to the packages truck
1403 dpurdie 1943
 
2049 dpurdie 1944
=item tags
1403 dpurdie 1945
 
2049 dpurdie 1946
If the branch name starts with 'tags/', then the command will refer to
1947
a tag within the package and not a branch.
1403 dpurdie 1948
 
2049 dpurdie 1949
=back
1403 dpurdie 1950
 
2049 dpurdie 1951
The command will add and remove unmodified files from the workspace during this
1952
operation.
311 dpurdie 1953
 
2049 dpurdie 1954
=back
311 dpurdie 1955
 
2049 dpurdie 1956
=head3 Examples
311 dpurdie 1957
 
2049 dpurdie 1958
To switch to the packages trunk
311 dpurdie 1959
 
2049 dpurdie 1960
    jats svn switch trunk
311 dpurdie 1961
 
2049 dpurdie 1962
To switch to the a branch called MyBranch
311 dpurdie 1963
 
2049 dpurdie 1964
    jats svn switch MyBranch
311 dpurdie 1965
 
2049 dpurdie 1966
To switch to a tagged version of the package
311 dpurdie 1967
 
2049 dpurdie 1968
    jats svn switch tags/MyPackage_1.0.0000.cr
311 dpurdie 1969
 
2049 dpurdie 1970
To display a list of available branches (not tags)
311 dpurdie 1971
 
2049 dpurdie 1972
    jats svn switch
311 dpurdie 1973
 
2049 dpurdie 1974
=head1 Delete Branch
311 dpurdie 1975
 
2049 dpurdie 1976
=head2 NAME
311 dpurdie 1977
 
2049 dpurdie 1978
Delete the Workspace Branch
311 dpurdie 1979
 
2049 dpurdie 1980
=head2 SYNOPSIS
311 dpurdie 1981
 
2429 dpurdie 1982
jats svn delete-branch [options] [branch-list]
311 dpurdie 1983
 
2049 dpurdie 1984
 Options:
1985
    -help[=n]              - Help message, [n=1,2,3]
1986
    -man                   - Full documentation [-help=3]
1987
    -verbose[=n]           - Verbose command operation
1988
    -path=path             - Target workspace
311 dpurdie 1989
 
2049 dpurdie 1990
=head2 ARGUMENTS
1991
 
2429 dpurdie 1992
The command may take zero or more arguments. If provided the arguments will be
1993
branch names to be deleted.
2049 dpurdie 1994
 
1995
=head2 OPTIONS
1996
 
1997
=over
1998
 
1999
=item B<-path=path>
2000
 
2001
This options specifies the path of the target workspace. If not provided the
2002
command will use the current directory.
2003
 
2004
=back
2005
 
2006
=head2 DESCRIPTION
2007
 
2429 dpurdie 2008
This command can display the branch associated with the workspace or it can
2009
delete one or more branches. It is intended to simplify the deletion of Private
2010
or Development branches.
2049 dpurdie 2011
 
2429 dpurdie 2012
=over 4
2013
 
2014
=item 1 Arguments are provided
2015
 
2016
The command will delete all the named branches. If a named branch does not exist
2017
then the command will issue a warning message.
2018
 
2019
=item 2 No arguments provided
2020
 
2021
The command will display the branch associated with the workspace
2022
 
2049 dpurdie 2023
If the workspace is not linked to a 'branch' then the command will fail.
2024
 
2429 dpurdie 2025
=back
2026
 
311 dpurdie 2027
=head1 Import directory to a Package
2028
 
2029
=head2 NAME
2030
 
2031
Import directory to a Package
2032
 
2033
=head2 SYNOPSIS
2034
 
2035
jats svn [options] import URL [command options]
2036
 
2037
 Options:
2038
    -help[=n]               - Help message, [n=1,2,3]
2039
    -man                    - Full documentation [-help=3]
2040
    -verbose[=n]            - Verbose command operation
2041
 
2042
 Command Options
2043
    -help[=n]               - Command specific help, [n=1,2,3]
2044
    -verbose[=n]            - Verbose operation
2045
    -package=name           - Name of source package
2046
    -dir=path               - Path to new version
379 dpurdie 2047
    -label=label            - Label the result
2048
    -branch=branchName      - Base import on a branch
311 dpurdie 2049
    -replace                - Allow the label to be replaced
2050
    -reuse                  - Reuse the import directory
2051
    -workspace=path         - Path and name of alternate workspace
2052
    -[no]delete             - Deletes workspace after use. Default:yes
379 dpurdie 2053
    -author=name            - Force author of changes
2054
    -date=dateString        - Force date of changes
2055
    -log=text               - Append text to the commit message
2056
    -datafile=path          - Export tag data for automation
2931 dpurdie 2057
    -[no]commit             - Prevent changes being committed. Default:Yes
2429 dpurdie 2058
    -printfiles=n           - Control commit verbosity
2931 dpurdie 2059
    -mergePaths=dirList     - Comma separated list of directories to merge
311 dpurdie 2060
 
2061
=head2 ARGUMENTS
2062
 
2063
The command takes one argument: The URL of the desired package.
2064
This may be be:
2065
 
2066
=over
2067
 
2068
=item * A full URL
2069
 
2070
Complete with protocol and path information.
2071
 
2072
=item * A simple URL
2073
 
2074
JATS will prepend the site-specific repository location to the user provided URL
2075
 
2076
=back
2077
 
2078
=head2 OPTIONS
2079
 
2080
=over
2081
 
2082
=item -help[=n]
2083
 
2084
Print a help message and exit. The level of help may be either 1, 2 or 3.
2085
 
2086
This option may be specified multiple times to increment the help level, or
2087
the help level may be directly specified as a number.
2088
 
2089
=item -verbose[=n]
2090
 
2091
This option will increase the level of verbosity of the utility.
2092
 
2093
If an argument is provided, then it will be used to set the level, otherwise the
2094
existing level will be incremented. This option may be specified multiple times.
2095
 
2096
=item -package=name
2097
 
2098
Either this option or a bare URL on the command line must be provided. It
2099
specifies the repository and package to be used as a basis for the work.
2100
 
2101
=item -dir=path
2102
 
2103
This option is mandatory. It specifies the path to a local directory that
2104
contains a version of the software to be checked in.
2105
 
2106
=item -label=name
2107
 
2108
The resulting software version will be labeled with this tag, if it is provided.
2109
 
383 dpurdie 2110
A label name of TIMESTAMP will be treated in special manner. The name will be
2111
replaced with a unique name based on the users name and the current date time.
2112
 
379 dpurdie 2113
=item -branch=branchName
2114
 
2115
This option will cause the importation to be referenced to the named branch.
2116
If the branch does not exist it will be created. If it does exist then it will
2117
be used.
2118
 
2119
If this option is not specified, then the importation will be based on the 'trunk'.
2120
 
2121
If the Workspace is provided, then it will be used independently of this option.
2122
 
383 dpurdie 2123
A branchName of TIMESTAMP will be treated in special manner. The name will be
2124
replaced with a unique name based on the users name and the current date time.
2125
 
311 dpurdie 2126
=item -replace
2127
 
2128
This option, if provided, allows the label to be replaced.
2129
 
2130
=item -reuse
2131
 
2132
This option can be used to speed the creation of multiple versions in a scripted
2133
environment. The option allows the utility to reuse the workspace if it exists.
2134
 
2135
=item -workspace=path
2136
 
2137
This option specifies an alternate workspace directory to create and use. The
2138
default directory is "SvnImportDir" within the users current directory.
2139
 
2140
=item [no]delete
2141
 
341 dpurdie 2142
This option control the deletion of the workspace directory. By default the
311 dpurdie 2143
directory will be deleted, unless re-use is also used.
2144
 
379 dpurdie 2145
=item -author=name
2146
 
2147
This option will force the author of changes as recorded in the repository.
385 dpurdie 2148
The repository must be configured to allow such changes.
379 dpurdie 2149
 
2150
This option may not work for non-admin users.
2151
 
2152
=item -date=dateString
2153
 
2154
This option will force the date of the changes as recorded in the repository.
385 dpurdie 2155
The repository must be configured to allow such changes.
379 dpurdie 2156
The dateString is in a restricted ISO 8601 format: ie 2009-02-12T00:44:04.921324Z
2157
 
2158
This option may not work for non-admin users.
2159
 
2160
=item -log=text
2161
 
2162
This option will append the specified text to the commit message.
2163
The first line of the commit message is fixed by the import tool.
2164
 
2165
=item -datafile=path
2166
 
2167
This option will cause the utility to create a data file to record the import
2168
tag. It is used for automation of the import process.
2169
 
2429 dpurdie 2170
=item -[no]commit
2171
 
2172
This option will prevent the final workspace from being committed to the
2173
Repository. This allows inspection of the results.
2174
 
2175
The default operation is to commit and label the results of the import.
2176
 
2177
=item -printfiles=n
2178
 
2179
This option controls commit verbosity. The default operation is to display
2180
the files added and removed during the commit.
2181
 
2182
Suitable numbers are: None, 0 (No Display) and 1 (Full Display).
2183
 
2764 dpurdie 2184
=item -mergePaths=dirList
2185
 
2931 dpurdie 2186
This option specifies a Comma separated list of directories to be merged
3967 dpurdie 2187
during the import process. This works via the following mechanism:
2764 dpurdie 2188
 
2189
If the named directory exists in the 'new' image it will replace that in the
2190
'initial' workspace.
2191
 
2192
If the named directory does not exist in the 'new' image, but does exist in the
2193
'initial' image then it will be retained in the 'final' image.
2194
 
2195
Directories other than those named will not be imported.
2196
 
311 dpurdie 2197
=back
2198
 
2199
=head2 DESCRIPTION
2200
 
2201
Import a new version of a package to the trunk of the package. The utility
2202
will only import changed files so that file history is preserved within the
2203
repository.
2204
 
2205
This utility is used import software from another version control system
2206
The utility will:
2207
 
2208
=over
2209
 
361 dpurdie 2210
=item *
311 dpurdie 2211
 
361 dpurdie 2212
Create a Work Space based on the current package version
2213
 
379 dpurdie 2214
The 'trunk' of the named package will be used as the base for the workspace,
2215
unless modified with the -branch option.
311 dpurdie 2216
 
361 dpurdie 2217
=item *
311 dpurdie 2218
 
361 dpurdie 2219
Update files and directories
2220
 
311 dpurdie 2221
Determines the files and directories that have been added and deleted and
2222
update the Workspace to reflect the new structure.
2223
 
361 dpurdie 2224
=item *
311 dpurdie 2225
 
361 dpurdie 2226
Check in the new version
311 dpurdie 2227
 
361 dpurdie 2228
=item *
2229
 
2230
Label the new version
2231
 
311 dpurdie 2232
=back
2233
 
2234
=cut
2235