Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
267 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
297 dpurdie 175
#                   Optionally Tag the import on a branch
267 dpurdie 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
297 dpurdie 181
#                       -tag=name       - Import to Tag Only
182
#                       -branch=name    - Import to Branch only
267 dpurdie 183
#                       -new            - Must be new package
297 dpurdie 184
#                       -replace        - Replace existing
267 dpurdie 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;
297 dpurdie 290
    my $opt_workdir = "SvnImportDir";
267 dpurdie 291
 
292
    #
293
    #   Other globals
294
    #
295
    my $url_label;
296
 
297
    #
298
    #   Configuration options
299
    #
300
    my $result = GetOptions (
301
                    "help:+"        => \$opt_help,
302
                    "manual:3"      => \$opt_help,
303
                    "verbose:+"     => \$opt_verbose,
304
                    "package=s"     => \$opt_package,
305
                    "dir=s"         => \$opt_dir,
306
                    "label=s"       => \$opt_label,
307
                    "replace"       => \$opt_replace,
308
                    "reuse"         => \$opt_reuse,
309
                    "workspace"     => \$opt_workdir,
310
 
311
                    #
312
                    #   Update documentation at the end of the file
313
                    #
314
                    ) || Error ("Invalid command line" );
315
 
316
    #
317
    #   Insert defaults
318
    #   User can specify base package via -package or unoptions arguments
319
    #
320
    $opt_package = $ARGV[0] unless ( $opt_package );
321
 
322
    #
323
    #   Subcommand specific help
324
    #
325
    SubCommandHelp( $opt_help, "Import directory to a Package")
326
        if ($opt_help || ! $opt_package );
327
 
328
    #
329
    #   Alter the error reporting paramters
330
    #
331
    ErrorConfig( 'verbose' => $opt_verbose );
332
 
333
    #
334
    #   Configure the error reporting process now that we have the user options
335
    #
336
    Error ("No package URL specified") unless ( $opt_package );
337
    Error ("No base directory specified") unless ( $opt_dir );
338
    Error ("Invalid base directory: $opt_dir") unless ( -d $opt_dir );
339
 
340
    #
341
    #   Create an SVN session
342
    #
343
    my $svn = NewSessionByUrl ( $opt_package );
344
 
345
    #
346
    #   Ensure that the required label is available
347
    #
348
    if ( $opt_label )
349
    {
350
        $opt_label = SvnIsaSimpleLabel ($opt_label);
351
        $url_label = $svn->BranchName( $opt_label, 'tags' );
352
        $svn->SvnValidateTarget (
353
                        'target' => $url_label,
354
                        'available' => 1,
355
                        ) unless ( $opt_replace );
356
    }
357
 
358
    #
359
    #   Create a workspace based on the users package
360
    #   Allow the workspace to be reused to speed up multiple
361
    #   operations
362
    #
363
    unless ( $opt_reuse && -d $opt_workdir )
364
    {
365
        Message ("Creating Workspace");
366
        rmtree( $opt_workdir );
367
 
368
        $svn->SvnValidatePackageRoot ();
369
        #DebugDumpData( 'Svn', $svn );
370
        $svn->SvnValidateTarget (
371
                            'cmd'    => 'SvnImporter',
372
                            'target' => $svn->Full,
373
                            'require' => 1,
374
                            );
375
 
376
        $svn->SvnCo ( $svn->Full . '/trunk', $opt_workdir );
377
        Error ("Cannot locate the created Workspace")
378
            unless ( -d $opt_workdir );
379
    }
380
 
381
    #
382
    #   Determine differences between the two folders
383
    #       Create structures for each directory
384
    #
385
    Message ("Determine Files in packages");
386
 
387
    my $search = JatsLocateFiles->new("--Recurse=1",
388
                                       "--DirsToo",
389
                                       "--FilterOutRe=/\.svn/",
390
                                       "--FilterOutRe=/\.svn\$",
391
                                       );
392
    my @ws = $search->search($opt_workdir);
393
    my @dir = $search->search($opt_dir);
394
 
395
    #Information ("WS Results", @ws);
396
    #Information ("DIR Results", @dir);
397
 
398
    #
399
    #   Create a hash the Workspace and the User dir
