Subversion Repositories DevTools

Rev

Rev 2048 | Rev 2071 | 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
 
2053 dpurdie 1021
 
2048 dpurdie 1022
    if ( $opt_switch )
1023
    {
1024
        Verbose ("Switching to new branch: $opt_branch");
1025
        $branch_tag = SvnPath2Url($branch_tag);
2053 dpurdie 1026
        chdir ($ws_root) || Error ("Cannot cd to: " .$ws_root);
1027
        $uref->SvnSwitch ($branch_tag, $opt_path, '--Print', '--KeepWs' );
2048 dpurdie 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);
2053 dpurdie 1107
    my $ws_root = $uref->SvnLocateWsRoot(1);
2048 dpurdie 1108
    my $ws_url = $uref->Full();
1109
    my $branch_tag = join ('/', $ws_url, $opt_branch);
1110
 
1111
    #
1112
    #   Validate the branch
1113
    #
1114
    $uref->SvnValidateTarget (
1115
                        'cmd'    => 'svn switch',
1116
                        'target' => $branch_tag,
1117
                        'require' => 1,
1118
                        );
1119
 
2053 dpurdie 1120
    #
1121
    #   Must Change directory before we switch
1122
    #   Otherwise we will import chnages into the wrong place
1123
    #
1124
    chdir ($ws_root) || Error ("Cannot cd to: " . $ws_root);
1125
    $uref->SvnSwitch ($branch_tag, $opt_path, '--Print', '--KeepWs' );
2048 dpurdie 1126
    $opr_done = 1;
1127
}
1128
 
1129
#-------------------------------------------------------------------------------
1130
# Function        : ShowBranches
1131
#
1132
# Description     : Show branches in current workspace
1133
#                   Internal use only
1134
#
1135
# Inputs          : $opt_path           - Optional path
1136
#
1137
# Returns         :
1138
#
1139
sub ShowBranches
1140
{
1141
    my ($opt_path) = @_;
1142
 
1143
    my $uref = NewSessionByWS($opt_path, 0, 1);
1144
    my $ws_url = $uref->Full();
1145
 
1146
    #
1147
    #   Display the packages full URL - allow the user to manuallu look at more
1148
    #   List the bracnhes
1149
    #
1150
    Message ("Url: $ws_url", 'Available Branches');
1151
    SvnUserCmd( 'ls', join ('/', $ws_url, 'branches'), { 'credentials' => 1 });
1152
    $opr_done = 1;
1153
}
1154
#-------------------------------------------------------------------------------
311 dpurdie 1155
# Function        : SubCommandHelp
1156
#
1157
# Description     : Provide help on a subcommand
1158
#
1159
# Inputs          : $help_level             - Help Level 1,2,3
1160
#                   $topic                  - Topic Name
1161
#
1162
# Returns         : This function does not return
1163
#
1164
sub SubCommandHelp
1165
{
1166
    my ($help_level, $topic) = @_;
1167
    my @sections;
1168
    #
1169
    #   Spell out the section we want to display
1170
    #
1171
    #   Note:
1172
    #   Due to bug in pod2usage can't use 'head1' by itself
1173
    #   Each one needs a subsection.
1174
    #
1175
    push @sections, qw( NAME SYNOPSIS ) ;
1176
    push @sections, qw( ARGUMENTS OPTIONS ) if ( $help_level > 1 );
1177
    push @sections, qw( DESCRIPTION )       if ( $help_level > 2 );
1178
 
1179
    #
1180
    #   Extract section from the POD
1181
    #
1182
    pod2usage({-verbose => 99,
1183
               -noperldoc => 1,
1184
               -sections => $topic . '/' . join('|', @sections) } );
1185
}
1186
 
1187
#-------------------------------------------------------------------------------
1188
#   Documentation
1189
#   NOTE
1190
#
1191
#   Each subcommand MUST have
1192
#   head1 section as used by the subcommand
1193
#       This should be empty, as the contents will NOT be displayed
1194
#   head2 sections called
1195
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION
1196
#
1197
#=head1 xxxxxx
1198
#=head2 NAME
1199
#=head2 SYNOPSIS
1200
#=head2 ARGUMENTS
1201
#=head2 OPTIONS
1202
#=head2 DESCRIPTION
1203
#
1204
 
