Subversion Repositories DevTools

Rev

Rev 1270 | Rev 1348 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
311 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2008 ERG Limited, All rights reserved
3
#
4
# Module name   : jats_svn.pl
5
# Module type   : Jats Utility
6
# Compiler(s)   : Perl
7
# Environment(s): Jats
8
#
9
# Description   : A script to perform a number of SVN utility functions
10
#                 The script will:
11
#                   Delete a package
12
#                   Create a package
13
#                   Import source to a package
14
#
15
#
16
#......................................................................#
17
 
18
require 5.006_001;
19
use strict;
20
use warnings;
21
use JatsError;
22
use JatsSvn qw(:All);
23
use JatsLocateFiles;
379 dpurdie 24
use JatsProperties;
311 dpurdie 25
 
379 dpurdie 26
 
311 dpurdie 27
use Pod::Usage;                                 # required for help support
28
use Getopt::Long qw(:config require_order);     # Stop on non-option
29
use Cwd;
30
use File::Path;
31
use File::Copy;
32
use File::Basename;
33
use File::Compare;
387 dpurdie 34
use Encode;
311 dpurdie 35
 
36
my $VERSION = "1.0.0";                          # Update this
37
 
38
#
39
#   Options
40
#
41
my $opt_debug   = $ENV{'GBE_DEBUG'};            # Allow global debug
42
my $opt_verbose = $ENV{'GBE_VERBOSE'};          # Allow global verbose
43
my $opt_help = 0;
44
 
45
#
46
#   Globals
47
#
48
my $opr_done;                                   # User has done something
49
 
50
#-------------------------------------------------------------------------------
51
# Function        : Mainline Entry Point
52
#
53
# Description     :
54
#
55
# Inputs          :
56
#
57
my $result = GetOptions (
58
                "help:+"        => \$opt_help,              # flag, multiple use allowed
59
                "manual:3"      => \$opt_help,              # flag
60
                "verbose:+"     => \$opt_verbose,           # flag, multiple use allowed
61
 
62
                );
63
 
64
                #
65
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
66
                #
67
 
68
#
69
#   Process help and manual options
70
#
71
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
72
pod2usage(-verbose => 1) if ($opt_help == 2 );
73
pod2usage(-verbose => 2) if ($opt_help > 2);
74
 
75
#
76
#   Configure the error reporting process now that we have the user options
77
#
78
ErrorConfig( 'name'    =>'SVN',
79
             'verbose' => $opt_verbose,
80
            );
81
 
82
#
369 dpurdie 83
#   Reconfigure the options parser to allow subcommands to parse options
311 dpurdie 84
#
85
Getopt::Long::Configure('permute');
86
 
87
#
88
#   Process command
89
#   First command line argument is a subversion command
90
#
91
my $cmd = shift @ARGV || "help";
92
CreatePackage()                        if ( $cmd =~ m/^create/ );
385 dpurdie 93
DeleteBranch()                         if ( $cmd =~ m/^delete-branch/ );
311 dpurdie 94
DeletePackage()                        if ( $cmd =~ m/^delete-package/ );
95
ImportPackage()                        if ( $cmd =~ m/^import/ );
96
SvnRepoCmd($cmd, @ARGV)                if ( $cmd eq 'ls' );
363 dpurdie 97
TestSvn()                              if ($cmd eq 'test');
369 dpurdie 98
ShowPaths()                            if ( $cmd =~ m/^path/ );
99
ShowTag()                              if ( $cmd =~ m/^tag/ );
100
ShowUrl()                              if ( $cmd =~ m/^url/ );
311 dpurdie 101
 
102
pod2usage(-verbose => 0, -message => "No valid operations specified") unless ( $opr_done );
103
exit 0;
104
 