400
    #   The key will be file names
401
    #
402
    my %ws;  map ( $ws{$_} = 1 , @ws );
403
    my %dir; map ( $dir{$_} = 1 , @dir );
404
 
405
    #
406
    #   Create a hash of common elements
407
    #   Removing then from the other two
408
    #
409
    my %common;
410
    foreach ( keys %ws )
411
    {
412
        next unless ( exists $dir{$_} );
413
        $common{$_} = 1;
414
        delete $ws{$_};
415
        delete $dir{$_};
416
    }
417
 
418
    #DebugDumpData( 'WS', \%ws );
419
    #DebugDumpData( 'DIR', \%dir );
420
    #DebugDumpData( 'COMMON', \%common );
421
 
422
    #
423
    #   Add New Files
424
    #   Won't add empty directories at this point
425
    #
426
    #   Process by sorted list
427
    #   This will ensure we process parent directories first
428
    #
429
    my @added = sort keys %dir;
430
 
431
    if ( @added )
432
    {
433
        foreach my $file ( @added  )
434
        {
435
            my $src = "$opt_dir/$file";
436
            my $target = "$opt_workdir/$file";
437
 
438
            if ( -d $src )
439
            {
440
                mkdir ( $target ) unless (-d $target);
441
            }
442
            else
443
            {
444
 
445
                my $path = dirname ( $target);
446
                mkdir ( $path ) unless (-d $path);
447
 
448
                Verbose ("Adding $file");
449
                unless (File::Copy::copy( $src, $target ))
450
                {
451
                    Error("Failed to transfer file [$file]: $!");
452
                }
453
            }
454
        }
455
 
456
        #
457
        #   Inform Subversion about the added files
297 dpurdie 458
        #   The command line does have a finite length, so add them 200 at a
459
        #   time.
267 dpurdie 460
        #
297 dpurdie 461
 
462
        my $base = 0;
463
        my $num = $#added;
464
        Message ("Update the workspace: Added $num files");
465
 
466
        while ( $base <= $num )
467
        {
468
            my $end = $base + 200;
469
            $end = $num if ( $end > $num );
470
 
471
            $svn->SvnCmd ( 'add'
472
                            , '--depth=empty'
473
                            , '--parents'
474
                            , map ("$opt_workdir/$_", @added[$base .. $end] ),
475
                            { 'error' => 'Adding files to workspace' } );
476
 
477
            $base = $end + 1;
478
        }
267 dpurdie 479
    }
480
 
481
    #
482
    #   Remove files
483
    #   Don't really need to delete the files as the svn delete
484
    #   comamdn will do this too. Just do it anyway
485
    #
486
    my @rm_files = sort keys %ws;
487
    if ( @rm_files )
488
    {
489
        foreach my $file ( @rm_files  )
490
        {
491
            Verbose ("Removing $file");
492
            unlink "$opt_workdir/$file";
493
        }
494
 
495
        #
496
        #   Inform Subversion about the removed files
497
        #
297 dpurdie 498
        my $base = 0;
499
        my $num = $#rm_files;
500
        Message ("Update the workspace: Removed $num Files");
501
 
502
        while ( $base <= $num )
503
        {
504
            my $end = $base + 200;
505
            $end = $num if ( $end > $num );
506
 
507
            $svn->SvnCmd ( 'delete', map ("$opt_workdir/$_", @rm_files[$base .. $end] ),
508
                            { 'error' => 'Deleting files from workspace' } );
509
 
510
 
511
            $base = $end + 1;
512
        }
267 dpurdie 513
    }
514
 
515
    #
516
    #   The common files may have changed
517
    #   Simply copy them all in and let subversion figure it out
518
    #
519
    foreach my $file ( sort keys %common  )
520
    {
521
        my $src = "$opt_dir/$file";
522
        my $target = "$opt_workdir/$file";
523
 
524
        next if ( -d $src );
525
        if ( File::Compare::compare ($src, $target) )
526
        {
527
            Verbose ("Transfer $file");
528
            unlink $target;
529
            unless (File::Copy::copy( $src, $target ))
530
            {
531
                Error("Failed to transfer file [$file]: $!",
532
                      "Src: $src",
533
                      "Tgt: $target");
534
            }
535
        }
536
    }