1205
=pod
1206
 
361 dpurdie 1207
=for htmltoc    GENERAL::Subversion::
1208
 
311 dpurdie 1209
=head1 NAME
1210
 
1211
jats svn - Miscellaneous SubVersion Operations
1212
 
1213
=head1 SYNOPSIS
1214
 
1215
jats svn [options] command [command options]
1216
 
1217
 Options:
1218
    -help[=n]              - Help message, [n=1,2,3]
1219
    -man                   - Full documentation [-help=3]
1220
    -verbose[=n]           - Verbose command operation
1221
 
1222
 Common Command Options:
1223
    All command support suboptions to provide command specific help
1224
 
1225
    -help[=n]              - Help message, [n=1,2,3]
1226
    -man                   - Full documentation [-help=3]
1227
 
1228
 Commands are:
363 dpurdie 1229
    test                   - Test access to subversion
369 dpurdie 1230
    paths                  - Display Subversion tag to URL conversions
311 dpurdie 1231
    ls URL                 - List Repo contents for URL
369 dpurdie 1232
    tag [URL]              - Convert URL or Path to a Release Manager Tag
1233
    url [TAG]              - Convert TAG or Path to a Subversion URL
2048 dpurdie 1234
    create-package URL     - Create a new package at URL
311 dpurdie 1235
    delete-package URL     - Delete Package Subtree
2048 dpurdie 1236
    branch BRANCH          - Create a Development Branch
1237
    switch [BRANCH]        - Switch to a Development Branch
385 dpurdie 1238
    delete-branch          - Delete a Development Branch
311 dpurdie 1239
    import URL             - Import files to package at URL
1240
 
1241
 Use the command
1242
    jats svn command -h
1243
 for command specific help
1244
 
1245
=head1 OPTIONS
1246
 
1247
=over
1248
 
1249
=item B<-help[=n]>
1250
 
1251
Print a help message and exit. The level of help may be either 1, 2 or
1252
3 for a full manual.
1253
 
1254
This option may be specified multiple times to increment the help level, or
1255
the help level may be directly specified as a number.
1256
 
1257
=item B<-man>
1258
 
1259
This is the same as '-help=3'.
1260
The complete help is produced in a man page format.
1261
 
1262
=item B<--verbose[=n]>
1263
 
1264
This option will increase the level of verbosity of the commands.
1265
 
1266
If an argument is provided, then it will be used to set the level, otherwise the
1267
existing level will be incremented. This option may be specified multiple times.
1268
 
1269
=back
1270
 
1271
=head1 DESCRIPTION
1272
 
1273
This program provides a number of useful Subversion based operations.
1274
 
363 dpurdie 1275
=head1 Test Subversion
1276
 
1277
=head2 NAME
1278
 
1279
Test Subversion
1280
 
1281
=head2 SYNOPSIS
1282
 
1283
    jats svn test
1284
 
1285
=head2 DESCRIPTION
1286
 
1287
This command will ensure that the subversion command line utility can be
1288
located. The command will report the version of the svn client found.
1289
 
369 dpurdie 1290
=head1 Subversion Paths
1291
 
1292
=head2 NAME
1293
 
1294
Subversion Paths
1295
 
1296
=head2 SYNOPSIS
1297
 
1298
    jats svn paths
1299
 
1300
=head2 DESCRIPTION
1301
 
1302
This command will display the base Tags and associated URLs that are used by
1303
JATS to convert a 'Subversion Tag' into a full URLs that will be used to access
1304
a physical repository.
1305
 
1306
The 'Tags' configuration is site-specific.
1307
 
311 dpurdie 1308
=head1 List Repository
1309
 
363 dpurdie 1310
=head2 NAME
1311
 
1312
List Repository
1313
 
1314
=head2 SYNOPSIS
1315
 
1316
    jats svn ls <URL>
1317
 
1318
=head2 DESCRIPTION
1319
 
311 dpurdie 1320
This command will take a URL and perform a 'svn' list operation. The URL will
1321
be expanded to include the site specific repository.
1322
 
369 dpurdie 1323
=head1 Url to Tag
1324
 
1325
=head2 NAME
1326
 
1327
Url to Tag
1328
 
