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
 
361 dpurdie 637
=for htmltoc    GENERAL::Subversion::
638
 
311 dpurdie 639
=head1 NAME
640
 
641
jats svn - Miscellaneous SubVersion Operations
642
 
643
=head1 SYNOPSIS
644
 
645
jats svn [options] command [command options]
646
 
647
 Options:
648
    -help[=n]              - Help message, [n=1,2,3]
649
    -man                   - Full documentation [-help=3]
650
    -verbose[=n]           - Verbose command operation
651
 
652
 Common Command Options:
653
    All command support suboptions to provide command specific help
654
 
655
    -help[=n]              - Help message, [n=1,2,3]
656
    -man                   - Full documentation [-help=3]
657
 
658
 Commands are:
659
    ls URL                 - List Repo contents for URL
660
    delete-package URL     - Delete Package Subtree
661
    create URL             - Create a new package at URL
662
    import URL             - Import files to package at URL
663
 
664
 Use the command
665
    jats svn command -h
666
 for command specific help
667
 
668
 
669
=head1 OPTIONS
670
 
671
=over
672
 
673
=item B<-help[=n]>
674
 
675
Print a help message and exit. The level of help may be either 1, 2 or
676
3 for a full manual.
677
 
678
This option may be specified multiple times to increment the help level, or
679
the help level may be directly specified as a number.
680
 
681
=item B<-man>
682
 
683
This is the same as '-help=3'.
684
The complete help is produced in a man page format.
685
 
686
=item B<--verbose[=n]>
687
 
688
This option will increase the level of verbosity of the commands.
689
 
690
If an argument is provided, then it will be used to set the level, otherwise the
691
existing level will be incremented. This option may be specified multiple times.
692
 
693
=back
694
 
695
=head1 DESCRIPTION
696
 
697
This program provides a number of useful Subversion based operations.
698
 
699
=head1 List Repository
700
 
701
This command will take a URL and perform a 'svn' list operation. The URL will
702
be expanded to include the site specific repository.
703
 
704
=head1 Delete a Package
705
 
706
=head2 NAME
707
 
708
Delete a Package
709
 
710
=head2 SYNOPSIS
711
 
712
jats svn delete-package URL [options]
713
 
714
 Options:
715
    -help[=n]              - Help message, [n=1,2,3]
716
    -man                   - Full documentation [-help=3]
717
    -verbose[=n]           - Verbose command operation
718
 
719
=head2 ARGUMENTS
720
 
721
The command takes one argument: The URL of the desired package.
722
This may be be:
723
 
724
=over
725
 
726
=item * A full URL
727
 
728
Complete with protocol and path information.
729
 
730
=item * A simple URL
731
 
732
JATS will prepend the site-specific repository location to the user provided URL
733
 
734
=back
735
 
736
=head2 OPTIONS
737
 
738
This command has no significant options, other than the general help options.
739
 
740
=head2 DESCRIPTION
741
 
742
This command will delete a package from the repository. It will ensure
743
that the package is a valid package, before it is deleted.
744
 
745
The command is intended to be used by test scripts, rather than users.
746
 
747
=head1 Create a Package Version
748
 
749
=head2 NAME
750
 
751
Create a Package Version
752
 
753
=head2 SYNOPSIS
754
 
755
jats svn [options] create URL [command options]
756
 
757
 Options:
758
    -help[=n]               - Help message, [n=1,2,3]
759
    -man                    - Full documentation [-help=3]
760
    -verbose[=n]            - Verbose command operation
761
 
762
 Command Options
763
    -help[=n]               - Provide command specific help
764
    -import=nnn             - Import directory tree
765
    -label=nnn              - Label it (trunk import only)
766
    -new                    - Package must not exist
767
    -replace                - Replace any existing versions
768
    -trunk                  - Import to trunk
769
    -tags=nnn               - Import to tags
770
    -branch=nnn             - Import to branches
771
 
772
=head2 ARGUMENTS
773
 
774
The command takes one argument: The URL of the desired package.
775
This may be be:
776
 
777
=over
778
 
779
=item * A full URL
780
 
781
Complete with protocol and path information.
782
 
783
=item * A simple URL
784
 
785
JATS will prepend the site-specific repository location to the user provided URL
786
 
787
=back
788
 
789
=head2 OPTIONS
790
 
791
=over
792
 
793
=item -help[=n]
794
 
795
Print a help message and exit. The level of help may be either 1, 2 or 3.
796
 
797
This option may be specified multiple times to increment the help level, or
798
the help level may be directly specified as a number.
799
 
800
=item -import=nnn
801
 
802
This option specifies the path of a subdirectory tree to import into the newly
803
created package. In not provided, then only a package skeleton will be created.
804
 
805
=item -label=nnn
806
 
807
This option specifies a label to place the imported source, if the source is
808
being imported to the 'trunk' of the package.
809
 
810
=item -new
811
 
812
This option specifies that the named package MUST not exist at all.
813
 
814
=item -replace
815
 
816
This option allows the program to replace any existing versions of the
817
imported source. It will allow the deletion of any existing trunk, tags or
818
branches.
819
 
820
=item -trunk
821
 
822
This option specifies that imported source will be placed on the trunk of the
823
package. This is the default mode of import.
824
 
825
The options -trunk, -tags and -branch are mutually exclusive.
826
 
827
=item -tags=nnn
828
 
829
This option specifies that imported source will be placed directly on the
830
named tag of the package.
831
 