537
 
538
    #
539
    #   Commit the workspace
540
    #   This will go back onto the trunk
541
    #
542
    $svn = NewSessionByWS( $opt_workdir );
543
    $svn->SvnCi ('comment' => "Checkin by Svn Import" );
544
    Message ("Repository Ref: " . $svn->RmRef);
545
 
546
    #
547
    #   Label the result
548
    #   The workspace will have been updated, so we can use it as the base for
549
    #   the labeling process
550
    #
551
    if ( $opt_label )
552
    {
553
        $svn->SvnCopyWs (
554
                       target => $url_label,
555
                       'noswitch' => 1,
556
                       'replace' => $opt_replace,
557
                       'comment' => 'Created by Jats Svn Import',
558
                       );
559
        Message ("Repository Ref: " . $svn->RmRef);
560
    }
561
    $opr_done = 1;
562
}
563
 
564
#-------------------------------------------------------------------------------
565
# Function        : SubCommandHelp
566
#
567
# Description     : Provide help on a subcommand
568
#
569
# Inputs          : $help_level             - Help Level 1,2,3
570
#                   $topic                  - Topic Name
571
#
572
# Returns         : This function does not return
573
#
574
sub SubCommandHelp
575
{
576
    my ($help_level, $topic) = @_;
577
 
578
    #
579
    #   Spell out the section we want to display
580
    #
581
    #   Note:
582
    #   Due to bug in pod2usage cant use 'head1' by itself
583
    #   Each one needs a subsection.
584
    #
585
    my $help_re;
586
    my @sections;
587
    if ( $help_level <= 1 ) {
588
        @sections = qw( NAME SYNOPSIS );
589
    } elsif ( $help_level <= 2 ) {
590
        @sections = qw( NAME SYNOPSIS ARGUMENTS OPTIONS );
591
    } else {
592
        @sections = qw( NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION );
593
    };
594
 
595
    #
596
    #   Build up a topic list
597
    #
598
    $help_re .= $topic . '\/' . $_ . '|' foreach ( @sections );
599
 
600
    #
601
    #   Extract section from the POD
602
    #   Need trailling DUMMY to overcome BUG in pod2usage
603
    #
604
    pod2usage({-verbose => 99,
605
               -sections => $help_re . 'DUMMY'} );
606
}
607
 
608
 
609
 
610
#-------------------------------------------------------------------------------
611
#   Documentation
612
#   NOTE
613
#
614
#   Each subcommand MUST have
615
#   head1 section as used by the subcommand
616
#       This should be empty
617
#   head2 sections called
618
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION
619
#
620
#=head1 xxxxxx
621
#=head2 NAME
622
#=head2 SYNOPSIS
623
#=head2 ARGUMENTS
624
#=head2 OPTIONS
625
#=head2 DESCRIPTION
626
#
627
 
628
=pod
629
 
630
=head1 NAME
631
 
632
jats svn - Miscellaneous SubVersion Operations
633
 
634
=head1 SYNOPSIS
635
 
636
jats svn [options] command [command options]
637
 
638
 Options:
639
    -help[=n]              - Help message, [n=1,2,3]
640
    -man                   - Full documentation [-help=3]
641
    -verbose[=n]           - Verbose command operation
642
 
643
 Common Command Options:
644
    All command support suboptions to provide command specific help
645
 
646
    -help[=n]              - Help message, [n=1,2,3]
647
    -man                   - Full documentation [-help=3]
648
 
649
 Commands are:
650
    ls URL                 - List Repo contents for URL
651
    delete-package URL     - Delete Package Subtree
652
    create URL             - Create a new package at URL
653
    import URL             - Import files to package at URL
654
 
655
 Use the command
656
    jats svn command -h
657
 for command specific help
658
 
659
 
660
=head1 OPTIONS
661
 
662
=over
663
 
664
=item B<-help[=n]>
665
 
666
Print a help message and exit. The level of help may be either 1, 2 or
667
3 for a full manual.
668
 
669
This option may be specified multiple times to increment the help level, or
670
the help level may be directly specified as a number.
671
 
672
=item B<-man>
673
 
674
This is the same as '-help=3'.
675
The complete help is produced in a man page format.
676
 