1329
=head2 SYNOPSIS
1330
 
1331
    jats svn tag [Option] [tag]
1332
 
1333
 Options:
1334
    -help[=n]              - Help message, [n=1,2,3]
1335
    -man                   - Full documentation [-help=3]
1336
    -path=path             - Convert specified path
1337
    -url=url               - Convert specified URL
1338
 
1339
=head2 DESCRIPTION
1340
 
1341
This command will convert a URL or a PATH to a Subversion Tag that can
1342
be used within the remainder of the build system. If no PATH or URL is provided,
1343
then the command uses a path of the current directory.
1344
 
1345
The command will convert either a PATH or a URL. It will not do both.
1346
 
1347
The command will use the configured Subversion URL prefixes to create the Tag.
1348
 
1349
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1350
The conversion will return a Tag to the root of the Workspace and Peg it to
1351
the last committed version. The command will not determine if the workspace
1352
contains modified files.
1353
 
1354
If a URL is to be converted, then the resultant value should be used with
1355
caution. The result is only as good as the provided URL and may not address
1356
the root of a package.
1357
 
1358
=head1 Tag to Url
1359
 
1360
=head2 NAME
1361
 
1362
Tag to Url
1363
 
1364
=head2 SYNOPSIS
1365
 
1366
    jats svn url [Option] [url]
1367
 
1368
 Options:
1369
    -help[=n]              - Help message, [n=1,2,3]
1370
    -man                   - Full documentation [-help=3]
1371
    -path=path             - Convert specified path
1372
    -url=url               - Convert specified URL
1373
 
1374
=head2 DESCRIPTION
1375
 
1376
This command will convert a TAG or a PATH to a full URL that can be used
1377
directly by Subversion. If no PATH or TAG is provided, then the command uses a
1378
path of the current directory.
1379
 
1380
The command will convert either a TAG or a URL. It will not do both.
1381
 
1382
The command will use the configured Subversion URL prefixes to expand the TAG.
1383
 
1384
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1385
The conversion will return a URL to the root of the Workspace and Peg it to
1386
the last committed version. The command will not determine if the workspace
1387
contains modified files.
1388
 
1389
If a TAG is to be converted, then the resultant value should be used with
1390
caution. The result is only as good as the provided URL and may not address
1391
the root of a package.
1392
 
2048 dpurdie 1393
=head1 Create a Package Version
1394
 
1395
=head2 NAME
1396
 
1397
Create a Package Version
1398
 
1399
=head2 SYNOPSIS
1400
 
1401
jats svn [options] create-package URL [command options]
1402
 
1403
 Options:
1404
    -help[=n]               - Help message, [n=1,2,3]
1405
    -man                    - Full documentation [-help=3]
1406
    -verbose[=n]            - Verbose command operation
1407
 
1408
 Command Options
1409
    -help[=n]               - Provide command specific help
1410
    -new                    - Package must not exist
1411
    -replace                - Replace any existing versions
1412
    -import=nnn             - Import directory tree
1413
    -label=nnn              - Label imported package
1414
    -trunk                  - Import to trunk (default)
1415
    -tags=nnn               - Import to tags
1416
    -branch=nnn             - Import to branches
1417
 
1418
=head2 ARGUMENTS
1419
 
1420
The command takes one argument: The URL of the desired package.
1421
This may be be:
1422
 
1423
=over
1424
 
1425
=item * A full URL
1426
 
1427
Complete with protocol and path information.
1428
 
1429
=item * A simple URL
1430
 
1431
JATS will prepend the site-specific repository location to the user provided URL
1432
 
1433
=back
1434
 
1435
=head2 OPTIONS
1436
 
1437
=over
1438
 
1439
=item -help[=n]
1440
 
1441
Print a help message and exit. The level of help may be either 1, 2 or 3.
1442
 
1443
This option may be specified multiple times to increment the help level, or
1444
the help level may be directly specified as a number.
1445
 
1446
=item -new
1447
 
1448
This option specifies that the named package MUST not exist at all.
1449
 
1450
=item -replace
1451
 
1452
This option allows the program to replace any existing versions of the
1453
imported source. It will allow the deletion of any existing trunk, tags or
1454
branches.
1455
 
1456
=item -import=nnn
1457
 
