Subversion Repositories DevTools

Rev

Go to most recent revision | Details | 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;
24
 
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;
32
 
33
my $VERSION = "1.0.0";                          # Update this
34
 
35
#
36
#   Options
37
#
38
my $opt_debug   = $ENV{'GBE_DEBUG'};            # Allow global debug
39
my $opt_verbose = $ENV{'GBE_VERBOSE'};          # Allow global verbose
40
my $opt_help = 0;
41
 
42
#
43
#   Globals
44
#
45
my $opr_done;                                   # User has done something
46
 
47
#-------------------------------------------------------------------------------
48
# Function        : Mainline Entry Point
49
#
50
# Description     :
51
#
52
# Inputs          :
53
#
54
my $result = GetOptions (
55
                "help:+"        => \$opt_help,              # flag, multiple use allowed
56
                "manual:3"      => \$opt_help,              # flag
57
                "verbose:+"     => \$opt_verbose,           # flag, multiple use allowed
58
 
59
                );
60
 
61
                #
62
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
63
                #
64
 
65
#
66
#   Process help and manual options
67
#
68
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
69
pod2usage(-verbose => 1) if ($opt_help == 2 );
70
pod2usage(-verbose => 2) if ($opt_help > 2);
71
 
72
#
73
#   Configure the error reporting process now that we have the user options
74
#
75
ErrorConfig( 'name'    =>'SVN',
76
             'verbose' => $opt_verbose,
77
            );
78
 
79
#
80
#   Reconfigure the optiosn parser to allow subcommands to parse options
81
#
82
Getopt::Long::Configure('permute');
83
 
84
#
85
#   Process command
86
#   First command line argument is a subversion command
87
#
88
my $cmd = shift @ARGV || "help";
89
CreatePackage()                        if ( $cmd =~ m/^create/ );
90
DeletePackage()                        if ( $cmd =~ m/^delete-package/ );
91
ImportPackage()                        if ( $cmd =~ m/^import/ );
92
SvnRepoCmd($cmd, @ARGV)                if ( $cmd eq 'ls' );
363 dpurdie 93
TestSvn()                              if ($cmd eq 'test');
311 dpurdie 94
 
95
pod2usage(-verbose => 0, -message => "No valid operations specified") unless ( $opr_done );
96
exit 0;
97
 