677
=item B<--verbose[=n]>
678
 
679
This option will increase the level of verbosity of the commands.
680
 
681
If an argument is provided, then it will be used to set the level, otherwise the
682
existing level will be incremented. This option may be specified multiple times.
683
 
684
=back
685
 
686
=head1 DESCRIPTION
687
 
688
This program provides a number of useful Subversion based operations.
689
 
690
=head1 List Repository
691
 
692
This command will take a URL and perform a 'svn' list operation. The URL will
693
be expanded to include the site specific repository.
694
 
695
=head1 Delete a Package
696
 
697
=head2 NAME
698
 
699
Delete a Package
700
 
701
=head2 SYNOPSIS
702
 
703
jats svn delete-package URL [options]
704
 
705
 Options:
706
    -help[=n]              - Help message, [n=1,2,3]
707
    -man                   - Full documentation [-help=3]
708
    -verbose[=n]           - Verbose command operation
709
 
710
=head2 ARGUMENTS
711
 
712
The command takes one argument: The URL of the desirecd package.
713
This may be be:
714
 
715
=over
716
 
717
=item * A full URL
718
 
719
Complete with protocol and path information.
720
 
721
=item * A simple URL
722
 
723
JATS will prepend the site-specific repository location to the user provided URL
724
 
725
=back
726
 
727
=head2 OPTIONS
728
 
729
This command has no significant options, other than the general help options.
730
 
731
=head2 DESCRIPTION
732
 
733
This command will delete a package from the repository. It will ensure
734
that the package is a valid package, before it is deleted.
735
 
736
The command is intended to be used by test scripts, rather than users.
737
 
738
=head1 Create a Package Version
739
 
740
=head2 NAME
741
 
742
Create a Package Version
743
 
744
=head2 SYNOPSIS
745
 
746
jats svn [options] create URL [command options]
747
 
748
 Options:
749
    -help[=n]               - Help message, [n=1,2,3]
750
    -man                    - Full documentation [-help=3]
751
    -verbose[=n]            - Verbose command operation
752
 
753
 Command Options
754
    -help[=n]               - Provide comand specific help
755
    -import=nnn             - Import directory tree
756
    -label=nnn              - Label it (trunk import only)
757
    -new                    - Package must not exist
758
    -replace                - Replace any existing versions
759
    -trunk                  - Import to trunk
760
    -tags=nnn               - Import to tags
761
    -branch=nnn             - Import to branches
762
 
763
=head2 ARGUMENTS
764
 
765
The command takes one argument: The URL of the desirecd package.
766
This may be be:
767
 
768
=over
769
 
770
=item * A full URL
771
 
772
Complete with protocol and path information.
773
 
774
=item * A simple URL
775
 
776
JATS will prepend the site-specific repository location to the user provided URL
777
 
778
=back
779
 
780
=head2 OPTIONS
781
 
782
=over
783
 
784
=item -help[=n]
785
 
786
Print a help message and exit. The level of help may be either 1, 2 or 3.
787
 
788
This option may be specified multiple times to increment the help level, or
789
the help level may be directly specified as a number.
790
 
791
=item -import=nnn
792
 
793
This option specifies the path of a subdirectory tree to import into the newly
794
created package. In not provided, then only a package skeleton will be created.
795
 
796
=item -label=nnn
797
 
798
This option specifes a label to place the imported source, if the source is
799
being imported to the 'trunk' of the package.
800
 
801
=item -new
802
 
803
This option specifies that the named package MUST not exist at all.
804
 
805
=item -replace
806
 
807
This option allows the program to replace any existing versions of the
808
imported source. It will allow the deletion of any existing trunk, trags or
809
branches.
810
 
811
=item -trunk
812
 
813
This option specifies that imported source will be placed on the trunk of the
814
package. This is the default mode of import.
815
 
816
The options -trunk, -tags and -branch are mutally exclusive.
817
 
818
=item -tags=nnn
819
 
820
This option specifies that imported source will be placed directly on the
821
named tag of ther package.
822
 
823
The options -trunk, -tags and -branch are mutally exclusive.
824
 
825
=item -branch=nnn
826
 
827
This option specifies that imported source will be placed directly on the
828
named branch of ther package.
829
 