1458
This option specifies the path of a subdirectory tree to import into the newly
1459
created package. In not provided, then only a package skeleton will be created.
1460
 
1461
=item -label=nnn
1462
 
1463
This option specifies a label to place the imported source.
1464
 
1465
=item -trunk
1466
 
1467
This option specifies that imported source will be placed on the trunk of the
1468
package. This is the default mode of import.
1469
 
1470
The options -trunk, -tags and -branch are mutually exclusive.
1471
 
1472
=item -tags=nnn
1473
 
1474
This option specifies that imported source will be placed directly on the
1475
named tag of the package.
1476
 
1477
The options -trunk, -tags and -branch are mutually exclusive.
1478
 
1479
=item -branch=nnn
1480
 
1481
This option specifies that imported source will be placed directly on the
1482
named branch of the package.
1483
 
1484
The options -trunk, -tags and -branch are mutually exclusive.
1485
 
1486
=back
1487
 
1488
=head2 DESCRIPTION
1489
 
1490
This command will create a new package within a repository. It will ensure
1491
that the package contains the three required subdirectories: trunk, tags and
1492
branches.
1493
 
1494
The command will also ensure that packages are not placed at inappropriate
1495
locations within the repository. It is not correct to place a package within
1496
another package.
1497
 
1498
The command will, optionally, import a directory tree into the repository and,
1499
optionally, label the package.
1500
 
1501
The package body may be imported to the 'trunk' or to a branch or a tag.
1502
By default the data will be imported to the trunk and may be labeled (tagged).
1503
 
1504
Options allow the targets to be deleted if they exist or to ensure that they
1505
are not present.
1506
 
1507
The command does not attempt to merge file versions within the repository. It
1508
may result in multiple instances of a file within the repository. Use only for
1509
simple imports. Use the 'import' command for more sophisticated import requirements.
1510
 
311 dpurdie 1511
=head1 Delete a Package
1512
 
1513
=head2 NAME
1514
 
1515
Delete a Package
1516
 
1517
=head2 SYNOPSIS
1518
 
1519
jats svn delete-package URL [options]
1520
 
1521
 Options:
1522
    -help[=n]              - Help message, [n=1,2,3]
1523
    -man                   - Full documentation [-help=3]
1524
    -verbose[=n]           - Verbose command operation
1525
 
1526
=head2 ARGUMENTS
1527
 
1528
The command takes one argument: The URL of the desired package.
1529
This may be be:
1530
 
1531
=over
1532
 
1533
=item * A full URL
1534
 
1535
Complete with protocol and path information.
1536
 
1537
=item * A simple URL
1538
 
1539
JATS will prepend the site-specific repository location to the user provided URL
1540
 
1541
=back
1542
 
1543
=head2 OPTIONS
1544
 
1545
This command has no significant options, other than the general help options.
1546
 
1547
=head2 DESCRIPTION
1548
 
1549
This command will delete a package from the repository. It will ensure
1550
that the package is a valid package, before it is deleted.
1551
 
1552
The command is intended to be used by test scripts, rather than users.
1553
 
2048 dpurdie 1554
=head1 Create Branch
385 dpurdie 1555
 
1556
=head2 NAME
1557
 
2048 dpurdie 1558
Create a Workspace Branch
385 dpurdie 1559
 
1560
=head2 SYNOPSIS
1561
 
2048 dpurdie 1562
jats svn branch branch-name [options]
385 dpurdie 1563
 
1564
 Options:
1565
    -help[=n]              - Help message, [n=1,2,3]
1566
    -man                   - Full documentation [-help=3]
1567
    -verbose[=n]           - Verbose command operation
1568
    -path=path             - Target workspace
2048 dpurdie 1569
    -[no]switch            - Switch to new branch(default)
1570
    -comment=text          - Comment to apply to the new branch
385 dpurdie 1571
 
1572
=head2 ARGUMENTS
1573
 
2048 dpurdie 1574
The command takes one argument. The name of the branch to be created.
385 dpurdie 1575
 
1576
=head2 OPTIONS
1577
 
1578
=over
1579
 
1580
=item B<-path=path>
1581
 
1582
This options specifies the path of the target workspace. If not provided the
1583
command will use the current directory.
1584
 
