| 1 | package ClearCase::Wrapper; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | $VERSION = '1.19'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | require 5.006; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use AutoLoader 'AUTOLOAD'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use B; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use vars qw(%Packages %ExtMap $libdir $prog $dieexit $dieexec $diemexec); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Inherit some symbols from the main package. We will later "donate" | ||||||||||||||||||||||||||||
| 15 | # these to all overlay packages as well. | ||||||||||||||||||||||||||||
| 16 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | *prog = \$::prog; | |||||||||||||||||||||||||||
| 18 | 1 | *dieexit = \$::dieexit; | |||||||||||||||||||||||||||
| 19 | 1 | *dieexec = \$::dieexec; | |||||||||||||||||||||||||||
| 20 | 1 | *diemexec = \$::diemexec; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # For some reason this can't be handled the same as $prog above ... | ||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use constant MSWIN => $^O =~ /MSWin|Windows_NT/i ? 1 : 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # This is the list of functions we want to export to overlay pkgs. | ||||||||||||||||||||||||||||
| 27 | 1 | my @exports = qw(MSWIN GetOptions Assert Burrow Msg Pred ViewTag | |||||||||||||||||||||||||||
| 28 | AutoCheckedOut AutoNotCheckedOut AutoViewPrivate); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # Hacks for portability with Windows env vars. | ||||||||||||||||||||||||||||
| 31 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | $ENV{LOGNAME} ||= $ENV{USERNAME}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{"LOGNAME"} ||= $ENV{"USERNAME"}
MC/DC0%0/2
$ENV{"LOGNAME"} ||= $ENV{"USERNAME"}
$ENV{"LOGNAME"}
$ENV{"USERNAME"}
Truth table33%1/3
A ||= B
A= $ENV{"LOGNAME"}B= $ENV{"USERNAME"}
| |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | $ENV{HOME} ||= "$ENV{HOMEDRIVE}/$ENV{HOMEPATH}"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"HOME"} ||= qq[$ENV{"HOMEDRIVE"}/$ENV{"HOMEPATH"}]
MC/DC0%0/1
$ENV{"HOME"} ||= qq[$ENV{"HOMEDRIVE"}/$ENV{"HOMEPATH"}]
$ENV{"HOME"}
Truth table50%1/2
A
A= $ENV{"HOME"}
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # Unless the user has their own CLEARCASE_PROFILE, set it to the global one. | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=19.4
| |||||||||||||||||||||||||||||
| 38 | # Learn where this module was found so we can look there for other files. | ||||||||||||||||||||||||||||
| 39 | 1 | ($libdir = $INC{'ClearCase/Wrapper.pm'}) =~ s%\.pm$%%; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | if (defined $ENV{CLEARCASE_PROFILE}) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 42 | 0 | $ENV{_CLEARCASE_WRAPPER_PROFILE} = $ENV{CLEARCASE_PROFILE}; | |||||||||||||||||||||||||||
| 43 | } elsif ($ENV{_CLEARCASE_WRAPPER_PROFILE}) { | ||||||||||||||||||||||||||||
| 44 | 0 | $ENV{CLEARCASE_PROFILE} = $ENV{_CLEARCASE_WRAPPER_PROFILE}; | |||||||||||||||||||||||||||
| 45 | } elsif (! -f "$ENV{HOME}/.clearcase_profile") { | ||||||||||||||||||||||||||||
| 46 | 1 | my $rc = join('/', $libdir, 'clearcase_profile'); | |||||||||||||||||||||||||||
| 47 | 1 | ▶ | $ENV{CLEARCASE_PROFILE} = $rc if -r $rc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # Skip the Getopt::Long->import(), we need our own GetOptions(). | ||||||||||||||||||||||||||||
| 52 | 1 | require Getopt::Long; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # Getopt::Long::GetOptions() respects '--' but strips it, while | ||||||||||||||||||||||||||||
| 55 | # we want to respect '--' and leave it in. Thus this override. | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub GetOptions { | ||||||||||||||||||||||||||
|
Subroutine
GetOptions: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | @ARGV = map {/^--$/ ? qw(=--= --) : $_} @ARGV; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | my $ret = Getopt::Long::GetOptions(@_); | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | @ARGV = map {/^=--=$/ ? qw(--) : $_} @ARGV; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | return $ret; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # Technically we should use Getopt::Long::Configure() for these but | ||||||||||||||||||||||||||||
| 64 | # there's a tangled version history and this is faster anyway. | ||||||||||||||||||||||||||||
| 65 | 1 | $Getopt::Long::passthrough = 1; # required for wrapper programs | |||||||||||||||||||||||||||
| 66 | 1 | $Getopt::Long::ignorecase = 0; # global override for dumb default | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # Any subroutine declared in a module located via this code | ||||||||||||||||||||||||||||
| 69 | # will eclipse one of the same name declared above. | ||||||||||||||||||||||||||||
| 70 | ## NOTE: functions defined in modules found here should not | ||||||||||||||||||||||||||||
| 71 | ## be placed directly into ClearCase::Wrapper. They MUST be | ||||||||||||||||||||||||||||
| 72 | ## placed in the standard package analogous to their pathname | ||||||||||||||||||||||||||||
| 73 | ## (e.g. ClearCase::Wrapper::Foo). Magic occurs here to get | ||||||||||||||||||||||||||||
| 74 | ## them into ClearCase::Wrapper where they belong. | ||||||||||||||||||||||||||||
| 75 | 16 | ▶ | sub _FindAndLoadModules { | ||||||||||||||||||||||||||
|
Subroutine
_FindAndLoadModules: called CC=13 SCAR=46.5
| |||||||||||||||||||||||||||||
| 76 | 16 | my ($dir, $subdir) = @_; | |||||||||||||||||||||||||||
| 77 | # Not sure how glob() sorts so force a standard order. | ||||||||||||||||||||||||||||
| 78 | 1 | ▶ | my @pms = sort glob("$dir/$subdir/*.pm"); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | 16 | for my $pm (@pms) { | |||||||||||||||||||||||||||
| 80 | 0 | my $dirQuoted = quotemeta($dir); | |||||||||||||||||||||||||||
| 81 | 0 | $pm =~ s%^$dirQuoted/(.*)\.pm$%$1%; | |||||||||||||||||||||||||||
| 82 | 0 | (my $pkg = $pm) =~ s%[/\\]+%::%g; | |||||||||||||||||||||||||||
| 83 | 0 | eval "*${pkg}::exit = \$dieexit"; | |||||||||||||||||||||||||||
| 84 | 0 | eval "*${pkg}::exec = \$dieexec"; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # In this block we temporarily enter the overlay's package | ||||||||||||||||||||||||||||
| 87 | # just in case the overlay module forgot its package stmt. | ||||||||||||||||||||||||||||
| 88 | # We then require the overlay file and also, if it's | ||||||||||||||||||||||||||||
| 89 | # an autoloaded module (which is recommended), we drag | ||||||||||||||||||||||||||||
| 90 | # in the index file too. This is because we need to | ||||||||||||||||||||||||||||
| 91 | # derive a list of all functions defined in the overlay | ||||||||||||||||||||||||||||
| 92 | # in order to import them to our own namespace. | ||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||
| 94 | 0 | eval qq(package $pkg); # default the pkg correctly | |||||||||||||||||||||||||||
| 95 | 1 | ▶ | no warnings qw(redefine); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 96 | 0 | eval { | |||||||||||||||||||||||||||
| 97 | 0 | eval "require $pkg"; | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | warn $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | next if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | my $ix = "auto/$pm/autosplit.ix"; | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | if (-e "$dir/$ix") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | eval { require $ix }; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | warn $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | # Now the overlay module is read in. We need to examine its | ||||||||||||||||||||||||||||
| 109 | # newly-created symbol table, determine which functions | ||||||||||||||||||||||||||||
| 110 | # it defined, and import them here. The same basic thing is | ||||||||||||||||||||||||||||
| 111 | # done for the base package later. | ||||||||||||||||||||||||||||
| 112 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 113 | 0 | my %names = %{"${pkg}::"}; | |||||||||||||||||||||||||||
| 114 | 0 | for (keys %names) { | |||||||||||||||||||||||||||
| 115 | # Skip symbols that can't be names of valid cleartool ops. | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | next if m%^(?:_?[A-Z]|__|[ab]$)%; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | my $tglob = "${pkg}::$_"; | |||||||||||||||||||||||||||
| 118 | 0 | my $coderef = \&{$tglob}; | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | next unless ref $coderef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | my $cv = B::svref_2object($coderef); | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | next unless $cv->isa('B::CV'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | next if $cv->GV->isa('B::SPECIAL'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | my $p = $cv->GV->STASH->NAME; | |||||||||||||||||||||||||||
| 124 | 0 | ▶ | next unless $p eq $pkg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # Take what survives the above tests and create a hash | ||||||||||||||||||||||||||||
| 127 | # mapping defined functions to the pkg that defines them. | ||||||||||||||||||||||||||||
| 128 | 0 | $ExtMap{$_} = $pkg; | |||||||||||||||||||||||||||
| 129 | # We import the entire typeglob for 'foo' when we | ||||||||||||||||||||||||||||
| 130 | # find an extension func named foo(). This allows usage | ||||||||||||||||||||||||||||
| 131 | # msg extensions (in the form $foo) to come over too. | ||||||||||||||||||||||||||||
| 132 | 0 | eval qq(*$_ = *$tglob); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # The base module defines a few functions which the | ||||||||||||||||||||||||||||
| 136 | # overlay's code might want to use. Make aliases | ||||||||||||||||||||||||||||
| 137 | # for those in the overlay's symbol table. | ||||||||||||||||||||||||||||
| 138 | 0 | for (@exports) { | |||||||||||||||||||||||||||
| 139 | 0 | eval "*${pkg}::$_ = \\&$_"; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 0 | eval "*${pkg}::prog = \\\$prog"; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | $Packages{$pkg} = $INC{"$pm.pm"}; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | 1 | for my $subdir (qw(ClearCase/Wrapper ClearCase/Wrapper/Site)) { | |||||||||||||||||||||||||||
| 147 | 2 | for my $dir (@INC) { | |||||||||||||||||||||||||||
| 148 | 16 | _FindAndLoadModules($dir, $subdir); | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 1 | $Packages{'ClearCase::Wrapper'} = __FILE__; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | # Piggyback on the -ver flag to show our version too. | ||||||||||||||||||||||||||||
| 155 | 1 | ▶ | if (@ARGV && $ARGV[0] =~ /^-ver/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@ARGV and $ARGV[0] =~ /^-ver/i
MC/DC0%0/2
@ARGV and $ARGV[0] =~ /^-ver/i
@ARGV
$ARGV[0] =~ /^-ver/i
Truth table33%1/3
A and B
A= @ARGVB= $ARGV[0] =~ /^-ver/i
| |||||||||||||||||||||||||||||
| 156 | 0 | my $fmt = "*%-32s %s (%s)\n"; | |||||||||||||||||||||||||||
| 157 | 0 | local $| = 1; | |||||||||||||||||||||||||||
| 158 | 0 | for (sort keys %Packages) { | |||||||||||||||||||||||||||
| 159 | 0 | ▶ | my $ver = eval "\$$_\::VERSION" || '????'; | ||||||||||||||||||||||||||
|
Condition0%0/2
eval "\$${_}::VERSION" || '????'
MC/DC0%0/1
eval "\$${_}::VERSION" || '????'
eval "\$${_}::VERSION"
Truth table0%0/2
A
A= eval "\$${_}::VERSION"
| |||||||||||||||||||||||||||||
| 160 | 0 | my $mtime = localtime((stat $Packages{$_})[9]); | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | printf $fmt, $_, $ver, $mtime || '----'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$mtime || '----'
MC/DC0%0/1
$mtime || '----'
$mtime
Truth table0%0/2
A
A= $mtime
| |||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | 0 | ▶ | exit 0 if $ARGV[0] =~ /^-verw/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | # Take a string and an array, return the index of the 1st occurrence | ||||||||||||||||||||||||||||
| 167 | # of the string in the array. | ||||||||||||||||||||||||||||
| 168 | 3 | ▶ | sub _FirstIndex { | ||||||||||||||||||||||||||
|
Subroutine
_FirstIndex: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 169 | 3 | my $flag = shift; | |||||||||||||||||||||||||||
| 170 | 3 | for my $i (0..$#_) { | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | return $i if $flag eq $_[$i]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | 3 | return undef; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # Implements the -me -tag convention (see POD). | ||||||||||||||||||||||||||||
| 177 | 1 | ▶ | if (my $me = _FirstIndex('-me', @ARGV)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($ARGV[0] =~ /^(?:set|start|end)view$|^rdl$|^work/) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 179 | 0 | my $delim = 0; | |||||||||||||||||||||||||||
| 180 | 0 | for (@ARGV) { | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | last if /^--$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | $delim++; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | 0 | for (reverse @ARGV[0..$delim-1]) { | |||||||||||||||||||||||||||
| 185 | 0 | ▶ | if (/^\w+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | $_ = join('_', $ENV{LOGNAME}, $_); | |||||||||||||||||||||||||||
| 187 | 0 | last; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 0 | splice(@ARGV, $me, 1); | |||||||||||||||||||||||||||
| 191 | } elsif (my $tag = _FirstIndex('-tag', @ARGV)) { | ||||||||||||||||||||||||||||
| 192 | 0 | $ARGV[$tag+1] = join('_', $ENV{LOGNAME}, $ARGV[$tag+1]); | |||||||||||||||||||||||||||
| 193 | 0 | splice(@ARGV, $me, 1); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | # Implements the -M flag (see POD). | ||||||||||||||||||||||||||||
| 198 | 1 | ▶ | if (my $mflag = _FirstIndex('-M', @ARGV) || $ENV{CLEARCASE_WRAPPER_PAGER}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_FirstIndex('-M', @ARGV) || $ENV{'CLEARCASE_WRAPPER_PAGER'}
MC/DC0%0/2
_FirstIndex('-M', @ARGV) || $ENV{'CLEARCASE_WRAPPER_PAGER'}
_FirstIndex('-M', @ARGV)
$ENV{'CLEARCASE_WRAPPER_PAGER'}
Truth table33%1/3
A || B
A= _FirstIndex('-M', @ARGV)B= $ENV{'CLEARCASE_WRAPPER_PAGER'}
| |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | splice(@ARGV, $mflag, 1) if $mflag && !$ENV{CLEARCASE_WRAPPER_PAGER}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mflag and not $ENV{"CLEARCASE_WRAPPER_PAGER"}
MC/DC0%0/2
$mflag and not $ENV{"CLEARCASE_WRAPPER_PAGER"}
$mflag
not $ENV{"CLEARCASE_WRAPPER_PAGER"}
Truth table0%0/3
A and not(B)
A= $mflagB= not $ENV{"CLEARCASE_WRAPPER_PAGER"}
| |||||||||||||||||||||||||||||
| 200 | 0 | pipe(READER, WRITER); | |||||||||||||||||||||||||||
| 201 | 0 | my $pid; | |||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($pid = fork) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | 0 | close WRITER; | |||||||||||||||||||||||||||
| 204 | 0 | ▶ | open(STDIN, ">&READER") || die Msg('E', "STDIN: $!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $pager = $ENV{CLEARCASE_WRAPPER_PAGER} || $ENV{PAGER}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'CLEARCASE_WRAPPER_PAGER'} || $ENV{'PAGER'}
MC/DC0%0/2
$ENV{'CLEARCASE_WRAPPER_PAGER'} || $ENV{'PAGER'}
$ENV{'CLEARCASE_WRAPPER_PAGER'}
$ENV{'PAGER'}
Truth table0%0/3
A || B
A= $ENV{'CLEARCASE_WRAPPER_PAGER'}B= $ENV{'PAGER'}
| |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if (!$pager) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 0 | require Config; | |||||||||||||||||||||||||||
| 208 | 0 | ▶ | $pager = $Config::Config{pager} || 'more'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$Config::Config{'pager'} || 'more'
MC/DC0%0/1
$Config::Config{'pager'} || 'more'
$Config::Config{'pager'}
Truth table0%0/2
A
A= $Config::Config{'pager'}
| |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | 0 | ▶ | exec $pager || warn Msg('W', "can't run $pager: $!"); | ||||||||||||||||||||||||||
|
Condition0%0/2
$pager || warn(Msg('W', "can't run ${pager}: $!"))
MC/DC0%0/1
$pager || warn(Msg('W', "can't run ${pager}: $!"))
$pager
Truth table0%0/2
A
A= $pager
| |||||||||||||||||||||||||||||
| 211 | } else { | ||||||||||||||||||||||||||||
| 212 | 0 | ▶ | die Msg('E', "can't fork") if !defined($pid); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 0 | close READER; | |||||||||||||||||||||||||||
| 214 | 0 | ▶ | open(STDOUT, ">&WRITER") || die Msg('E', "STDOUT: $!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | # Implements the -P flag to pause after a GUI operation. | ||||||||||||||||||||||||||||
| 219 | 1 | ▶ | if (my $pflag = _FirstIndex('-P', @ARGV)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 0 | splice(@ARGV, $pflag, 1); | |||||||||||||||||||||||||||
| 221 | 0 | if (MSWIN) { | |||||||||||||||||||||||||||
| 222 | eval "END { system qw(cmd /c pause) }"; | ||||||||||||||||||||||||||||
| 223 | } else { | ||||||||||||||||||||||||||||
| 224 | 0 | my $foo = <STDIN>; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | ############################################################################# | ||||||||||||||||||||||||||||
| 229 | # Usage Message Extensions | ||||||||||||||||||||||||||||
| 230 | ############################################################################# | ||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||
| 232 | 1 | ▶ | no strict 'vars'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | # Extended messages for actual cleartool commands that we extend. | ||||||||||||||||||||||||||||
| 235 | 1 | $checkin = "\n* [-dir|-rec|-all|-avobs] [-ok] [-diff [diff-opts]]" . | |||||||||||||||||||||||||||
| 236 | "\n* [-revert [-mkhlink]]"; | ||||||||||||||||||||||||||||
| 237 | 1 | $checkout = "\n* [-dir|-rec] [-ok]"; | |||||||||||||||||||||||||||
| 238 | 1 | $diff = "\n* [-<n>] [-dir|-rec|-all|-avobs]"; | |||||||||||||||||||||||||||
| 239 | 1 | $diffcr = "\n* [-data]"; | |||||||||||||||||||||||||||
| 240 | 1 | $lsprivate = "\n* [-dir|-rec|-all] [-ecl/ipsed] [-type d|f]" . | |||||||||||||||||||||||||||
| 241 | "\n* [-rel/ative] [-ext] [pname]"; | ||||||||||||||||||||||||||||
| 242 | 1 | $lsview = "\n* [-me]"; | |||||||||||||||||||||||||||
| 243 | 1 | $mkelem = "\n* [-dir|-rec] [-do] [-ok]"; | |||||||||||||||||||||||||||
| 244 | 1 | $uncheckout = " * [-nc]"; | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | # Extended messages for pseudo cleartool commands that we implement here. | ||||||||||||||||||||||||||||
| 247 | 1 | ▶ | my $z = $ARGV[0] || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ARGV[0] || ''
MC/DC0%0/1
$ARGV[0] || ''
$ARGV[0]
Truth table50%1/2
A
A= $ARGV[0]
| |||||||||||||||||||||||||||||
| 248 | 1 | $edit = "$z <co-flags> [-ci] <ci-flags> pname ..."; | |||||||||||||||||||||||||||
| 249 | 1 | $extensions = "$z [-long]"; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | ############################################################################# | ||||||||||||||||||||||||||||
| 253 | # Command Aliases | ||||||||||||||||||||||||||||
| 254 | ############################################################################# | ||||||||||||||||||||||||||||
| 255 | 1 | *ci = *checkin; | |||||||||||||||||||||||||||
| 256 | 1 | *co = *checkout; | |||||||||||||||||||||||||||
| 257 | 1 | *lsp = *lsprivate; | |||||||||||||||||||||||||||
| 258 | 1 | *lspriv = *lsprivate; | |||||||||||||||||||||||||||
| 259 | 1 | *unco = *uncheckout; | |||||||||||||||||||||||||||
| 260 | 1 | *vi = *edit; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | ############################################################################# | ||||||||||||||||||||||||||||
| 263 | # Allow per-user configurability. Give the individual access to @ARGV just | ||||||||||||||||||||||||||||
| 264 | # before we hand it off to the local wrapper function and/or cleartool. | ||||||||||||||||||||||||||||
| 265 | # Access to this feature is suppressed if the 'NO_OVERRIDES' file exists. | ||||||||||||||||||||||||||||
| 266 | ############################################################################# | ||||||||||||||||||||||||||||
| 267 | 1 | ▶ | if (-r "$ENV{HOME}/.clearcase_profile.pl" && ! -e "$libdir/NO_OVERRIDES") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-r qq[$ENV{"HOME"}/.clearcase_profile.pl] and not -e "$ClearCase::Wrapper::libdir/NO_OVERRIDES"
MC/DC0%0/2
-r qq[$ENV{"HOME"}/.clearcase_profile.pl] and not -e "$ClearCase::Wrapper::libdir/NO_OVERRIDES"
-r qq[$ENV{"HOME"}/.clearcase_profile.pl]
not -e "$ClearCase::Wrapper::libdir/NO_OVERRIDES"
Truth table33%1/3
A and not(B)
A= -r qq[$ENV{"HOME"}/.clearcase_profile.pl]B= not -e "$ClearCase::Wrapper::libdir/NO_OVERRIDES"
| |||||||||||||||||||||||||||||
| 268 | 0 | require "$ENV{HOME}/.clearcase_profile.pl"; | |||||||||||||||||||||||||||
| 269 | 1 | ▶ | no warnings qw(redefine); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 270 | 0 | *Argv::exec = $diemexec; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | # Add to ExtMap the names of extensions defined in the base package. | ||||||||||||||||||||||||||||
| 274 | 1 | for (keys %ClearCase::Wrapper::) { | |||||||||||||||||||||||||||
| 275 | # Skip functions that can't be names of valid cleartool ops. | ||||||||||||||||||||||||||||
| 276 | 47 | ▶ | next if m%^(?:_?[A-Z]|__)%; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | # Skip typeglobs that don't involve functions. | ||||||||||||||||||||||||||||
| 278 | 24 | my $tglob = "ClearCase::Wrapper::$_"; | |||||||||||||||||||||||||||
| 279 | 24 | ▶ | next unless ref \&{$tglob}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | # Take what survives the above tests and create a hash | ||||||||||||||||||||||||||||
| 281 | # mapping defined functions to the pkg that defines them. | ||||||||||||||||||||||||||||
| 282 | 24 | ▶ | $ExtMap{$_} ||= __PACKAGE__; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ClearCase::Wrapper::ExtMap{$_} ||= __PACKAGE__
MC/DC0%0/1
$ClearCase::Wrapper::ExtMap{$_} ||= __PACKAGE__
$ClearCase::Wrapper::ExtMap{$_}
Truth table50%1/2
A
A= $ClearCase::Wrapper::ExtMap{$_}
| |||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | # Returns undefined if <op> is not being extended and returns the | ||||||||||||||||||||||||||||
| 286 | # package that extends it otherwise. Potentially useful for extension | ||||||||||||||||||||||||||||
| 287 | # writers. | ||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub Extension { | ||||||||||||||||||||||||||
|
Subroutine
Extension: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 289 | 0 | my $op = shift; | |||||||||||||||||||||||||||
| 290 | 0 | return $ExtMap{$op}; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | # Returns the full name of a command, whether native or not; unchanged in error | ||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub Canonic { | ||||||||||||||||||||||||||
|
Subroutine
Canonic: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 295 | 0 | my $op = shift; | |||||||||||||||||||||||||||
| 296 | 0 | my $tglob = $ExtMap{$op} . "::" . $op; | |||||||||||||||||||||||||||
| 297 | 0 | my $coderef = \&{$tglob}; | |||||||||||||||||||||||||||
| 298 | 0 | ▶ | return $op unless ref $coderef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 0 | my $cv = B::svref_2object($coderef); | |||||||||||||||||||||||||||
| 300 | 0 | return $cv->GV->NAME; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | # Returns a boolean indicating whether the named cmd is native to | ||||||||||||||||||||||||||||
| 304 | # CC or not. Note: the first call to this func has a "cost" of one | ||||||||||||||||||||||||||||
| 305 | # "cleartool help" operation; subsequent calls are free. | ||||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||
| 307 | 1 | my %native; | |||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub Native { | ||||||||||||||||||||||||||
|
Subroutine
Native: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 309 | 0 | my $op = shift; | |||||||||||||||||||||||||||
| 310 | 0 | ▶ | return 1 if $op =~ m%^lsp(riv)?%; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if (! $op) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 0 | ($op = (caller(1))[3]) =~ s%.*:%%; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if (! keys %native) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 0 | my @usg = grep /^Usage:/, ClearCase::Argv->help->qx; | |||||||||||||||||||||||||||
| 316 | 0 | for (@usg) { | |||||||||||||||||||||||||||
| 317 | 0 | ▶ | if (/^Usage:\s*(\w+)\s*(\|\s*(\w+))?/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | $native{$1} = 1 if $1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | $native{$3} = 1 if $3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if (exists($native{$op})) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 324 | 0 | return 1; | |||||||||||||||||||||||||||
| 325 | } elsif ($op =~ m%^(?:des|lsh)%) { | ||||||||||||||||||||||||||||
| 326 | 0 | return 1; | |||||||||||||||||||||||||||
| 327 | } else { | ||||||||||||||||||||||||||||
| 328 | 0 | return 0; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | # This is an enhancement like the ones below but is kept "above the | ||||||||||||||||||||||||||||
| 334 | # fold" because wrapping of cleartool man is an integral and generic | ||||||||||||||||||||||||||||
| 335 | # part of the module. It runs "cleartool man <cmd>" as requested, | ||||||||||||||||||||||||||||
| 336 | # followed by "perldoc ClearCase::Wrapper" iff <cmd> is extended below. | ||||||||||||||||||||||||||||
| 337 | 1 | ▶ | sub man { | ||||||||||||||||||||||||||
|
Subroutine
man: not called CC=11 SCAR=48.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 338 | 0 | $_ = Canonic($_) for @ARGV[1..$#ARGV]; | |||||||||||||||||||||||||||
| 339 | 0 | my $page = (grep !/^-/, @ARGV)[1]; | |||||||||||||||||||||||||||
| 340 | 0 | ▶ | return 0 unless $page; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 0 | ▶ | ClearCase::Argv->new(@ARGV)->system if Native($page); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if (exists($ClearCase::Wrapper::{$page})) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 343 | # This EV hack causes perldoc to search for the right keyword | ||||||||||||||||||||||||||||
| 344 | # within the module's perldoc. | ||||||||||||||||||||||||||||
| 345 | 0 | if (!MSWIN) { | |||||||||||||||||||||||||||
| 346 | 0 | require Config; | |||||||||||||||||||||||||||
| 347 | 0 | my $pager = $Config::Config{pager}; | |||||||||||||||||||||||||||
| 348 | 0 | ▶ | $ENV{PERLDOC_PAGER} ||= "$pager +/" . uc($page) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"PERLDOC_PAGER"} ||= "$pager +/" . uc($page)
MC/DC0%0/2
$ENV{"PERLDOC_PAGER"} ||= "$pager +/" . uc($page)
$ENV{"PERLDOC_PAGER"}
"$pager +/" . uc($page)
Truth table0%0/3
A ||= B
A= $ENV{"PERLDOC_PAGER"}B= "$pager +/" . uc($page)
| |||||||||||||||||||||||||||||
| 349 | if $pager =~ /more|less/; | ||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | } elsif ($page ne $::prog) { | ||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if (!Native($page)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 353 | 0 | ClearCase::Argv->new(@ARGV)->exec; | |||||||||||||||||||||||||||
| 354 | } else { | ||||||||||||||||||||||||||||
| 355 | 0 | ▶ | exit($? ? 1 : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||
| 358 | 0 | my $psep = MSWIN ? ';' : ':'; | |||||||||||||||||||||||||||
| 359 | 0 | require File::Basename; | |||||||||||||||||||||||||||
| 360 | 0 | $ENV{PATH} = join($psep, File::Basename::dirname($^X), $ENV{PATH}); | |||||||||||||||||||||||||||
| 361 | 0 | ▶ | my $module = $ExtMap{$page} || __PACKAGE__; | ||||||||||||||||||||||||||
|
Condition0%0/2
$ClearCase::Wrapper::ExtMap{$page} || __PACKAGE__
MC/DC0%0/1
$ClearCase::Wrapper::ExtMap{$page} || __PACKAGE__
$ClearCase::Wrapper::ExtMap{$page}
Truth table0%0/2
A
A= $ClearCase::Wrapper::ExtMap{$page}
| |||||||||||||||||||||||||||||
| 362 | 0 | Argv->perldoc($module)->exec; | |||||||||||||||||||||||||||
| 363 | 0 | exit $?; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 1 | 1; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | __END__ | ||||||||||||||||||||||||||||