830
The options -trunk, -tags and -branch are mutally exclusive.
831
 
832
=back
833
 
834
=head2 DESCRIPTION
835
 
836
This command will create a new package within a repository. It will ensure
837
that the package contains the three required subdirectories: trunk, tags and
838
branches.
839
 
840
The command will also ensure that packages are not placed at inappropriate
841
locations within the repository. It is not correct to place a package within
842
another package.
843
 
844
The command will, optionally, import a directory tree into the repository and,
845
optionally, label the package.
846
 
847
The package body may be imported to the 'trunk' or to a branch or a tag.
848
By default the data will be imported to the trunk and may be labled (tagged).
849
 
850
Options allow the targets to be deleletd if they exist or to ensure that they
851
are not present.
852
 
853
The command does not attempt to merge file versions within the repository. It
854
may result in multiple instances of a file within the repository. Use only for
855
simple imports.
856
 
857
=head1 Import directory to a Package
858
 
859
=head2 NAME
860
 
861
Import directory to a Package
862
 
863
=head2 SYNOPSIS
864
 
865
jats svn [options] import URL [command options]
866
 
867
 Options:
868
    -help[=n]               - Help message, [n=1,2,3]
869
    -man                    - Full documentation [-help=3]
870
    -verbose[=n]            - Verbose command operation
871
 
872
 Command Options
873
    -help[=n]               - Command specific help, [n=1,2,3]
874
    -verbose[=n]            - Verbose operation
875
    -package=name           - Name of source package
876
    -dir=path               - Path to new version
877
    -label                  - Label the result
878
    -replace                - Allow the label to be replaced
879
    -reuse                  - Reuse the import directory
880
    -workspace=path         - Path and name of alternate workspace
881
 
882
=head2 ARGUMENTS
883
 
884
The command takes one argument: The URL of the desirecd package.
885
This may be be:
886
 
887
=over
888
 
889
=item * A full URL
890
 
891
Complete with protocol and path information.
892
 
893
=item * A simple URL
894
 
895
JATS will prepend the site-specific repository location to the user provided URL
896
 
897
=back
898
 
899
=head2 OPTIONS
900
 
901
=over
902
 
903
=item -help[=n]
904
 
905
Print a help message and exit. The level of help may be either 1, 2 or 3.
906
 
907
This option may be specified multiple times to increment the help level, or
908
the help level may be directly specified as a number.
909
 
910
=item -verbose[=n]
911
 
912
This option will increase the level of verbosity of the utility.
913
 
914
If an argument is provided, then it will be used to set the level, otherwise the
915
existing level will be incremented. This option may be specified multiple times.
916
 
917
 
918
=item -package=name
919
 
920
This option is mandatory. It specifies the repository and package to be used as a
921
basis for the work.
922
 
923
=item -dir=path
924
 
925
This option is mandatory. It specifies the path to a local directory that
926
contains a version of the software to be checked in.
927
 
928
=item -label=name
929
 
930
The resulting software version will be labled with this tag, if it is provided.
931
 
932
=item -replace
933
 
934
This option, if provided, allows the label to be replaced.
935
 
936
=item -reuse
937
 
938
This option can be used to speed the creation of multiple versions in a scripted
939
environment. The option allows the utility to reuse the workspace if it exists
940
 
941
=item -workpspace=path
942
 
943
This option specifies an alternate workspace directory to create and use. The
297 dpurdie 944
default directory is "SvnImportDir" within the users current directory.
267 dpurdie 945
 
946
=back
947
 
948
=head2 DESCRIPTION
949
 
950
Import a new version of a package to the trunk of the package. The utility
951
will only import changed files so that file history is preserved within the
952
repository.
953
 
954
This utility is used import software from another version control system
955
The utility will:
956
 
957
=over
958
 
959
=item * Create a Work Space based on the current pakage version
960
 
961
The 'trunk' of the named package will be used as the baes for the workspace.
962
 
963
=item * Update files and directories
964
 
965
Determines the files and directories that have been added and deleted and
966
update the Workspace to reflect the new structure.
967
 
968
=item * Check in the new version
969
 
970
=item * Label the new version
971
 
972
=back
973
 
974
=cut
975