2048 dpurdie 1585
=item B<-[no]switch>
1586
 
1587
If enabled (the default) the workspace will be switched to the new branch at
1588
the end of the process.
1589
 
1590
=item B<-comment=text>
1591
 
1592
If present, the specified text will be used as a Subversion comment when the
1593
branch is created.
1594
 
1595
If not provided, then JATS will provide a basic comment.
1596
 
385 dpurdie 1597
=back
1598
 
1599
=head2 DESCRIPTION
1600
 
2048 dpurdie 1601
This command will create a named branch associated with the workspace in the
1602
specified path. It is intended to simplify the creation of Private or
385 dpurdie 1603
Development branches.
1604
 
2048 dpurdie 1605
If the named branch already exists, then the command will fail.
385 dpurdie 1606
 
2048 dpurdie 1607
The command performs a server-side copy. It will not commit any locally
1608
modified files. Nor will it inform you if there are any.
311 dpurdie 1609
 
2048 dpurdie 1610
By default, the user is 'switched' to the newly created branch.
1611
 
1612
=head1 Switch Branch
1613
 
311 dpurdie 1614
=head2 NAME
1615
 
2048 dpurdie 1616
Switch a Workspace Branch
311 dpurdie 1617
 
1618
=head2 SYNOPSIS
1619
 
2048 dpurdie 1620
jats svn switch [branch-name] [options]
311 dpurdie 1621
 
1622
 Options:
2048 dpurdie 1623
    -help[=n]              - Help message, [n=1,2,3]
1624
    -man                   - Full documentation [-help=3]
1625
    -verbose[=n]           - Verbose command operation
1626
    -path=path             - Target workspace
311 dpurdie 1627
 
1628
=head2 ARGUMENTS
1629
 
2048 dpurdie 1630
The command takes one optional argument. The name of the target branch.
311 dpurdie 1631
 
2048 dpurdie 1632
=head2 OPTIONS
1633
 
311 dpurdie 1634
=over
1635
 
2048 dpurdie 1636
=item B<-path=path>
311 dpurdie 1637
 
2048 dpurdie 1638
This options specifies the path of the target workspace. If not provided the
1639
command will use the current directory.
311 dpurdie 1640
 
2048 dpurdie 1641
=back
311 dpurdie 1642
 
2048 dpurdie 1643
=head2 DESCRIPTION
311 dpurdie 1644
 
2048 dpurdie 1645
This command will switch the users workspace to the named branch. This is
1646
identical to the Subversion switch command, except it is easier to user and
1647
has several validity checks and other enhancements.
311 dpurdie 1648
 
2048 dpurdie 1649
The command has two modes of operation:
311 dpurdie 1650
 
2048 dpurdie 1651
=over 4
311 dpurdie 1652
 
2048 dpurdie 1653
=item   1. Display a list of branched in the current package.
311 dpurdie 1654
 
2048 dpurdie 1655
If no branch is specified, then the utility will display a list of branches in
1656
the packages 'branches' directory.
311 dpurdie 1657
 
2048 dpurdie 1658
=item   2. Switch to the named branch.
311 dpurdie 1659
 
2048 dpurdie 1660
The named branch must exists otherwise the command will fail.
311 dpurdie 1661
 
2048 dpurdie 1662
There are two spcial variants of the branch name:
311 dpurdie 1663
 
2048 dpurdie 1664
=over 4
311 dpurdie 1665
 
2048 dpurdie 1666
=item trunk
311 dpurdie 1667
 
2048 dpurdie 1668
If the branch is named 'trunk' then it will refer to the packages truck
1356 dpurdie 1669
 
2048 dpurdie 1670
=item tags
1356 dpurdie 1671
 
2048 dpurdie 1672
If the branch name starts with 'tags/', then the command will refer to
1673
a tag within the package and not a branch.
1356 dpurdie 1674
 
2048 dpurdie 1675
=back
1356 dpurdie 1676
 
2048 dpurdie 1677
The command will add and remove unmodified files from the workspace during this
1678
operation.
311 dpurdie 1679
 
2048 dpurdie 1680
=back
311 dpurdie 1681
 
2048 dpurdie 1682
=head3 Examples
311 dpurdie 1683
 