105
#-------------------------------------------------------------------------------
369 dpurdie 106
# Function        : ShowPaths
107
#
108
# Description     : Show PATHS
109
#
110
# Inputs          : 
111
#
112
# Returns         : 
113
#
114
sub ShowPaths
115
{
116
    #
117
    #   Parse more options
118
    #
119
    GetOptions (
120
                "help:+"        => \$opt_help,
121
                "manual:3"      => \$opt_help,
122
                ) || Error ("Invalid command line" );
123
 
124
    #
125
    #   Subcommand specific help
126
    #
127
    SubCommandHelp( $opt_help, "Subversion Paths") if ($opt_help || $#ARGV >= 0);
128
 
129
    #
130
    #   Display known PATHS
131
    #
132
    my ( $pSVN_URLS, $pSVN_URLS_LIST) = SvnPaths();
133
    print ("Configured SubVersion Repository Paths\n");
134
    print sprintf("    %-20s %s\n", 'Tag', 'URL Prefix');
135
 
136
    foreach my $key ( @{$pSVN_URLS_LIST} )
137
    {
138
        print sprintf("    %-20s %s\n", $key || 'Default', $pSVN_URLS->{$key} );
139
    }
140
 
141
    $opr_done = 1;
142
}
143
 
144
#-------------------------------------------------------------------------------
145
# Function        : ShowTag
146
#
147
# Description     : Convert a URL into a TAG
148
#                   Convert the current workspace info into a TAG
149
#
150
# Inputs          : url                     - Url to convert (optional)
151
#                   Options
152
#                       -help[=n]           - Show help
153
#                       -man                - Show manual
154
#                       -url=url            - Convert URL
155
#                       -path=path          - Convert Workspace
156
#
157
# Returns         : Nothing
158
#
159
sub ShowTag
160
{
161
    my $opt_path;
162
    my $opt_url;
163
 
164
    #
165
    #   Parse more options
166
    #
167
    GetOptions (
168
                "help:+"        => \$opt_help,
169
                "manual:3"      => \$opt_help,
170
                "path:s"        => \$opt_path,
171
                "url:s"         => \$opt_url,
172
                ) || Error ("Invalid command line" );
173
 
174
    #
175
    #   Subcommand specific help
176
    #
177
    SubCommandHelp( $opt_help, "Url to Tag") if ($opt_help);
178
 
179
    #
180
    #   Bare argument is a URL
181
    #   If no arguments provided assume a path of the current directory
182
    #
183
    $opt_url = shift (@ARGV) if ( $#ARGV == 0 );
184
    $opt_path = '.' unless ( defined $opt_path || defined $opt_url );
185
 
186
    #
187
    #   Sanity Tests
188
    #
189
    Error ("Cannot specify both a URL and a PATH")
190
            if ( defined $opt_url && defined $opt_path );
191
    Warning ("Too many arguments") if ( $#ARGV >= 0 );
192
 
193
    #   Do all the hard work
194
    #
195
    my $uref;
196
    if ( $opt_url )
197
    {
198
        $uref = NewSessionByUrl ( $opt_url );
199
        $uref->CalcRmReference($uref->Full());
200
    }
201
    else
202
    {
203
        $uref = NewSessionByWS($opt_path, 0, 1);
204
        my $ws_root = $uref->SvnLocateWsRoot(1);
205
        $uref->CalcRmReference($uref->FullWs());
206
    }
207
 
208
    Message ("Tag is: " . $uref->RmRef() );
209
    $opr_done = 1;
210
}
211
#-------------------------------------------------------------------------------
212
# Function        : ShowUrl
213
#
214
# Description     : Convert a TAG into a URL
215
#                   Show the current workspace URL
216
#
217
# Inputs          : tag                     - Tag to convert (optional)
218
#                   Options
219
#                       -help[=n]           - Show help
220
#                       -man                - Show manual
221
#                       -tag=tag            - Convert TAG
222
#                       -path=path          - Convert Workspace
223
#
224
# Returns         : Nothing
225
#
226
sub ShowUrl
227
{
228
    my $opt_path;
229
    my $opt_tag;
230
 
231
    #
232
    #   Parse more options
233
    #
234
    GetOptions (
235
                "help:+"        => \$opt_help,
236
                "manual:3"      => \$opt_help,
237
                "path:s"        => \$opt_path,
238
                "tag:s"         => \$opt_tag,
239
                ) || Error ("Invalid command line" );
240
 
241
    #
242
    #   Subcommand specific help
243
    #
244
    SubCommandHelp( $opt_help, "Tag to Url") if ($opt_help);
245
 
246
    #
247
    #   Bare argument is a TAG
248
    #   If no arguments provided assume a path of the current directory
249
    #
250
    $opt_tag = shift (@ARGV) if ( $#ARGV == 0 );
251
    $opt_path = '.' unless ( defined $opt_path || defined $opt_tag );
252
 
253
    #
254
    #   Sanity Tests
255
    #
256
    Error ("Cannot specify both a TAG and a PATH")
257
            if ( defined $opt_tag && defined $opt_path );
258
    Warning ("Too many arguments") if ( $#ARGV >= 0 );
259
 
260
    #   Do all the hard work
261
    #
262
    my $uref;
263
    my $url;
264
    if ( $opt_tag )
265
    {
266
        $url = SvnPath2Url($opt_tag);
267
    }
268
    else
269
    {
270
        $uref = NewSessionByWS($opt_path, 0, 1);
271
        my $ws_root = $uref->SvnLocateWsRoot(1);
272
        $url = $uref->FullWsRev();
273
    }
274
 
275
    Message ("Url: $url");
276
    $opr_done = 1;
277
}
278
 
279
#-------------------------------------------------------------------------------
363 dpurdie 280
# Function        : TestSvn
281
#
282
# Description     : Test access to subversion
283
#
284
# Inputs          : None
285
#
286
# Returns         :
287
#
288
sub TestSvn
289
{
290
    #
291
    #   Parse more options
292
    #
293
    GetOptions (
294
                "help:+"        => \$opt_help,
295
                "manual:3"      => \$opt_help,
296
                ) || Error ("Invalid command line" );
297
 
298
    #
299
    #   Subcommand specific help
300
    #
301
    SubCommandHelp( $opt_help, "Test Subversion") if ($opt_help || $#ARGV >= 0);
302
 
303
    SvnUserCmd( '--version');
304
    $opr_done = 1;
305
}
306
 
307
 
308
#-------------------------------------------------------------------------------
311 dpurdie 309
# Function        : SvnRepoCmd
310
#
311
# Description     : Execute a SVN command, where the first argument
312
#                   is a repository specifier
313
#
314
# Inputs          : $cmd
315
#                   $repo_url
316
#                   @opts
317
#
318
# Returns         : 
319
#
320
sub SvnRepoCmd
321
{
322
    my ( $cmd, $repo_url, @opts ) = @_;
323
    my $uref = NewSessionByUrl ( $repo_url );
324
 
325
    SvnUserCmd( $cmd,
326
            $uref->Full,
327
            @opts,
328
            { 'credentials' => 1 });
329
 
330
    $opr_done = 1;
331
}
332
 
333
#-------------------------------------------------------------------------------
334
# Function        : DeletePackage
335
#
336
# Description     : Delete a Package structure within a Repository
337
#                   Intended for test usage
338
#
339
# Inputs          : URL                 - Url to Repo + Package Base
340
#
341
# Returns         : 
342
#
343
sub DeletePackage
344
{
379 dpurdie 345
    my $opt_error = 0;
311 dpurdie 346
    #
347
    #   Parse more options
348
    #
349
    GetOptions (
350
                "help:+"        => \$opt_help,
351
                "manual:3"      => \$opt_help,
379 dpurdie 352
                "error!"       => \$opt_error,
311 dpurdie 353
                ) || Error ("Invalid command line" );
354
 
355
    #
356
    #   Subcommand specific help
357
    #
358
    SubCommandHelp( $opt_help, "Delete a Package") if ($opt_help || $#ARGV < 0);
359
 
360
    #
361
    #   Sanity Tests
362
    #
363
    Message ("Delete Entire Package Tree" );
364
    Warning ("Too many arguments: @ARGV") if ( $#ARGV >= 1 );
365
 
366
    #
367
    #   Do all the hard work
368
    #       Create
369
    #       Import
370
    #       Label
371
    #
372
    my $uref = NewSessionByUrl ( $ARGV[0] );
379 dpurdie 373
    $uref->SvnValidatePackageRoot(!$opt_error);
311 dpurdie 374
    $uref->SvnDelete (
375
                      'target'      => $uref->Full,
385 dpurdie 376
                      'comment'   => [$uref->Path().": Delete Package",'Deleted by user command: jats svn delete-package'],
379 dpurdie 377
                      'noerror'   => !$opt_error,
311 dpurdie 378
                      );
379
    $opr_done = 1;
380
}
381
 
382
#-------------------------------------------------------------------------------
383
# Function        : CreatePackage
384
#
385
# Description     : Create a Package structure within a Repository
386
#                   Optionally Import Data
387
#                   Optionally Tag the import
388
#                   Optionally Tag the import on a branch
389
#
390
# Inputs          : URL                 - Url to Repo + Package Base
391
#                   Options             - Command modifiers
392
#                       -import=path    - Import named directory
393
#                       -label=name     - Label the result
394
#                       -tag=name       - Import to Tag Only
395
#                       -branch=name    - Import to Branch only
396
#                       -new            - Must be new package
397
#                       -replace        - Replace existing
398
#
399
# Returns         : 
400
#
401
sub CreatePackage
402
{
403
    my $opt_import;
404
    my $opt_tag;
405
    my $opt_branch;
406
    my $opt_trunk;
407
    my $opt_new;
408
    my $opt_label;
409
    my $opt_replace;
410
    my $pname;
411
    my $type;
385 dpurdie 412
    my $opt_author;
413
    my $opt_date;
311 dpurdie 414
 
415
 
416
    Message ("Create New Package Version" );
417
 
418
    #
419
    #   Parse more options
420
    #
421
    GetOptions (
422
                "help:+"        => \$opt_help,
423
                "manual:3"      => \$opt_help,
424
                "verbose:+"     => \$opt_verbose,
425
                "import=s"      => \$opt_import,
426
                "new"           => \$opt_new,
427
                "branch=s"      => \$opt_branch,
428
                "trunk"         => \$opt_trunk,
1347 dpurdie 429
                "tags=s"        => \$opt_tag,
311 dpurdie 430
                "label=s"       => \$opt_label,
431
                "replace"       => \$opt_replace,
385 dpurdie 432
                'author=s'      => \$opt_author,
433
                'date=s'        => \$opt_date,
311 dpurdie 434
 
435
                ) || Error ("Invalid command line" );
436
 
437
    #
438
    #   Subcommand specific help
439
    #
440
    SubCommandHelp( $opt_help, "Create a Package Version") if ($opt_help || $#ARGV < 0);
441
 
442
    #
369 dpurdie 443
    #   Alter the error reporting parameters
311 dpurdie 444
    #
445
    ErrorConfig( 'verbose' => $opt_verbose );
446
 
447
    #
448
    #   Sanity Tests
449
    #
450
    my $count = 0;
451
    $count++ if ( $opt_trunk );
452
    $count++ if ( $opt_branch );
453
    $count++ if ( $opt_tag );
454
    Error ("Conflicting options: -trunk, -tag, -branch") if ( $count > 1 );
455
    Error ("Nothing imported to be labeled") if ( $count && !$opt_import );
456
    Error ("Import path does not exist: $opt_import") if ( $opt_import && ! -d $opt_import );
457
    Error ("Conflicting options: new and replace") if ( $opt_new && $opt_replace );
385 dpurdie 458
    Error ("Too many command line arguments") if ( exists $ARGV[1] );
311 dpurdie 459
 
1347 dpurdie 460
    $type = 'tags/' . $opt_tag          if ( $opt_tag);
461
    $type = 'branches/' . $opt_branch   if ( $opt_branch );
462
    $type = 'trunk'                     if ( $opt_trunk);
311 dpurdie 463
 
464
    #
465
    #   Do all the hard work
466
    #       Create
467
    #       Import
468
    #       Label
469
    #
470
    my $uref = NewSessionByUrl ( $ARGV[0] );
471
    $uref->SvnCreatePackage (
472
                      'import'  => $opt_import,
473
                      'label'   => $opt_label,
474
                      'type'    => $type,
475
                      'new'     => $opt_new,
476
                      'replace' => $opt_replace,
477
                      );
385 dpurdie 478
    #
479
    # Report RmPath as using a pegged version of a new package is a bit silly
480
    #
481
    Message ("Repository Ref: " . $uref->RmPath);
1347 dpurdie 482
    Message ("Vcs Tag       : " . $uref->SvnTag);
1270 dpurdie 483
    if ( $uref->{REVNO} )
484
    {
485
        $uref->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
486
        $uref->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
487
    }
311 dpurdie 488
    $opr_done = 1;
489
}
490
 
491
#-------------------------------------------------------------------------------
492
# Function        : ImportPackage
493
#
494
# Description     : Import a new version of a package
495
#                   Take great care to reuse file-versions that are already in
496
#                   the  package
497
#
369 dpurdie 498
#                   Intended to allow the importation of multiple
311 dpurdie 499
#                   versions of a package
500
#
501
# Inputs          : 
502
#
503
# Returns         : 
504
#
505
sub ImportPackage
506
{
507
    Message ("Import Package Version" );
508
 
509
    #
510
    #   Options
511
    #
512
    my $opt_package;
513
    my $opt_dir;
514
    my $opt_label;
515
    my $opt_replace = 0;
516
    my $opt_reuse;
517
    my $opt_workdir = "SvnImportDir";
518
    my $opt_delete = 1;
379 dpurdie 519
    my $opt_author;
520
    my $opt_date;
521
    my $opt_log = '';
522
    my $opt_branch;
523
    my $opt_datafile;
311 dpurdie 524
 
525
    #
526
    #   Other globals
527
    #
528
    my $url_label;
379 dpurdie 529
    my $url_branch;
311 dpurdie 530
 
531
    #
532
    #   Configuration options
533
    #
534
    my $result = GetOptions (
379 dpurdie 535
                    'help:+'        => \$opt_help,
536
                    'manual:3'      => \$opt_help,
537
                    'verbose:+'     => \$opt_verbose,
538
                    'package=s'     => \$opt_package,
539
                    'dir=s'         => \$opt_dir,
540
                    'label=s'       => \$opt_label,
541
                    'branch=s'      => \$opt_branch,
542
                    'replace'       => \$opt_replace,
543
                    'reuse'         => \$opt_reuse,
544
                    'workspace=s'   => \$opt_workdir,
545
                    'delete!'       => \$opt_delete,
546
                    'author=s'      => \$opt_author,
547
                    'date=s'        => \$opt_date,
548
                    'log=s'         => \$opt_log,
549
                    'datafile=s'    => \$opt_datafile,
311 dpurdie 550
 
551
                    #
552
                    #   Update documentation at the end of the file
553
                    #
554
                    ) || Error ("Invalid command line" );
555
 
556
    #
557
    #   Insert defaults
341 dpurdie 558
    #   User can specify base package via -package or a non-options argument
311 dpurdie 559
    #
560
    $opt_package = $ARGV[0] unless ( $opt_package );
379 dpurdie 561
    unlink $opt_datafile if ( defined $opt_datafile );
311 dpurdie 562
 
563
    #
564
    #   Subcommand specific help
565
    #
566
    SubCommandHelp( $opt_help, "Import directory to a Package")
567
        if ($opt_help || ! $opt_package );
568
 
569
    #
369 dpurdie 570
    #   Alter the error reporting parameters
311 dpurdie 571
    #
572
    ErrorConfig( 'verbose' => $opt_verbose );
573
 
574
    #
575
    #   Configure the error reporting process now that we have the user options
576
    #
577
    Error ("No package URL specified") unless ( $opt_package );
578
    Error ("No base directory specified") unless ( $opt_dir );
579
    Error ("Invalid base directory: $opt_dir") unless ( -d $opt_dir );
580
 
581
    #
582
    #   Create an SVN session
583
    #
584
    my $svn = NewSessionByUrl ( $opt_package );
585
 
586
    #
587
    #   Ensure that the required label is available
588
    #
589
    if ( $opt_label )
590
    {
591
        $opt_label = SvnIsaSimpleLabel ($opt_label);
592
        $url_label = $svn->BranchName( $opt_label, 'tags' );
593
        $svn->SvnValidateTarget (
594
                        'target' => $url_label,
595
                        'available' => 1,
596
                        ) unless ( $opt_replace );
597
    }
598
 
599
    #
379 dpurdie 600
    #   Validate the required branch
601
    #   It will be created if it doesn't exist
602
    #
603
    if ( $opt_branch )
604
    {
605
        $opt_branch = SvnIsaSimpleLabel($opt_branch);
606
        $url_branch = $svn->BranchName( $opt_branch, 'branches' );
385 dpurdie 607
        my $rv = $svn->SvnValidateTarget (
608
                        'cmd'    => 'SvnImporter. Create branch',
379 dpurdie 609
                        'target' => $url_branch,
610
                        'create' => 1,
611
                        );
385 dpurdie 612
        if ( $rv == 2 )
613
        {
614
            $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
615
            $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
616
        }
379 dpurdie 617
    }
618
 
619
    #
311 dpurdie 620
    #   Create a workspace based on the users package
621
    #   Allow the workspace to be reused to speed up multiple
622
    #   operations
623
    #
624
    unless ( $opt_reuse && -d $opt_workdir )
625
    {
626
        Message ("Creating Workspace");
627
        rmtree( $opt_workdir );
628
 
629
        $svn->SvnValidatePackageRoot ();
630
        #DebugDumpData( 'Svn', $svn );
631
        $svn->SvnValidateTarget (
632
                            'cmd'    => 'SvnImporter',
633
                            'target' => $svn->Full,
634
                            'require' => 1,
635
                            );
636
 
379 dpurdie 637
        my $url_co = $opt_branch ? $url_branch : $svn->Full . '/trunk';
1270 dpurdie 638
        $svn->SvnCo ( $url_co, $opt_workdir, $opt_verbose ? '--Print' : '--NoPrint' );
311 dpurdie 639
        Error ("Cannot locate the created Workspace")
640
            unless ( -d $opt_workdir );
641
    }
642
    else
643
    {
644
        Message ("Reusing Workspace");
645
    }
646
 
647
    #
648
    #   Determine differences between the two folders
649
    #       Create structures for each directory
650
    #
651
    Message ("Determine Files in packages");
652
 
653
    my $search = JatsLocateFiles->new("--Recurse=1",
654
                                       "--DirsToo",
655
                                       "--FilterOutRe=/\.svn/",
656
                                       "--FilterOutRe=/\.svn\$",
657
                                       "--FilterOutRe=^/${opt_workdir}\$",
658
                                       "--FilterOutRe=^/${opt_workdir}/",
659
                                       );
660
    my @ws = $search->search($opt_workdir);
661
    my @dir = $search->search($opt_dir);
662
 
1270 dpurdie 663
    #
664
    #   Scan for a source file
665
    #   Trying to detect empty views
666
    #   Look for file, not directory
667
    #
668
    {
669
        my $fileFound = 0;
670
        foreach ( @dir )
671
        {
672
            next if ( m~/$~ );
673
            $fileFound++;
674
            last;
675
        }
676
 
677
        unless ( $fileFound )
678
        {
679
            Warning ("No source files found in source view");
680
            $opr_done = 1;
681
            return;
682
        }
683
    }
684
 
311 dpurdie 685
    #Information ("WS Results", @ws);
686
    #Information ("DIR Results", @dir);
1270 dpurdie 687
    #Information ("WS Results: ", scalar @ws);
688
    #Information ("DIR Results:", scalar @dir);
311 dpurdie 689
 
690
    #
691
    #   Create a hash the Workspace and the User dir
692
    #   The key will be file names
693
    #
694
    my %ws;  map ( $ws{$_} = 1 , @ws );
695
    my %dir; map ( $dir{$_} = 1 , @dir );
696
 
697
    #
698
    #   Create a hash of common elements
699
    #   Removing then from the other two
700
    #
701
    my %common;
702
    foreach ( keys %ws )
703
    {
704
        next unless ( exists $dir{$_} );
705
        $common{$_} = 1;
706
        delete $ws{$_};
707
        delete $dir{$_};
708
    }
709
 
710
    #DebugDumpData( 'WS', \%ws );
711
    #DebugDumpData( 'DIR', \%dir );
712
    #DebugDumpData( 'COMMON', \%common );
713
 
714
    #
379 dpurdie 715
    #   Need to consider the case where a file has been replaced with a directory
716
    #   and visa-versa. Delete files and directories first.
717
    #
718
    #
719
    #   Remove files
720
    #   Sort in reverse. This will ensure that we process directory
721
    #   contents before directories
722
    #
723
    my @rm_files = reverse sort keys %ws;
724
    if ( @rm_files )
725
    {
726
        foreach my $file ( @rm_files  )
727
        {
728
            Verbose ("Removing $file");
729
            unlink "$opt_workdir/$file";
730
        }
731
 
732
        #
733
        #   Inform Subversion about the removed files
734
        #
735
        my $base = 0;
736
        my $num = $#rm_files;
737
        Message ("Update the workspace: Removed " . ($num + 1) . " Files");
738
 
739
        while ( $base <= $num )
740
        {
741
            my $end = $base + 200;
742
            $end = $num if ( $end > $num );
743
 
744
            $svn->SvnCmd ( 'delete', map ("$opt_workdir/$_@", @rm_files[$base .. $end] ),
745
                            { 'error' => 'Deleting files from workspace' } );
746
 
747
            $base = $end + 1;
748
        }
749
    }
750
 
751
    #
311 dpurdie 752
    #   Add New Files
753
    #   Won't add empty directories at this point
754
    #
755
    #   Process by sorted list
756
    #   This will ensure we process parent directories first
757
    #
758
    my @added = sort keys %dir;
759
    if ( @added )
760
    {
761
        foreach my $file ( @added  )
762
        {
763
            my $src = "$opt_dir/$file";
764
            my $target = "$opt_workdir/$file";
765
 
766
            if ( -d $src )
767
            {
379 dpurdie 768
                Verbose ("Adding directory: $file");
311 dpurdie 769
                mkdir ( $target ) unless (-d $target);
770
            }
771
            else
772
            {
773
 
774
                my $path = dirname ( $target);
775
                mkdir ( $path ) unless (-d $path);
776
 
777
                Verbose ("Adding $file");
778
                unless (File::Copy::copy( $src, $target ))
779
                {
780
                    Error("Failed to transfer file [$file]: $!");
781
                }
782
            }
783
        }
784
 
785
        #
786
        #   Inform Subversion about the added files
787
        #   The command line does have a finite length, so add them 200 at a
788
        #   time.
789
        #
790
 
791
        my $base = 0;
792
        my $num = $#added;
379 dpurdie 793
        Message ("Update the workspace: Added " . (1 + $num) . " files");
311 dpurdie 794
 
795
        while ( $base <= $num )
796
        {
797
            my $end = $base + 200;
798
            $end = $num if ( $end > $num );
799
 
800
            $svn->SvnCmd ( 'add'
801
                            , '--depth=empty'
802
                            , '--parents'
379 dpurdie 803
                            , map ("$opt_workdir/$_@", @added[$base .. $end] ),
311 dpurdie 804
                            { 'error' => 'Adding files to workspace' } );
805
 
806
            $base = $end + 1;
807
        }
808
    }
809
 
810
    #
811
    #   The common files may have changed
812
    #   Simply copy them all in and let subversion figure it out
813
    #
814
    foreach my $file ( sort keys %common  )
815
    {
816
        my $src = "$opt_dir/$file";
817
        my $target = "$opt_workdir/$file";
818
 
819
        next if ( -d $src );
820
        if ( File::Compare::compare ($src, $target) )
821
        {
822
            Verbose ("Transfer $file");
823
            unlink $target;
824
            unless (File::Copy::copy( $src, $target ))
825
            {
826
                Error("Failed to transfer file [$file]: $!",
827
                      "Src: $src",
828
                      "Tgt: $target");
829
            }
830
        }
831
    }
832
 
833
    #
834
    #   Commit the workspace
835
    #   This will go back onto the trunk
836
    #
837
    $svn = NewSessionByWS( $opt_workdir );
379 dpurdie 838
    my $pkgPath = $svn->Path();
387 dpurdie 839
 
379 dpurdie 840
    my $ciComment = "$pkgPath: Checkin by Svn Import";
841
    $ciComment .= "\n" . $opt_log if ( $opt_log );
842
    $ciComment =~ s~\r\n~\n~g;
387 dpurdie 843
    $ciComment =~ s~\r~\n~g;
844
    $ciComment = encode('UTF-8', $ciComment, Encode::FB_DEFAULT);
845
 
379 dpurdie 846
    $svn->SvnCi ('comment' => $ciComment, 'allowSame' => 1 );
381 dpurdie 847
    Message ("Repository Ref: " . $svn->RmRef) unless( $opt_label );
379 dpurdie 848
    $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
849
    $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
311 dpurdie 850
 
851
    #
852
    #   Label the result
853
    #   The workspace will have been updated, so we can use it as the base for
854
    #   the labeling process
855
    #
856
    if ( $opt_label )
857
    {
858
        $svn->SvnCopyWs (
859
                       target => $url_label,
860
                       'noswitch' => 1,
861
                       'replace' => $opt_replace,
379 dpurdie 862
                       'comment' => "$pkgPath: Tagged by Jats Svn Import",
311 dpurdie 863
                       );
864
        Message ("Repository Ref: " . $svn->RmRef);
1347 dpurdie 865
        Message ("Vcs Tag       : " . $svn->SvnTag);
379 dpurdie 866
        $svn->setRepoProperty('svn:author', $opt_author) if (defined ($opt_author));
867
        $svn->setRepoProperty('svn:date', $opt_date) if (defined ($opt_date));
311 dpurdie 868
    }
869
 
870
    #
871
    #   Clean up
872
    #
873
    if ( $opt_delete && ! $opt_reuse )
874
    {
875
        Message ("Delete Workspace");
876
        rmtree( $opt_workdir );
877
    }
379 dpurdie 878
 
879
    #
880
    #   Automation data transfer
881
    #
882
    if ( defined $opt_datafile )
883
    {
884
        my $data = JatsProperties::New();
885
 
886
        $data->setProperty('Command'        , 'ImportPackage');
887
        $data->setProperty('Label'          , $opt_label);
1347 dpurdie 888
        $data->setProperty('subversion.url' , $svn->RmRef);
889
        $data->setProperty('subversion.tag' , $svn->SvnTag);
379 dpurdie 890
 
891
        $data->Dump('InfoFile') if ($opt_verbose);
892
        $data->store( $opt_datafile );
893
    }
894
 
311 dpurdie 895
    $opr_done = 1;
896
}
897
 
898
#-------------------------------------------------------------------------------
385 dpurdie 899
# Function        : DeleteBranch
900
#
901
# Description     : Delete the branch that a workspace is based upon
902
#
903
# Inputs          : 
904
#
905
# Returns         : 
906
#
907
sub DeleteBranch
908
{
909
    my $opt_path;
910
    my $opt_error = 0;
911
    #
912
    #   Parse more options
913
    #
914
    GetOptions (
915
                "help:+"        => \$opt_help,
916
                "manual:3"      => \$opt_help,
917
                "path:s"        => \$opt_path,
918
                ) || Error ("Invalid command line" );
919
 
920
    #
921
    #   Subcommand specific help
922
    #
923
    SubCommandHelp( $opt_help, "Delete Branch") if ($opt_help);
924
 
925
    #
926
    #   Sanity Tests
927
    #
928
    Message ("Delete Workspace Branch" );
929
    Error ("Too many arguments: @ARGV") if ( $#ARGV >= 0 );
930
 
931
    #
932
    #   Do all the hard work
933
    #
934
    $opt_path = '.' unless ( defined $opt_path );
935
    my $uref = NewSessionByWS($opt_path, 0, 1);
936
    my $ws_root = $uref->SvnLocateWsRoot(1);
937
    my $ws_url = $uref->FullWs();
938
 
939
    #
940
    #   Must be a branch
941
    #
942
    Error ("Workspace is not based on a branch")
943
        unless ( $ws_url =~ m ~/branches/~ );
944
 
945
    Message ("Deleting: " . $uref->{WSURL} );
946
    $uref->SvnDelete (
947
                      'target'    => $ws_url,
948
                      'comment'   => [$uref->Path().": Delete Branch",'Deleted by user command: jats svn delete-branch'],
949
                      );
950
    $opr_done = 1;
951
}
952
 
953
 
954
#-------------------------------------------------------------------------------
311 dpurdie 955
# Function        : SubCommandHelp
956
#
957
# Description     : Provide help on a subcommand
958
#
959
# Inputs          : $help_level             - Help Level 1,2,3
960
#                   $topic                  - Topic Name
961
#
962
# Returns         : This function does not return
963
#
964
sub SubCommandHelp
965
{
966
    my ($help_level, $topic) = @_;
967
    my @sections;
968
    #
969
    #   Spell out the section we want to display
970
    #
971
    #   Note:
972
    #   Due to bug in pod2usage can't use 'head1' by itself
973
    #   Each one needs a subsection.
974
    #
975
    push @sections, qw( NAME SYNOPSIS ) ;
976
    push @sections, qw( ARGUMENTS OPTIONS ) if ( $help_level > 1 );
977
    push @sections, qw( DESCRIPTION )       if ( $help_level > 2 );
978
 
979
    #
980
    #   Extract section from the POD
981
    #
982
    pod2usage({-verbose => 99,
983
               -noperldoc => 1,
984
               -sections => $topic . '/' . join('|', @sections) } );
985
}
986
 
987
 
988
 
989
#-------------------------------------------------------------------------------
990
#   Documentation
991
#   NOTE
992
#
993
#   Each subcommand MUST have
994
#   head1 section as used by the subcommand
995
#       This should be empty, as the contents will NOT be displayed
996
#   head2 sections called
997
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION
998
#
999
#=head1 xxxxxx
1000
#=head2 NAME
1001
#=head2 SYNOPSIS
1002
#=head2 ARGUMENTS
1003
#=head2 OPTIONS
1004
#=head2 DESCRIPTION
1005
#
1006
 
1007
=pod
1008
 
361 dpurdie 1009
=for htmltoc    GENERAL::Subversion::
1010
 
311 dpurdie 1011
=head1 NAME
1012
 
1013
jats svn - Miscellaneous SubVersion Operations
1014
 
1015
=head1 SYNOPSIS
1016
 
1017
jats svn [options] command [command options]
1018
 
1019
 Options:
1020
    -help[=n]              - Help message, [n=1,2,3]
1021
    -man                   - Full documentation [-help=3]
1022
    -verbose[=n]           - Verbose command operation
1023
 
1024
 Common Command Options:
1025
    All command support suboptions to provide command specific help
1026
 
1027
    -help[=n]              - Help message, [n=1,2,3]
1028
    -man                   - Full documentation [-help=3]
1029
 
1030
 Commands are:
363 dpurdie 1031
    test                   - Test access to subversion
369 dpurdie 1032
    paths                  - Display Subversion tag to URL conversions
311 dpurdie 1033
    ls URL                 - List Repo contents for URL
369 dpurdie 1034
    tag [URL]              - Convert URL or Path to a Release Manager Tag
1035
    url [TAG]              - Convert TAG or Path to a Subversion URL
311 dpurdie 1036
    delete-package URL     - Delete Package Subtree
385 dpurdie 1037
    delete-branch          - Delete a Development Branch
311 dpurdie 1038
    create URL             - Create a new package at URL
1039
    import URL             - Import files to package at URL
1040
 
1041
 Use the command
1042
    jats svn command -h
1043
 for command specific help
1044
 
1045
 
1046
=head1 OPTIONS
1047
 
1048
=over
1049
 
1050
=item B<-help[=n]>
1051
 
1052
Print a help message and exit. The level of help may be either 1, 2 or
1053
3 for a full manual.
1054
 
1055
This option may be specified multiple times to increment the help level, or
1056
the help level may be directly specified as a number.
1057
 
1058
=item B<-man>
1059
 
1060
This is the same as '-help=3'.
1061
The complete help is produced in a man page format.
1062
 
1063
=item B<--verbose[=n]>
1064
 
1065
This option will increase the level of verbosity of the commands.
1066
 
1067
If an argument is provided, then it will be used to set the level, otherwise the
1068
existing level will be incremented. This option may be specified multiple times.
1069
 
1070
=back
1071
 
1072
=head1 DESCRIPTION
1073
 
1074
This program provides a number of useful Subversion based operations.
1075
 
363 dpurdie 1076
=head1 Test Subversion
1077
 
1078
=head2 NAME
1079
 
1080
Test Subversion
1081
 
1082
=head2 SYNOPSIS
1083
 
1084
    jats svn test
1085
 
1086
=head2 DESCRIPTION
1087
 
1088
This command will ensure that the subversion command line utility can be
1089
located. The command will report the version of the svn client found.
1090
 
369 dpurdie 1091
=head1 Subversion Paths
1092
 
1093
=head2 NAME
1094
 
1095
Subversion Paths
1096
 
1097
=head2 SYNOPSIS
1098
 
1099
    jats svn paths
1100
 
1101
=head2 DESCRIPTION
1102
 
1103
This command will display the base Tags and associated URLs that are used by
1104
JATS to convert a 'Subversion Tag' into a full URLs that will be used to access
1105
a physical repository.
1106
 
1107
The 'Tags' configuration is site-specific.
1108
 
311 dpurdie 1109
=head1 List Repository
1110
 
363 dpurdie 1111
=head2 NAME
1112
 
1113
List Repository
1114
 
1115
=head2 SYNOPSIS
1116
 
1117
    jats svn ls <URL>
1118
 
1119
=head2 DESCRIPTION
1120
 
311 dpurdie 1121
This command will take a URL and perform a 'svn' list operation. The URL will
1122
be expanded to include the site specific repository.
1123
 
369 dpurdie 1124
=head1 Url to Tag
1125
 
1126
=head2 NAME
1127
 
1128
Url to Tag
1129
 
1130
=head2 SYNOPSIS
1131
 
1132
    jats svn tag [Option] [tag]
1133
 
1134
 Options:
1135
    -help[=n]              - Help message, [n=1,2,3]
1136
    -man                   - Full documentation [-help=3]
1137
    -path=path             - Convert specified path
1138
    -url=url               - Convert specified URL
1139
 
1140
=head2 DESCRIPTION
1141
 
1142
This command will convert a URL or a PATH to a Subversion Tag that can
1143
be used within the remainder of the build system. If no PATH or URL is provided,
1144
then the command uses a path of the current directory.
1145
 
1146
The command will convert either a PATH or a URL. It will not do both.
1147
 
1148
The command will use the configured Subversion URL prefixes to create the Tag.
1149
 
1150
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1151
The conversion will return a Tag to the root of the Workspace and Peg it to
1152
the last committed version. The command will not determine if the workspace
1153
contains modified files.
1154
 
1155
If a URL is to be converted, then the resultant value should be used with
1156
caution. The result is only as good as the provided URL and may not address
1157
the root of a package.
1158
 
1159
=head1 Tag to Url
1160
 
1161
=head2 NAME
1162
 
1163
Tag to Url
1164
 
1165
=head2 SYNOPSIS
1166
 
1167
    jats svn url [Option] [url]
1168
 
1169
 Options:
1170
    -help[=n]              - Help message, [n=1,2,3]
1171
    -man                   - Full documentation [-help=3]
1172
    -path=path             - Convert specified path
1173
    -url=url               - Convert specified URL
1174
 
1175
=head2 DESCRIPTION
1176
 
1177
This command will convert a TAG or a PATH to a full URL that can be used
1178
directly by Subversion. If no PATH or TAG is provided, then the command uses a
1179
path of the current directory.
1180
 
1181
The command will convert either a TAG or a URL. It will not do both.
1182
 
1183
The command will use the configured Subversion URL prefixes to expand the TAG.
1184
 
1185
If a PATH is to be converted, then the PATH must address a Subversion workspace.
1186
The conversion will return a URL to the root of the Workspace and Peg it to
1187
the last committed version. The command will not determine if the workspace
1188
contains modified files.
1189
 
1190
If a TAG is to be converted, then the resultant value should be used with
1191
caution. The result is only as good as the provided URL and may not address
1192
the root of a package.
1193
 
311 dpurdie 1194
=head1 Delete a Package
1195
 
1196
=head2 NAME
1197
 
1198
Delete a Package
1199
 
1200
=head2 SYNOPSIS
1201
 
1202
jats svn delete-package URL [options]
1203
 
1204
 Options:
1205
    -help[=n]              - Help message, [n=1,2,3]
1206
    -man                   - Full documentation [-help=3]
1207
    -verbose[=n]           - Verbose command operation
1208
 
1209
=head2 ARGUMENTS
1210
 
1211
The command takes one argument: The URL of the desired package.
1212
This may be be:
1213
 
1214
=over
1215
 
1216
=item * A full URL
1217
 
1218
Complete with protocol and path information.
1219
 
1220
=item * A simple URL
1221
 
1222
JATS will prepend the site-specific repository location to the user provided URL
1223
 
1224
=back
1225
 
1226
=head2 OPTIONS
1227
 
1228
This command has no significant options, other than the general help options.
1229
 
1230
=head2 DESCRIPTION
1231
 
1232
This command will delete a package from the repository. It will ensure
1233
that the package is a valid package, before it is deleted.
1234
 
1235
The command is intended to be used by test scripts, rather than users.
1236
 
385 dpurdie 1237
=head1 Delete Branch
1238
 
1239
=head2 NAME
1240
 
1241
Delete the Workspace Branch
1242
 
1243
=head2 SYNOPSIS
1244
 
1245
jats svn delete-branch [options]
1246
 
1247
 Options:
1248
    -help[=n]              - Help message, [n=1,2,3]
1249
    -man                   - Full documentation [-help=3]
1250
    -verbose[=n]           - Verbose command operation
1251
    -path=path             - Target workspace
1252
 
1253
=head2 ARGUMENTS
1254
 
1255
The command takes no arguments.
1256
 
1257
=head2 OPTIONS
1258
 
1259
=over
1260
 
1261
=item B<-path=path>
1262
 
1263
This options specifies the path of the target workspace. If not provided the
1264
command will use the current directory.
1265
 
1266
=back
1267
 
1268
=head2 DESCRIPTION
1269
 
1270
This command will delete the branch associated with the workspace in the
1271
specified path. It is intended to simplify the deletion of Private or
1272
Development branches.
1273
 
1274
If the workspace is not linked to a 'branch' then the command will fail.
1275
 
311 dpurdie 1276
=head1 Create a Package Version
1277
 
1278
=head2 NAME
1279
 
1280
Create a Package Version
1281
 
1282
=head2 SYNOPSIS
1283
 
1284
jats svn [options] create URL [command options]
1285
 
1286
 Options:
1287
    -help[=n]               - Help message, [n=1,2,3]
1288
    -man                    - Full documentation [-help=3]
1289
    -verbose[=n]            - Verbose command operation
1290
 
1291
 Command Options
1292
    -help[=n]               - Provide command specific help
1293
    -import=nnn             - Import directory tree
1294
    -label=nnn              - Label it (trunk import only)
1295
    -new                    - Package must not exist
1296
    -replace                - Replace any existing versions
1297
    -trunk                  - Import to trunk
1298
    -tags=nnn               - Import to tags
1299
    -branch=nnn             - Import to branches
1300
 
1301
=head2 ARGUMENTS
1302
 
1303
The command takes one argument: The URL of the desired package.
1304
This may be be:
1305
 
1306
=over
1307
 
1308
=item * A full URL
1309
 
1310
Complete with protocol and path information.
1311
 
1312
=item * A simple URL
1313
 
1314
JATS will prepend the site-specific repository location to the user provided URL
1315
 
1316
=back
1317
 
1318
=head2 OPTIONS
1319
 
1320
=over
1321
 
1322
=item -help[=n]
1323
 
1324
Print a help message and exit. The level of help may be either 1, 2 or 3.
1325
 
1326
This option may be specified multiple times to increment the help level, or
1327
the help level may be directly specified as a number.
1328
 
1329
=item -import=nnn
1330
 
1331
This option specifies the path of a subdirectory tree to import into the newly
1332
created package. In not provided, then only a package skeleton will be created.
1333
 
1334
=item -label=nnn
1335
 
1336
This option specifies a label to place the imported source, if the source is
1337
being imported to the 'trunk' of the package.
1338
 
1339
=item -new
1340
 
1341
This option specifies that the named package MUST not exist at all.
1342
 
1343
=item -replace
1344
 
1345
This option allows the program to replace any existing versions of the
1346
imported source. It will allow the deletion of any existing trunk, tags or
1347
branches.
1348
 
1349
=item -trunk
1350
 
1351
This option specifies that imported source will be placed on the trunk of the
1352
package. This is the default mode of import.
1353
 
1354
The options -trunk, -tags and -branch are mutually exclusive.
1355
 
1356
=item -tags=nnn
1357
 
1358
This option specifies that imported source will be placed directly on the
1359
named tag of the package.
1360
 
1361
The options -trunk, -tags and -branch are mutually exclusive.
1362
 
1363
=item -branch=nnn
1364
 
1365
This option specifies that imported source will be placed directly on the
1366
named branch of the package.
1367
 
1368
The options -trunk, -tags and -branch are mutually exclusive.
1369
 
1370
=back
1371
 
1372
=head2 DESCRIPTION
1373
 
1374
This command will create a new package within a repository. It will ensure
1375
that the package contains the three required subdirectories: trunk, tags and
1376
branches.
1377
 
1378
The command will also ensure that packages are not placed at inappropriate
1379
locations within the repository. It is not correct to place a package within
1380
another package.
1381
 
1382
The command will, optionally, import a directory tree into the repository and,
1383
optionally, label the package.
1384
 
1385
The package body may be imported to the 'trunk' or to a branch or a tag.
1386
By default the data will be imported to the trunk and may be labeled (tagged).
1387
 
1388
Options allow the targets to be deleted if they exist or to ensure that they
1389
are not present.
1390
 
1391
The command does not attempt to merge file versions within the repository. It
1392
may result in multiple instances of a file within the repository. Use only for
341 dpurdie 1393
simple imports. Use the 'import' command for more sophisticated import requirements.
311 dpurdie 1394
 
1395
=head1 Import directory to a Package
1396
 
1397
=head2 NAME
1398
 
1399
Import directory to a Package
1400
 
1401
=head2 SYNOPSIS
1402
 
1403
jats svn [options] import URL [command options]
1404
 
1405
 Options:
1406
    -help[=n]               - Help message, [n=1,2,3]
1407
    -man                    - Full documentation [-help=3]
1408
    -verbose[=n]            - Verbose command operation
1409
 
1410
 Command Options
1411
    -help[=n]               - Command specific help, [n=1,2,3]
1412
    -verbose[=n]            - Verbose operation
1413
    -package=name           - Name of source package
1414
    -dir=path               - Path to new version
379 dpurdie 1415
    -label=label            - Label the result
1416
    -branch=branchName      - Base import on a branch
311 dpurdie 1417
    -replace                - Allow the label to be replaced
1418
    -reuse                  - Reuse the import directory
1419
    -workspace=path         - Path and name of alternate workspace
1420
    -[no]delete             - Deletes workspace after use. Default:yes
379 dpurdie 1421
    -author=name            - Force author of changes
1422
    -date=dateString        - Force date of changes
1423
    -log=text               - Append text to the commit message
1424
    -datafile=path          - Export tag data for automation
311 dpurdie 1425
 
379 dpurdie 1426
 
311 dpurdie 1427
=head2 ARGUMENTS
1428
 
1429
The command takes one argument: The URL of the desired package.
1430
This may be be:
1431
 
1432
=over
1433
 
1434
=item * A full URL
1435
 
1436
Complete with protocol and path information.
1437
 
1438
=item * A simple URL
1439
 
1440
JATS will prepend the site-specific repository location to the user provided URL
1441
 
1442
=back
1443
 
1444
=head2 OPTIONS
1445
 
1446
=over
1447
 
1448
=item -help[=n]
1449
 
1450
Print a help message and exit. The level of help may be either 1, 2 or 3.
1451
 
1452
This option may be specified multiple times to increment the help level, or
1453
the help level may be directly specified as a number.
1454
 
1455
=item -verbose[=n]
1456
 
1457
This option will increase the level of verbosity of the utility.
1458
 
1459
If an argument is provided, then it will be used to set the level, otherwise the
1460
existing level will be incremented. This option may be specified multiple times.
1461
 
1462
 
1463
=item -package=name
1464
 
1465
Either this option or a bare URL on the command line must be provided. It
1466
specifies the repository and package to be used as a basis for the work.
1467
 
1468
=item -dir=path
1469
 
1470
This option is mandatory. It specifies the path to a local directory that
1471
contains a version of the software to be checked in.
1472
 
1473
=item -label=name
1474
 
1475
The resulting software version will be labeled with this tag, if it is provided.
1476
 
383 dpurdie 1477
A label name of TIMESTAMP will be treated in special manner. The name will be
1478
replaced with a unique name based on the users name and the current date time.
1479
 
379 dpurdie 1480
=item -branch=branchName
1481
 
1482
This option will cause the importation to be referenced to the named branch.
1483
If the branch does not exist it will be created. If it does exist then it will
1484
be used.
1485
 
1486
If this option is not specified, then the importation will be based on the 'trunk'.
1487
 
1488
If the Workspace is provided, then it will be used independently of this option.
1489
 
383 dpurdie 1490
A branchName of TIMESTAMP will be treated in special manner. The name will be
1491
replaced with a unique name based on the users name and the current date time.
1492
 
311 dpurdie 1493
=item -replace
1494
 
1495
This option, if provided, allows the label to be replaced.
1496
 
1497
=item -reuse
1498
 
1499
This option can be used to speed the creation of multiple versions in a scripted
1500
environment. The option allows the utility to reuse the workspace if it exists.
1501
 
1502
=item -workspace=path
1503
 
1504
This option specifies an alternate workspace directory to create and use. The
1505
default directory is "SvnImportDir" within the users current directory.
1506
 
1507
=item [no]delete
1508
 
341 dpurdie 1509
This option control the deletion of the workspace directory. By default the
311 dpurdie 1510
directory will be deleted, unless re-use is also used.
1511
 
379 dpurdie 1512
=item -author=name
1513
 
1514
This option will force the author of changes as recorded in the repository.
385 dpurdie 1515
The repository must be configured to allow such changes.
379 dpurdie 1516
 
1517
This option may not work for non-admin users.
1518
 
1519
=item -date=dateString
1520
 
1521
This option will force the date of the changes as recorded in the repository.
385 dpurdie 1522
The repository must be configured to allow such changes.
379 dpurdie 1523
The dateString is in a restricted ISO 8601 format: ie 2009-02-12T00:44:04.921324Z
1524
 
1525
This option may not work for non-admin users.
1526
 
1527
=item -log=text
1528
 
1529
This option will append the specified text to the commit message.
1530
The first line of the commit message is fixed by the import tool.
1531
 
1532
=item -datafile=path
1533
 
1534
This option will cause the utility to create a data file to record the import
1535
tag. It is used for automation of the import process.
1536
 
311 dpurdie 1537
=back
1538
 
1539
=head2 DESCRIPTION
1540
 
1541
Import a new version of a package to the trunk of the package. The utility
1542
will only import changed files so that file history is preserved within the
1543
repository.
1544
 
1545
This utility is used import software from another version control system
1546
The utility will:
1547
 
1548
=over
1549
 
361 dpurdie 1550
=item *
311 dpurdie 1551
 
361 dpurdie 1552
Create a Work Space based on the current package version
1553
 
379 dpurdie 1554
The 'trunk' of the named package will be used as the base for the workspace,
1555
unless modified with the -branch option.
311 dpurdie 1556
 
361 dpurdie 1557
=item *
311 dpurdie 1558
 
361 dpurdie 1559
Update files and directories
1560
 
311 dpurdie 1561
Determines the files and directories that have been added and deleted and
1562
update the Workspace to reflect the new structure.
1563
 
361 dpurdie 1564
=item *
311 dpurdie 1565
 
361 dpurdie 1566
Check in the new version
311 dpurdie 1567
 
361 dpurdie 1568
=item *
1569
 
1570
Label the new version
1571
 
311 dpurdie 1572
=back
1573
 
1574
=cut
1575