Subversion Repositories DevTools

Rev

Rev 1451 | Rev 2028 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1451 Rev 1454
Line 355... Line 355...
355
#   length filename in error messages and this name is part of the path
355
#   length filename in error messages and this name is part of the path
356
#
356
#
357
#   Base the viewname on the view label. This will simplify the creation
357
#   Base the viewname on the view label. This will simplify the creation
358
#   of multiple views and reduce the risk of unexpected deletion
358
#   of multiple views and reduce the risk of unexpected deletion
359
#
359
#
360
if ( $opt_viewname )
-
 
361
{
-
 
362
    Error ("View Name contains invalid characters" )
-
 
363
        unless ( $opt_viewname =~ m~^[0-9a-z]([-.:0-9a-z_]*[0-9a-z])?$~i )
-
 
364
}
-
 
365
else
-
 
366
{
-
 
367
    #
-
 
368
    #   Create a view name based on the provide URL or SVN Reference
-
 
369
    #   Unless creating a branch. Branch name will be appended later
-
 
370
    #
-
 
371
    if ( $svnSession->Type )
-
 
372
    {
-
 
373
        $opt_viewname = $svnSession->Path;
-
 
374
        $opt_viewname .= '_' . ($svnSession->Version || 'trunk') unless $opt_branch;
-
 
375
 
-
 
376
        #
-
 
377
        #   Tags and Branches 'should' include the package name
-
 
378
        #   This will lead to a duplication of the package name
-
 
379
        #   ie: aaaaa/package/tags/package_version
-
 
380
        #   Attempt to remove these
-
 
381
        #
-
 
382
        if ( $opt_viewname =~ s~[_/]([\-.:0-9a-zA-Z]+)_\1_~_$1_~ )
-
 
383
        {
-
 
384
            Verbose ("Removed duplicate package name: $1 from $opt_viewname");
-
 
385
        }
-
 
386
    }
-
 
387
    else
-
 
388
    {
-
 
389
        $opt_viewname = $svnSession->Path;
-
 
390
        $bad_label_name = 1;
-
 
391
    }
-
 
392
 
-
 
393
    #
-
 
394
    #   Append information to indicate the exact type of the WorkSpace
-
 
395
    #   Normally mutually exclusive
-
 
396
    #
-
 
397
    $opt_viewname .= '_Tip' if ( $opt_devMode eq 'tip' );
-
 
398
    $opt_viewname .= '_Tag' if ( $opt_devMode eq 'tag' );
-
 
399
    $opt_viewname .= '_Exact' if ( $opt_devMode eq 'exact' );
-
 
400
    $opt_viewname .= '_' . $opt_branch if ( $opt_branch );
-
 
401
    
-
 
402
    #
-
 
403
    #   Create a simple dir name
-
 
404
    #       Remove path sep characters and replace with _
-
 
405
    #       Remove Peg marker (@) as this breaks svn
-
 
406
    #       Replace multiple _ with a single _
-
 
407
    #       Remove trailing _ - caused by URL with a trailing /
-
 
408
    #
-
 
409
    $opt_viewname =~ s~[^\-.:0-9a-zA-Z_]~_~g;
-
 
410
    $opt_viewname =~ tr~_~_~s;
360
$opt_viewname = calcViewName();
411
    $opt_viewname =~ s~_+$~~;
-
 
412
}
-
 
413
$opt_viewname =~ s~^$view_prefix~~ if (defined($opt_viewname) && $view_prefix && $opt_delete );
361
$opt_viewname =~ s~^$view_prefix~~ if (defined($opt_viewname) && $view_prefix && $opt_delete );
414
 
362
 
415
#
363
#
416
#   Create a clearcase view to be used for the view
364
#   Create a clearcase view to be used for the view
417
#
365
#
Line 1507... Line 1455...
1507
    }
1455
    }
1508
    #debugDumpRefInfo('First Parse');
1456
    #debugDumpRefInfo('First Parse');
1509
}
1457
}
1510
 
1458
 
1511
#-------------------------------------------------------------------------------
1459
#-------------------------------------------------------------------------------
-
 
1460
# Function        : calcViewName
-
 
1461
#
-
 
1462
# Description     : Calculate a nice name for the view
-
 
1463
#                   Try to base the name on the tag
-
 
1464
#
-
 
1465
#                   If the URL looks like a TTB then we can make some guesses
-
 
1466
#                   as to the package name and version.
-
 
1467
#
-
 
1468
#                   Add indication for the Dev Mode
-
 
1469
#                   Add indication for a branch
-
 
1470
 
-
 
1471
#
-
 
1472
# Inputs          : Nothing
-
 
1473
#
-
 
1474
# Returns         : A nice View name
-
 
1475
#                   Will not retirn on error
-
 
1476
#
-
 
1477
sub calcViewName
-
 