98
#-------------------------------------------------------------------------------
363 dpurdie 99
# Function        : TestSvn
100
#
101
# Description     : Test access to subversion
102
#
103
# Inputs          : None
104
#
105
# Returns         :
106
#
107
sub TestSvn
108
{
109
    #
110
    #   Parse more options
111
    #
112
    GetOptions (
113
                "help:+"        => \$opt_help,
114
                "manual:3"      => \$opt_help,
115
                ) || Error ("Invalid command line" );
116
 
117
    #
118
    #   Subcommand specific help
119
    #
120
    SubCommandHelp( $opt_help, "Test Subversion") if ($opt_help || $#ARGV >= 0);
121
 
122
    SvnUserCmd( '--version');
123
    $opr_done = 1;
124
}
125
 
126
 
127
#-------------------------------------------------------------------------------
311 dpurdie 128
# Function        : SvnRepoCmd
129
#
130
# Description     : Execute a SVN command, where the first argument
131
#                   is a repository specifier
132
#
133
# Inputs          : $cmd
134
#                   $repo_url
135
#                   @opts
136
#
137
# Returns         : 
138
#
139
sub SvnRepoCmd
140
{
141
    my ( $cmd, $repo_url, @opts ) = @_;
142
    my $uref = NewSessionByUrl ( $repo_url );
143
 
144
    SvnUserCmd( $cmd,
145
            $uref->Full,
146
            @opts,
147
            { 'credentials' => 1 });
148
 
149
    $opr_done = 1;
150
}
151
 
152
#-------------------------------------------------------------------------------
153
# Function        : DeletePackage
154
#
155
# Description     : Delete a Package structure within a Repository
156
#                   Intended for test usage
157
#
158
# Inputs          : URL                 - Url to Repo + Package Base
159
#
160
# Returns         : 
161
#
162
sub DeletePackage
163
{
164
    #
165
    #   Parse more options
166
    #
167
    GetOptions (
168
                "help:+"        => \$opt_help,
169
                "manual:3"      => \$opt_help,
170
                ) || Error ("Invalid command line" );
171
 
172
    #
173
    #   Subcommand specific help
174
    #
175
    SubCommandHelp( $opt_help, "Delete a Package") if ($opt_help || $#ARGV < 0);
176
 
177
    #
178
    #   Sanity Tests
179
    #
180
    Message ("Delete Entire Package Tree" );
181
    Warning ("Too many arguments: @ARGV") if ( $#ARGV >= 1 );
182
 
183
    #
184
    #   Do all the hard work
185
    #       Create
186
    #       Import
187
    #       Label
188
    #
189
    my $uref = NewSessionByUrl ( $ARGV[0] );
190
    $uref->SvnValidatePackageRoot();
191
    $uref->SvnDelete (
192
                      'target'      => $uref->Full,
193
                      'comment'   => ['Deleted by user command','jats svn delete-package'],
194
                      'noerror'     => 0,
195
                      );
196
    $opr_done = 1;
197
}
198
 
199
#-------------------------------------------------------------------------------
200
# Function        : CreatePackage
201
#
202
# Description     : Create a Package structure within a Repository
203
#                   Optionally Import Data
204
#                   Optionally Tag the import
205
#                   Optionally Tag the import on a branch
206
#
207
# Inputs          : URL                 - Url to Repo + Package Base
208
#                   Options             - Command modifiers
209
#                       -import=path    - Import named directory
210
#                       -label=name     - Label the result
211
#                       -tag=name       - Import to Tag Only
212
#                       -branch=name    - Import to Branch only
213
#                       -new            - Must be new package
214
#                       -replace        - Replace existing
215
#
216
# Returns         : 
217
#
218
sub CreatePackage
219
{
220
    my $opt_import;
221
    my $opt_tag;
222
    my $opt_branch;
223
    my $opt_trunk;
224
    my $opt_new;
225
    my $opt_label;
226
    my $opt_replace;
227
    my $pname;
228
    my $type;
229
 
230
 
231
    Message ("Create New Package Version" );
232
 
233
    #
234
    #   Parse more options
235
    #
236
    GetOptions (
237
                "help:+"        => \$opt_help,
238
                "manual:3"      => \$opt_help,
239
                "verbose:+"     => \$opt_verbose,
240
                "import=s"      => \$opt_import,
241
                "new"           => \$opt_new,
242
                "branch=s"      => \$opt_branch,
243
                "trunk"         => \$opt_trunk,
244
                "tag=s"         => \$opt_tag,
245
                "label=s"       => \$opt_label,
246
                "replace"       => \$opt_replace,
247
 
248
                ) || Error ("Invalid command line" );
249
 
250
    #
251
    #   Subcommand specific help
252
    #
253
    SubCommandHelp( $opt_help, "Create a Package Version") if ($opt_help || $#ARGV < 0);
254
 
255
    #
256
    #   Alter the error reporting paramters
257
    #
258
    ErrorConfig( 'verbose' => $opt_verbose );
259
 
260
    #
261
    #   Sanity Tests
262
    #
263
    my $count = 0;
264
    $count++ if ( $opt_trunk );
265
    $count++ if ( $opt_branch );
266
    $count++ if ( $opt_tag );
267
    Error ("Conflicting options: -trunk, -tag, -branch") if ( $count > 1 );
268
    Error ("Nothing imported to be labeled") if ( $count && !$opt_import );
269
    Error ("Import path does not exist: $opt_import") if ( $opt_import && ! -d $opt_import );
270
    Error ("Conflicting options: new and replace") if ( $opt_new && $opt_replace );
271
 
272
    ($type, $opt_label) = ('tags', $opt_tag)            if ( $opt_tag);
273
    ($type, $opt_label) = ('branches', $opt_branch)     if ( $opt_branch );
274
    ($type, $opt_label) = ('trunk', $opt_label)         if ( $opt_trunk);
275
 
276
    #
277
    #   Do all the hard work
278
    #       Create
279
    #       Import
280
    #       Label
281
    #
282
    my $uref = NewSessionByUrl ( $ARGV[0] );
283
    $uref->SvnCreatePackage (
284
                      'import'  => $opt_import,
285
                      'label'   => $opt_label,
286
                      'type'    => $type,
287
                      'new'     => $opt_new,
288
                      'replace' => $opt_replace,
289
                      );
290
    Message ("Repository Ref: " . $uref->RmRef);
291
    $opr_done = 1;
292
}
293
 
294
#-------------------------------------------------------------------------------
295
# Function        : ImportPackage
296
#
297
# Description     : Import a new version of a package
298
#                   Take great care to reuse file-versions that are already in
299
#                   the  package
300
#
301
#                   Intended to allow the imprtation of multiple
302
#                   versions of a package
303
#
304
# Inputs          : 
305
#
306
# Returns         : 
307
#
308
sub ImportPackage
309
{
310
    Message ("Import Package Version" );
311
 
312
    #
313
    #   Options
314
    #
315
    my $opt_package;
316
    my $opt_dir;
317
    my $opt_label;
318
    my $opt_replace = 0;
319
    my $opt_reuse;
320
    my $opt_workdir = "SvnImportDir";
321
    my $opt_delete = 1;
322
 
323
    #
324
    #   Other globals
325
    #
326
    my $url_label;
327
 
328
    #
329
    #   Configuration options
330
    #
331
    my $result = GetOptions (
332
                    "help:+"        => \$opt_help,
333
                    "manual:3"      => \$opt_help,
334
                    "verbose:+"     => \$opt_verbose,
335
                    "package=s"     => \$opt_package,
336
                    "dir=s"         => \$opt_dir,
337
                    "label=s"       => \$opt_label,
338
                    "replace"       => \$opt_replace,
339
                    "reuse"         => \$opt_reuse,
340
                    "workspace=s"   => \$opt_workdir,
341
                    "delete!"       => \$opt_delete,
342
 
343
                    #
344
                    #   Update documentation at the end of the file
345
                    #
346
                    ) || Error ("Invalid command line" );
347
 
348
    #
349
    #   Insert defaults
341 dpurdie 350
    #   User can specify base package via -package or a non-options argument
311 dpurdie 351
    #
352
    $opt_package = $ARGV[0] unless ( $opt_package );
353
 
354
    #
355
    #   Subcommand specific help
356
    #
357
    SubCommandHelp( $opt_help, "Import directory to a Package")
358
        if ($opt_help || ! $opt_package );
359
 
360
    #
361
    #   Alter the error reporting paramters
362
    #
363
    ErrorConfig( 'verbose' => $opt_verbose );
364
 
365
    #
366
    #   Configure the error reporting process now that we have the user options
367
    #
368
    Error ("No package URL specified") unless ( $opt_package );
369
    Error ("No base directory specified") unless ( $opt_dir );
370
    Error ("Invalid base directory: $opt_dir") unless ( -d $opt_dir );
371
 
372
    #
373
    #   Create an SVN session
374
    #
375
    my $svn = NewSessionByUrl ( $opt_package );
376
 
377
    #
378
    #   Ensure that the required label is available
379
    #
380
    if ( $opt_label )
381
    {
382
        $opt_label = SvnIsaSimpleLabel ($opt_label);
383
        $url_label = $svn->BranchName( $opt_label, 'tags' );
384
        $svn->SvnValidateTarget (
385
                        'target' => $url_label,
386
                        'available' => 1,
387
                        ) unless ( $opt_replace );
388
    }
389
 
390
    #
391
    #   Create a workspace based on the users package
392
    #   Allow the workspace to be reused to speed up multiple
393
    #   operations
394
    #
395
    unless ( $opt_reuse && -d $opt_workdir )
396
    {
397
        Message ("Creating Workspace");
398
        rmtree( $opt_workdir );
399
 
400
        $svn->SvnValidatePackageRoot ();
401
        #DebugDumpData( 'Svn', $svn );
402
        $svn->SvnValidateTarget (
403
                            'cmd'    => 'SvnImporter',
404
                            'target' => $svn->Full,
405
                            'require' => 1,
406
                            );
407
 
408
        $svn->SvnCo ( $svn->Full . '/trunk', $opt_workdir );
409
        Error ("Cannot locate the created Workspace")
410
            unless ( -d $opt_workdir );
411
    }
412
    else
413
    {
414
        Message ("Reusing Workspace");
415
    }
416
 
417
    #
418
    #   Determine differences between the two folders
419
    #       Create structures for each directory
420
    #
421
    Message ("Determine Files in packages");
422
 
423
    my $search = JatsLocateFiles->new("--Recurse=1",
424
                                       "--DirsToo",
425
                                       "--FilterOutRe=/\.svn/",
426
                                       "--FilterOutRe=/\.svn\$",
427
                                       "--FilterOutRe=^/${opt_workdir}\$",
428
                                       "--FilterOutRe=^/${opt_workdir}/",
429
                                       );
430
    my @ws = $search->search($opt_workdir);
431
    my @dir = $search->search($opt_dir);
432
 
433
    #Information ("WS Results", @ws);
434
    #Information ("DIR Results", @dir);
435
 
436
    #
437
    #   Create a hash the Workspace and the User dir
438
    #   The key will be file names
439
    #
440
    my %ws;  map ( $ws{$_} = 1 , @ws );
441
    my %dir; map ( $dir{$_} = 1 , @dir );
442
 
443
    #
444
    #   Create a hash of common elements
445
    #   Removing then from the other two
446
    #
447
    my %common;
448
    foreach ( keys %ws )
449
    {
450
        next unless ( exists $dir{$_} );
451
        $common{$_} = 1;
452
        delete $ws{$_};
453
        delete $dir{$_};
454
    }
455
 
456
    #DebugDumpData( 'WS', \%ws );
457
    #DebugDumpData( 'DIR', \%dir );
458
    #DebugDumpData( 'COMMON', \%common );
459
 
460
    #
461
    #   Add New Files
462
    #   Won't add empty directories at this point
463
    #
464
    #   Process by sorted list
465
    #   This will ensure we process parent directories first
466
    #
467
    my @added = sort keys %dir;
468
 
469
    if ( @added )
470
    {
471
        foreach my $file ( @added  )
472
        {
473
            my $src = "$opt_dir/$file";
474
            my $target = "$opt_workdir/$file";
475
 
476
            if ( -d $src )
477
            {
478
                mkdir ( $target ) unless (-d $target);
479
            }
480
            else
481
            {
482
 
483
                my $path = dirname ( $target);
484
                mkdir ( $path ) unless (-d $path);
485
 
486
                Verbose ("Adding $file");
487
                unless (File::Copy::copy( $src, $target ))
488
                {
489
                    Error("Failed to transfer file [$file]: $!");
490
                }
491
            }
492
        }
493
 
494
        #
495
        #   Inform Subversion about the added files
496
        #   The command line does have a finite length, so add them 200 at a
497
        #   time.
498
        #
499
 
500
        my $base = 0;
501
        my $num = $#added;
502
        Message ("Update the workspace: Added $num files");
503
 
504
        while ( $base <= $num )
505
        {
506
            my $end = $base + 200;
507
            $end = $num if ( $end > $num );
508
 
509
            $svn->SvnCmd ( 'add'
510
                            , '--depth=empty'
511
                            , '--parents'
512
                            , map ("$opt_workdir/$_", @added[$base .. $end] ),
513
                            { 'error' => 'Adding files to workspace' } );
514
 
515
            $base = $end + 1;
516
        }
517
    }
518
 
519
    #
520
    #   Remove files
521
    #   Don't really need to delete the files as the svn delete
522
    #   comamdn will do this too. Just do it anyway
523
    #
524
    my @rm_files = sort keys %ws;
525
    if ( @rm_files )
526
    {
527
        foreach my $file ( @rm_files  )
528
        {
529
            Verbose ("Removing $file");
530
            unlink "$opt_workdir/$file";
531
        }
532
 
533
        #
534
        #   Inform Subversion about the removed files
535
        #
536
        my $base = 0;
537
        my $num = $#rm_files;
538
        Message ("Update the workspace: Removed $num Files");
539
 
540
        while ( $base <= $num )
541
        {
542
            my $end = $base + 200;
543
            $end = $num if ( $end > $num );
544
 
545
            $svn->SvnCmd ( 'delete', map ("$opt_workdir/$_", @rm_files[$base .. $end] ),
546
                            { 'error' => 'Deleting files from workspace' } );
547
 
548
 
549
            $base = $end + 1;
550
        }
551
    }
552
 
553
    #
554
    #   The common files may have changed
555
    #   Simply copy them all in and let subversion figure it out
556
    #
557
    foreach my $file ( sort keys %common  )
558
    {
559
        my $src = "$opt_dir/$file";
560
        my $target = "$opt_workdir/$file";
561
 
562
        next if ( -d $src );
563
        if ( File::Compare::compare ($src, $target) )
564
        {
565
            Verbose ("Transfer $file");
566
            unlink $target;
567
            unless (File::Copy::copy( $src, $target ))
568
            {
569
                Error("Failed to transfer file [$file]: $!",
570
                      "Src: $src",
571
                      "Tgt: $target");
572
            }
573
        }
574
    }
575
 
576
    #
577
    #   Commit the workspace
578
    #   This will go back onto the trunk
579
    #
580
    $svn = NewSessionByWS( $opt_workdir );
581
    $svn->SvnCi ('comment' => "Checkin by Svn Import" );
582
    Message ("Repository Ref: " . $svn->RmRef);
583
 
584
    #
585
    #   Label the result
586
    #   The workspace will have been updated, so we can use it as the base for
587
    #   the labeling process
588
    #
589
    if ( $opt_label )
590
    {
591
        $svn->SvnCopyWs (
592
                       target => $url_label,
593
                       'noswitch' => 1,
594
                       'replace' => $opt_replace,
595
                       'comment' => 'Created by Jats Svn Import',
596
                       );
597
        Message ("Repository Ref: " . $svn->RmRef);
598
    }
599
 
600
    #
601
    #   Clean up
602
    #
603
    if ( $opt_delete && ! $opt_reuse )
604
    {
605
        Message ("Delete Workspace");
606
        rmtree( $opt_workdir );
607
    }
608
 
609
    $opr_done = 1;
610
}
611
 
612
#-------------------------------------------------------------------------------
613
# Function        : SubCommandHelp
614
#
615
# Description     : Provide help on a subcommand
616
#
617
# Inputs          : $help_level             - Help Level 1,2,3
618
#                   $topic                  - Topic Name
619
#
620
# Returns         : This function does not return
621
#
622
sub SubCommandHelp
623
{
624
    my ($help_level, $topic) = @_;
625
    my @sections;
626
    #
627
    #   Spell out the section we want to display
628
    #
629
    #   Note:
630
    #   Due to bug in pod2usage can't use 'head1' by itself
631
    #   Each one needs a subsection.
632
    #
633
    push @sections, qw( NAME SYNOPSIS ) ;
634
    push @sections, qw( ARGUMENTS OPTIONS ) if ( $help_level > 1 );
635
    push @sections, qw( DESCRIPTION )       if ( $help_level > 2 );
636
 
637
    #
638
    #   Extract section from the POD
639
    #
640
    pod2usage({-verbose => 99,
641
               -noperldoc => 1,
642
               -sections => $topic . '/' . join('|', @sections) } );
643
}
644
 
645
 
646
 
647
#-------------------------------------------------------------------------------
648
#   Documentation
649
#   NOTE
650
#
651
#   Each subcommand MUST have
652
#   head1 section as used by the subcommand
653
#       This should be empty, as the contents will NOT be displayed
654
#   head2 sections called
655
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION
656
#
657
#=head1 xxxxxx
658
#=head2 NAME
659
#=head2 SYNOPSIS
660
#=head2 ARGUMENTS
661
#=head2 OPTIONS
662
#=head2 DESCRIPTION
663
#
664
 
665
=pod
666
 
361 dpurdie 667
=for htmltoc    GENERAL::Subversion::
668
 
311 dpurdie 669
=head1 NAME
670
 
671
jats svn - Miscellaneous SubVersion Operations
672
 
673
=head1 SYNOPSIS
674
 
675
jats svn [options] command [command options]
676
 
677
 Options:
678
    -help[=n]              - Help message, [n=1,2,3]
679
    -man                   - Full documentation [-help=3]
680
    -verbose[=n]           - Verbose command operation
681
 
682
 Common Command Options:
683
    All command support suboptions to provide command specific help
684
 
685
    -help[=n]              - Help message, [n=1,2,3]
686
    -man                   - Full documentation [-help=3]
687
 
688
 Commands are:
363 dpurdie 689
    test                   - Test access to subversion
311 dpurdie 690
    ls URL                 - List Repo contents for URL
691
    delete-package URL     - Delete Package Subtree
692
    create URL             - Create a new package at URL
693
    import URL             - Import files to package at URL
694
 
695
 Use the command
696
    jats svn command -h
697
 for command specific help
698
 
699
 
700
=head1 OPTIONS
701
 
702
=over
703
 
704
=item B<-help[=n]>
705
 
706
Print a help message and exit. The level of help may be either 1, 2 or
707
3 for a full manual.
708
 
709
This option may be specified multiple times to increment the help level, or
710
the help level may be directly specified as a number.
711
 
712
=item B<-man>
713
 
714
This is the same as '-help=3'.
715
The complete help is produced in a man page format.
716
 
717
=item B<--verbose[=n]>
718
 
719
This option will increase the level of verbosity of the commands.
720
 
721
If an argument is provided, then it will be used to set the level, otherwise the
722
existing level will be incremented. This option may be specified multiple times.
723
 
724
=back
725
 
726
=head1 DESCRIPTION
727
 
728
This program provides a number of useful Subversion based operations.
729
 
363 dpurdie 730
=head1 Test Subversion
731
 
732
=head2 NAME
733
 
734
Test Subversion
735
 
736
=head2 SYNOPSIS
737
 
738
    jats svn test
739
 
740
=head2 DESCRIPTION
741
 
742
This command will ensure that the subversion command line utility can be
743
located. The command will report the version of the svn client found.
744
 
311 dpurdie 745
=head1 List Repository
746
 
363 dpurdie 747
=head2 NAME
748
 
749
List Repository
750
 
751
=head2 SYNOPSIS
752
 
753
    jats svn ls <URL>
754
 
755
=head2 DESCRIPTION
756
 
311 dpurdie 757
This command will take a URL and perform a 'svn' list operation. The URL will
758
be expanded to include the site specific repository.
759
 
760
=head1 Delete a Package
761
 
762
=head2 NAME
763
 
764
Delete a Package
765
 
766
=head2 SYNOPSIS
767
 
768
jats svn delete-package URL [options]
769
 
770
 Options:
771
    -help[=n]              - Help message, [n=1,2,3]
772
    -man                   - Full documentation [-help=3]
773
    -verbose[=n]           - Verbose command operation
774
 
775
=head2 ARGUMENTS
776
 
777
The command takes one argument: The URL of the desired package.
778
This may be be:
779
 
780
=over
781
 
782
=item * A full URL
783
 
784
Complete with protocol and path information.
785
 
786
=item * A simple URL
787
 
788
JATS will prepend the site-specific repository location to the user provided URL
789
 
790
=back
791
 
792
=head2 OPTIONS
793
 
794
This command has no significant options, other than the general help options.
795
 
796
=head2 DESCRIPTION
797
 
798
This command will delete a package from the repository. It will ensure
799
that the package is a valid package, before it is deleted.
800
 
801
The command is intended to be used by test scripts, rather than users.
802
 
803
=head1 Create a Package Version
804
 
805
=head2 NAME
806
 
807
Create a Package Version
808
 
809
=head2 SYNOPSIS
810
 
811
jats svn [options] create URL [command options]
812
 
813
 Options:
814
    -help[=n]               - Help message, [n=1,2,3]
815
    -man                    - Full documentation [-help=3]
816
    -verbose[=n]            - Verbose command operation
817
 
818
 Command Options
819
    -help[=n]               - Provide command specific help
820
    -import=nnn             - Import directory tree
821
    -label=nnn              - Label it (trunk import only)
822
    -new                    - Package must not exist
823
    -replace                - Replace any existing versions
824
    -trunk                  - Import to trunk
825
    -tags=nnn               - Import to tags
826
    -branch=nnn             - Import to branches
827
 
828
=head2 ARGUMENTS
829
 
830
The command takes one argument: The URL of the desired package.
831
This may be be:
832
 
833
=over
834
 
835
=item * A full URL
836
 
837
Complete with protocol and path information.
838
 
839
=item * A simple URL
840
 
841
JATS will prepend the site-specific repository location to the user provided URL
842
 
843
=back
844
 
845
=head2 OPTIONS
846
 
847
=over
848
 
849
=item -help[=n]
850
 
851
Print a help message and exit. The level of help may be either 1, 2 or 3.
852
 
853
This option may be specified multiple times to increment the help level, or
854
the help level may be directly specified as a number.
855
 
856
=item -import=nnn
857
 
858
This option specifies the path of a subdirectory tree to import into the newly
859
created package. In not provided, then only a package skeleton will be created.
860
 
861
=item -label=nnn
862
 
863
This option specifies a label to place the imported source, if the source is
864
being imported to the 'trunk' of the package.
865
 
866
=item -new
867
 
868
This option specifies that the named package MUST not exist at all.
869
 
870
=item -replace
871
 
872
This option allows the program to replace any existing versions of the
873
imported source. It will allow the deletion of any existing trunk, tags or
874
branches.
875
 
876
=item -trunk
877
 
878
This option specifies that imported source will be placed on the trunk of the
879
package. This is the default mode of import.
880
 
881
The options -trunk, -tags and -branch are mutually exclusive.
882
 
883
=item -tags=nnn
884
 
885
This option specifies that imported source will be placed directly on the
886
named tag of the package.
887
 
888
The options -trunk, -tags and -branch are mutually exclusive.
889
 
890
=item -branch=nnn
891
 
892
This option specifies that imported source will be placed directly on the
893
named branch of the package.
894
 
895
The options -trunk, -tags and -branch are mutually exclusive.
896
 
897
=back
898
 
899
=head2 DESCRIPTION
900
 
901
This command will create a new package within a repository. It will ensure
902
that the package contains the three required subdirectories: trunk, tags and
903
branches.
904
 
905
The command will also ensure that packages are not placed at inappropriate
906
locations within the repository. It is not correct to place a package within
907
another package.
908
 
909
The command will, optionally, import a directory tree into the repository and,
910
optionally, label the package.
911
 
912
The package body may be imported to the 'trunk' or to a branch or a tag.
913
By default the data will be imported to the trunk and may be labeled (tagged).
914
 
915
Options allow the targets to be deleted if they exist or to ensure that they
916
are not present.
917
 
918
The command does not attempt to merge file versions within the repository. It
919
may result in multiple instances of a file within the repository. Use only for
341 dpurdie 920
simple imports. Use the 'import' command for more sophisticated import requirements.
311 dpurdie 921
 
922
=head1 Import directory to a Package
923
 
924
=head2 NAME
925
 
926
Import directory to a Package
927
 
928
=head2 SYNOPSIS
929
 
930
jats svn [options] import URL [command options]
931
 
932
 Options:
933
    -help[=n]               - Help message, [n=1,2,3]
934
    -man                    - Full documentation [-help=3]
935
    -verbose[=n]            - Verbose command operation
936
 
937
 Command Options
938
    -help[=n]               - Command specific help, [n=1,2,3]
939
    -verbose[=n]            - Verbose operation
940
    -package=name           - Name of source package
941
    -dir=path               - Path to new version
942
    -label                  - Label the result
943
    -replace                - Allow the label to be replaced
944
    -reuse                  - Reuse the import directory
945
    -workspace=path         - Path and name of alternate workspace
946
    -[no]delete             - Deletes workspace after use. Default:yes
947
 
948
=head2 ARGUMENTS
949
 
950
The command takes one argument: The URL of the desired package.
951
This may be be:
952
 
953
=over
954
 
955
=item * A full URL
956
 
957
Complete with protocol and path information.
958
 
959
=item * A simple URL
960
 
961
JATS will prepend the site-specific repository location to the user provided URL
962
 
963
=back
964
 
965
=head2 OPTIONS
966
 
967
=over
968
 
969
=item -help[=n]
970
 
971
Print a help message and exit. The level of help may be either 1, 2 or 3.
972
 
973
This option may be specified multiple times to increment the help level, or
974
the help level may be directly specified as a number.
975
 
976
=item -verbose[=n]
977
 
978
This option will increase the level of verbosity of the utility.
979
 
980
If an argument is provided, then it will be used to set the level, otherwise the
981
existing level will be incremented. This option may be specified multiple times.
982
 
983
 
984
=item -package=name
985
 
986
Either this option or a bare URL on the command line must be provided. It
987
specifies the repository and package to be used as a basis for the work.
988
 
989
=item -dir=path
990
 
991
This option is mandatory. It specifies the path to a local directory that
992
contains a version of the software to be checked in.
993
 
994
=item -label=name
995
 
996
The resulting software version will be labeled with this tag, if it is provided.
997
 
998
=item -replace
999
 
1000
This option, if provided, allows the label to be replaced.
1001
 
1002
=item -reuse
1003
 
1004
This option can be used to speed the creation of multiple versions in a scripted
1005
environment. The option allows the utility to reuse the workspace if it exists.
1006
 
1007
=item -workspace=path
1008
 
1009
This option specifies an alternate workspace directory to create and use. The
1010
default directory is "SvnImportDir" within the users current directory.
1011
 
1012
=item [no]delete
1013
 
341 dpurdie 1014
This option control the deletion of the workspace directory. By default the
311 dpurdie 1015
directory will be deleted, unless re-use is also used.
1016
 
1017
=back
1018
 
1019
=head2 DESCRIPTION
1020
 
1021
Import a new version of a package to the trunk of the package. The utility
1022
will only import changed files so that file history is preserved within the
1023
repository.
1024
 
1025
This utility is used import software from another version control system
1026
The utility will:
1027
 
1028
=over
1029
 
361 dpurdie 1030
=item *
311 dpurdie 1031
 
361 dpurdie 1032
Create a Work Space based on the current package version
1033
 
311 dpurdie 1034
The 'trunk' of the named package will be used as the base for the workspace.
1035
 
361 dpurdie 1036
=item *
311 dpurdie 1037
 
361 dpurdie 1038
Update files and directories
1039
 
311 dpurdie 1040
Determines the files and directories that have been added and deleted and
1041
update the Workspace to reflect the new structure.
1042
 
361 dpurdie 1043
=item *
311 dpurdie 1044
 
361 dpurdie 1045
Check in the new version
311 dpurdie 1046
 
361 dpurdie 1047
=item *
1048
 
1049
Label the new version
1050
 
311 dpurdie 1051
=back
1052
 
1053
The utility can optionally perform other operations including:
1054
 
1055
=over
1056
 
361 dpurdie 1057
=item *
311 dpurdie 1058
 
361 dpurdie 1059
Import directly to a branch. This does not affect the 'trunk'.
311 dpurdie 1060
 
361 dpurdie 1061
=item *
1062
 
1063
Import directly to a tag. This does not affect the 'trunk'
1064
 
311 dpurdie 1065
=back
1066
 
1067
=cut
1068