2048 dpurdie 1684
To switch to the packages trunk
311 dpurdie 1685
 
2048 dpurdie 1686
    jats svn switch trunk
311 dpurdie 1687
 
2048 dpurdie 1688
To switch to the a branch called MyBranch
311 dpurdie 1689
 
2048 dpurdie 1690
    jats svn switch MyBranch
311 dpurdie 1691
 
2048 dpurdie 1692
To switch to a tagged version of the package
311 dpurdie 1693
 
2048 dpurdie 1694
    jats svn switch tags/MyPackage_1.0.0000.cr
311 dpurdie 1695
 
2048 dpurdie 1696
To display a list of available branches (not tags)
311 dpurdie 1697
 
2048 dpurdie 1698
    jats svn switch
311 dpurdie 1699
 
2048 dpurdie 1700
=head1 Delete Branch
311 dpurdie 1701
 
2048 dpurdie 1702
=head2 NAME
311 dpurdie 1703
 
2048 dpurdie 1704
Delete the Workspace Branch
311 dpurdie 1705
 
2048 dpurdie 1706
=head2 SYNOPSIS
311 dpurdie 1707
 
2048 dpurdie 1708
jats svn delete-branch [options]
311 dpurdie 1709
 
2048 dpurdie 1710
 Options:
1711
    -help[=n]              - Help message, [n=1,2,3]
1712
    -man                   - Full documentation [-help=3]
1713
    -verbose[=n]           - Verbose command operation
1714
    -path=path             - Target workspace
311 dpurdie 1715
 
2048 dpurdie 1716
=head2 ARGUMENTS
1717
 
1718
The command takes no arguments.
1719
 
1720
=head2 OPTIONS
1721
 
1722
=over
1723
 
1724
=item B<-path=path>
1725
 
1726
This options specifies the path of the target workspace. If not provided the
1727
command will use the current directory.
1728
 
1729
=back
1730
 
1731
=head2 DESCRIPTION
1732
 
1733
This command will delete the branch associated with the workspace in the
1734
specified path. It is intended to simplify the deletion of Private or
1735
Development branches.
1736
 
1737
If the workspace is not linked to a 'branch' then the command will fail.
1738
 
311 dpurdie 1739
=head1 Import directory to a Package
1740
 
1741
=head2 NAME
1742
 
1743
Import directory to a Package
1744
 
1745
=head2 SYNOPSIS
1746
 
1747
jats svn [options] import URL [command options]
1748
 
1749
 Options:
1750
    -help[=n]               - Help message, [n=1,2,3]
1751
    -man                    - Full documentation [-help=3]
1752
    -verbose[=n]            - Verbose command operation
1753
 
1754
 Command Options
1755
    -help[=n]               - Command specific help, [n=1,2,3]
1756
    -verbose[=n]            - Verbose operation
1757
    -package=name           - Name of source package
1758
    -dir=path               - Path to new version
379 dpurdie 1759
    -label=label            - Label the result
1760
    -branch=branchName      - Base import on a branch
311 dpurdie 1761
    -replace                - Allow the label to be replaced
1762
    -reuse                  - Reuse the import directory
1763
    -workspace=path         - Path and name of alternate workspace
1764
    -[no]delete             - Deletes workspace after use. Default:yes
379 dpurdie 1765
    -author=name            - Force author of changes
1766
    -date=dateString        - Force date of changes
1767
    -log=text               - Append text to the commit message
1768
    -datafile=path          - Export tag data for automation
311 dpurdie 1769
 
1770
=head2 ARGUMENTS
1771
 
1772
The command takes one argument: The URL of the desired package.
1773
This may be be:
1774
 
1775
=over
1776
 
1777
=item * A full URL
1778
 
1779
Complete with protocol and path information.
1780
 
1781
=item * A simple URL
1782
 
1783
JATS will prepend the site-specific repository location to the user provided URL
1784
 
1785
=back
1786
 
1787
=head2 OPTIONS
1788
 
1789
=over
1790
 
1791
=item -help[=n]
1792
 
1793
Print a help message and exit. The level of help may be either 1, 2 or 3.
1794
 
1795
This option may be specified multiple times to increment the help level, or
1796
the help level may be directly specified as a number.
1797
 