1478
{
-
 
1479
    #
-
 
1480
    #   Use the user provided view name if its valid
-
 
1481
    #
-
 
1482
    if ( $opt_viewname )
-
 
1483
    {
-
 
1484
        Error ("View Name contains invalid characters" )
-
 
1485
            unless ( $opt_viewname =~ m~^[0-9a-z]([-.:0-9a-z_]*[0-9a-z])?$~i );
-
 
1486
        return $opt_viewname ;
-
 
1487
    }
-
 
1488
 
-
 
1489
    #
-
 
1490
    #   Create a view name based on the provide URL or SVN Reference
-
 
1491
    #
-
 
1492
    my $version;
-
 
1493
    my $name = $srcPathPkg;
-
 
1494
    $name =~ s~.*/~~;
-
 
1495
 
-
 
1496
    if ( $tagLabel )
-
 
1497
    {
-
 
1498
        $version = $tagLabel;
-
 
1499
        $version =~ s~.*/~~;
-
 
1500
        $version = $1 if ( $version =~ m~^${name}_(.*)~ );
-
 
1501
    }
-
 
1502
    elsif ( $devBranch )
-
 
1503
    {
-
 
1504
        $version = $devBranch;
-
 
1505
        $version =~ s~.*/~~;
-
 
1506
    }
-
 
1507
 
-
 
1508
    if ( $version && $name )
-
 
1509
    {
-
 
1510
        $opt_viewname = join( '_', $name, $version);
-
 
1511
    }
-
 
1512
    elsif ( $svnSession->Type )
-
 
1513
    {
-
 
1514
        $opt_viewname = $svnSession->Path;
-
 
1515
        $opt_viewname .= '_' . ($svnSession->Version || 'trunk') unless $opt_branch;
-
 
1516
 
-
 
1517
        #
-
 
1518
        #   Tags and Branches 'should' include the package name
-
 
1519
        #   This will lead to a duplication of the package name
-
 
1520
        #   ie: aaaaa/package/tags/package_version
-
 
1521
        #   Attempt to remove these
-
 
1522
        #
-
 
1523
        if ( $opt_viewname =~ s~[_/]([\-.:0-9a-zA-Z]+)_\1_~_$1_~ )
-
 
1524
        {
-
 
1525
            Verbose ("Removed duplicate package name: $1 from $opt_viewname");
-
 
1526
        }
-
 
1527
    }
-
 
1528
    else
-
 
1529
    {
-
 
1530
        $opt_viewname = $svnSession->Path;
-
 
1531
        $bad_label_name = 1;
-
 
1532
    }
-
 
1533
 
-
 
1534
    #
-
 
1535
    #   Append the peg if provided
-
 
1536
    #   Not if creating a 'tip' as its a bit meaningless
-
 
1537
    #
-
 
1538
    if ( my $peg = $tagPeg || $devBranchPeg )
-
 
1539
    {
-
 
1540
        unless( $opt_devMode eq 'tip' )
-
 
1541
        {
-
 
1542
            $opt_viewname .= '_' . $peg;
-
 
1543
        }
-
 
1544
    }
-
 
1545
 
-
 
1546
    #
-
 
1547
    #   Append information to indicate the exact type of the WorkSpace
-
 
1548
    #   Normally mutually exclusive
-
 
1549
    #
-
 
1550
    $opt_viewname .= '_Tip' if ( $opt_devMode eq 'tip' );
-
 
1551
    $opt_viewname .= '_Tag' if ( $opt_devMode eq 'tag' );
-
 
1552
    $opt_viewname .= '_Exact' if ( $opt_devMode eq 'exact' );
-
 
1553
    $opt_viewname .= '_' . $opt_branch if ( $opt_branch );
-
 
1554
 
-
 
1555
    #
-
 
1556
    #   Create a simple dir name
-
 
1557
    #       Remove path sep characters and replace with _
-
 
1558
    #       Remove Peg marker (@) as this breaks svn
-
 
1559
    #       Replace multiple _ with a single _
-
 
1560
    #       Remove trailing _ - caused by URL with a trailing /
-
 
1561
    #
-
 
1562
    $opt_viewname =~ s~[^\-.:0-9a-zA-Z_]~_~g;
-
 
1563
    $opt_viewname =~ tr~_~_~s;
-
 
1564
    $opt_viewname =~ s~_+$~~;
-
 
1565
    return $opt_viewname;
-
 
1566
}
-
 
1567
 
-
 
1568
#-------------------------------------------------------------------------------
1512
# Function        : debugDumpRefInfo
1569
# Function        : debugDumpRefInfo
1513
#
1570
#
1514
# Description     : Dump the current Ref Information
1571
# Description     : Dump the current Ref Information
1515
#
1572
#
1516
# Inputs          : $text
1573
# Inputs          : $text