832
The options -trunk, -tags and -branch are mutually exclusive.
833
 
834
=item -branch=nnn
835
 
836
This option specifies that imported source will be placed directly on the
837
named branch of the package.
838
 
839
The options -trunk, -tags and -branch are mutually exclusive.
840
 
841
=back
842
 
843
=head2 DESCRIPTION
844
 
845
This command will create a new package within a repository. It will ensure
846
that the package contains the three required subdirectories: trunk, tags and
847
branches.
848
 
849
The command will also ensure that packages are not placed at inappropriate
850
locations within the repository. It is not correct to place a package within
851
another package.
852
 
853
The command will, optionally, import a directory tree into the repository and,
854
optionally, label the package.
855
 
856
The package body may be imported to the 'trunk' or to a branch or a tag.
857
By default the data will be imported to the trunk and may be labeled (tagged).
858
 
859
Options allow the targets to be deleted if they exist or to ensure that they
860
are not present.
861
 
862
The command does not attempt to merge file versions within the repository. It
863
may result in multiple instances of a file within the repository. Use only for
341 dpurdie 864
simple imports. Use the 'import' command for more sophisticated import requirements.
311 dpurdie 865
 
866
=head1 Import directory to a Package
867
 
868
=head2 NAME
869
 
870
Import directory to a Package
871
 
872
=head2 SYNOPSIS
873
 
874
jats svn [options] import URL [command options]
875
 
876
 Options:
877
    -help[=n]               - Help message, [n=1,2,3]
878
    -man                    - Full documentation [-help=3]
879
    -verbose[=n]            - Verbose command operation
880
 
881
 Command Options
882
    -help[=n]               - Command specific help, [n=1,2,3]
883
    -verbose[=n]            - Verbose operation
884
    -package=name           - Name of source package
885
    -dir=path               - Path to new version
886
    -label                  - Label the result
887
    -replace                - Allow the label to be replaced
888
    -reuse                  - Reuse the import directory
889
    -workspace=path         - Path and name of alternate workspace
890
    -[no]delete             - Deletes workspace after use. Default:yes
891
 
892
=head2 ARGUMENTS
893
 
894
The command takes one argument: The URL of the desired package.
895
This may be be:
896
 
897
=over
898
 
899
=item * A full URL
900
 
901
Complete with protocol and path information.
902
 
903
=item * A simple URL
904
 
905
JATS will prepend the site-specific repository location to the user provided URL
906
 
907
=back
908
 
909
=head2 OPTIONS
910
 
911
=over
912
 
913
=item -help[=n]
914
 
915
Print a help message and exit. The level of help may be either 1, 2 or 3.
916
 
917
This option may be specified multiple times to increment the help level, or
918
the help level may be directly specified as a number.
919
 
920
=item -verbose[=n]
921
 
922
This option will increase the level of verbosity of the utility.
923
 
924
If an argument is provided, then it will be used to set the level, otherwise the
925
existing level will be incremented. This option may be specified multiple times.
926
 
927
 
928
=item -package=name
929
 
930
Either this option or a bare URL on the command line must be provided. It
931
specifies the repository and package to be used as a basis for the work.
932
 
933
=item -dir=path
934
 
935
This option is mandatory. It specifies the path to a local directory that
936
contains a version of the software to be checked in.
937
 
938
=item -label=name
939
 
940
The resulting software version will be labeled with this tag, if it is provided.
941
 
942
=item -replace
943
 
944
This option, if provided, allows the label to be replaced.
945
 
946
=item -reuse
947
 
948
This option can be used to speed the creation of multiple versions in a scripted
949
environment. The option allows the utility to reuse the workspace if it exists.
950
 
951
=item -workspace=path
952
 
953
This option specifies an alternate workspace directory to create and use. The
954
default directory is "SvnImportDir" within the users current directory.
955
 
956
=item [no]delete
957
 
341 dpurdie 958
This option control the deletion of the workspace directory. By default the
311 dpurdie 959
directory will be deleted, unless re-use is also used.
960
 
961
=back
962
 
963
=head2 DESCRIPTION
964
 
965
Import a new version of a package to the trunk of the package. The utility
966
will only import changed files so that file history is preserved within the
967
repository.
968
 
969
This utility is used import software from another version control system
970
The utility will:
971
 
972
=over
973
 
361 dpurdie 974
=item *
311 dpurdie 975
 
361 dpurdie 976
Create a Work Space based on the current package version
977
 
311 dpurdie 978
The 'trunk' of the named package will be used as the base for the workspace.
979
 
361 dpurdie 980
=item *
311 dpurdie 981
 
361 dpurdie 982
Update files and directories
983
 
311 dpurdie 984
Determines the files and directories that have been added and deleted and
985
update the Workspace to reflect the new structure.
986
 
361 dpurdie 987
=item *
311 dpurdie 988
 
361 dpurdie 989
Check in the new version
311 dpurdie 990
 
361 dpurdie 991
=item *
992
 
993
Label the new version
994
 
311 dpurdie 995
=back
996
 
997
The utility can optionally perform other operations including:
998
 
999
=over
1000
 
361 dpurdie 1001
=item *
311 dpurdie 1002
 
361 dpurdie 1003
Import directly to a branch. This does not affect the 'trunk'.
311 dpurdie 1004
 
361 dpurdie 1005
=item *
1006
 
1007
Import directly to a tag. This does not affect the 'trunk'
1008
 
311 dpurdie 1009
=back
1010
 
1011
=cut
1012