1798
=item -verbose[=n]
1799
 
1800
This option will increase the level of verbosity of the utility.
1801
 
1802
If an argument is provided, then it will be used to set the level, otherwise the
1803
existing level will be incremented. This option may be specified multiple times.
1804
 
1805
=item -package=name
1806
 
1807
Either this option or a bare URL on the command line must be provided. It
1808
specifies the repository and package to be used as a basis for the work.
1809
 
1810
=item -dir=path
1811
 
1812
This option is mandatory. It specifies the path to a local directory that
1813
contains a version of the software to be checked in.
1814
 
1815
=item -label=name
1816
 
1817
The resulting software version will be labeled with this tag, if it is provided.
1818
 
383 dpurdie 1819
A label name of TIMESTAMP will be treated in special manner. The name will be
1820
replaced with a unique name based on the users name and the current date time.
1821
 
379 dpurdie 1822
=item -branch=branchName
1823
 
1824
This option will cause the importation to be referenced to the named branch.
1825
If the branch does not exist it will be created. If it does exist then it will
1826
be used.
1827
 
1828
If this option is not specified, then the importation will be based on the 'trunk'.
1829
 
1830
If the Workspace is provided, then it will be used independently of this option.
1831
 
383 dpurdie 1832
A branchName of TIMESTAMP will be treated in special manner. The name will be
1833
replaced with a unique name based on the users name and the current date time.
1834
 
311 dpurdie 1835
=item -replace
1836
 
1837
This option, if provided, allows the label to be replaced.
1838
 
1839
=item -reuse
1840
 
1841
This option can be used to speed the creation of multiple versions in a scripted
1842
environment. The option allows the utility to reuse the workspace if it exists.
1843
 
1844
=item -workspace=path
1845
 
1846
This option specifies an alternate workspace directory to create and use. The
1847
default directory is "SvnImportDir" within the users current directory.
1848
 
1849
=item [no]delete
1850
 
341 dpurdie 1851
This option control the deletion of the workspace directory. By default the
311 dpurdie 1852
directory will be deleted, unless re-use is also used.
1853
 
379 dpurdie 1854
=item -author=name
1855
 
1856
This option will force the author of changes as recorded in the repository.
385 dpurdie 1857
The repository must be configured to allow such changes.
379 dpurdie 1858
 
1859
This option may not work for non-admin users.
1860
 
1861
=item -date=dateString
1862
 
1863
This option will force the date of the changes as recorded in the repository.
385 dpurdie 1864
The repository must be configured to allow such changes.
379 dpurdie 1865
The dateString is in a restricted ISO 8601 format: ie 2009-02-12T00:44:04.921324Z
1866
 
1867
This option may not work for non-admin users.
1868
 
1869
=item -log=text
1870
 
1871
This option will append the specified text to the commit message.
1872
The first line of the commit message is fixed by the import tool.
1873
 
1874
=item -datafile=path
1875
 
1876
This option will cause the utility to create a data file to record the import
1877
tag. It is used for automation of the import process.
1878
 
311 dpurdie 1879
=back
1880
 
1881
=head2 DESCRIPTION
1882
 
1883
Import a new version of a package to the trunk of the package. The utility
1884
will only import changed files so that file history is preserved within the
1885
repository.
1886
 
1887
This utility is used import software from another version control system
1888
The utility will:
1889
 
1890
=over
1891
 
361 dpurdie 1892
=item *
311 dpurdie 1893
 
361 dpurdie 1894
Create a Work Space based on the current package version
1895
 
379 dpurdie 1896
The 'trunk' of the named package will be used as the base for the workspace,
1897
unless modified with the -branch option.
311 dpurdie 1898
 
361 dpurdie 1899
=item *
311 dpurdie 1900
 
361 dpurdie 1901
Update files and directories
1902
 
311 dpurdie 1903
Determines the files and directories that have been added and deleted and
1904
update the Workspace to reflect the new structure.
1905
 
361 dpurdie 1906
=item *
311 dpurdie 1907
 
361 dpurdie 1908
Check in the new version
311 dpurdie 1909
 
361 dpurdie 1910
=item *
1911
 
1912
Label the new version
1913
 
311 dpurdie 1914
=back
1915
 
1916
=cut
1917