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