line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ClearCase::Wrapper::MGi; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '1.00'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1274
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
7
|
1
|
50
|
|
1
|
|
4
|
use constant CYGWIN => $^O =~ /cygwin/i ? 1 : 0; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
71
|
|
8
|
1
|
|
|
1
|
|
4
|
use vars qw($CT $EQHL $PRHL $STHL $FCHL %Xfer $Benchstart); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
90
|
|
9
|
1
|
|
|
1
|
|
31
|
use File::Find; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
130
|
|
10
|
|
|
|
|
|
|
($EQHL, $PRHL, $STHL, $FCHL) = qw(EqInc PrevInc StBr FullCpy); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Note: only wrapper supported functionality--possible fallback to cleartool |
13
|
|
|
|
|
|
|
sub _Wrap { |
14
|
0
|
|
|
0
|
|
|
local @ARGV = @_; |
15
|
0
|
|
|
|
|
|
ClearCase::Wrapper::Extension($ARGV[0]); |
16
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
483
|
|
17
|
0
|
|
|
|
|
|
my $rc = eval { "ClearCase::Wrapper::$ARGV[0]"->(@ARGV) }; |
|
0
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
if ($@) { |
19
|
0
|
|
|
|
|
|
chomp $@; #One extra newline to avoid dumping the stack |
20
|
0
|
0
|
|
|
|
|
if ($@ =~ m%^\d+$%) { |
|
|
0
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$rc = $@; |
22
|
|
|
|
|
|
|
} elsif ($@) { |
23
|
0
|
|
|
|
|
|
print STDERR "$@\n"; |
24
|
0
|
|
|
|
|
|
$rc = 1; |
25
|
|
|
|
|
|
|
} else { |
26
|
0
|
|
|
|
|
|
$rc = 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} else { |
29
|
0
|
0
|
|
|
|
|
$rc = ClearCase::Argv->new(@ARGV)->system unless $rc; # fallback! |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
return $rc; # Completed, successful or not |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
## Internal service routines, undocumented. |
34
|
|
|
|
|
|
|
sub _Compareincs { |
35
|
0
|
|
|
0
|
|
|
my ($t1, $t2) = @_; |
36
|
0
|
|
|
|
|
|
my ($p1, $M1, $m1, $s1) = pfxmajminsfx($t1); |
37
|
0
|
|
|
|
|
|
my ($p2, $M2, $m2, $s2) = pfxmajminsfx($t2); |
38
|
0
|
0
|
0
|
|
|
|
if (!(defined($p1) and defined($p2) and ($p1 eq $p2) and ($s1 eq $s2))) { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
39
|
0
|
|
|
|
|
|
warn Msg('W', "$t1 and $t2 not comparable\n"); |
40
|
0
|
|
|
|
|
|
return 1; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
0
|
|
|
|
return ($M1 <=> $M2 or (defined($m1) and defined($m2) and $m1 <=> $m2)); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
sub _Samebranch { # same branch |
45
|
0
|
|
|
0
|
|
|
my ($cur, $prd) = @_; |
46
|
0
|
|
|
|
|
|
$cur =~ s:/\d+$:/:; # Treat CHECKEDOUT as other branch |
47
|
0
|
|
|
|
|
|
$prd =~ s:/\d+$:/:; |
48
|
0
|
|
|
|
|
|
return $cur eq $prd; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
sub _Sosbranch { # same or sub- branch |
51
|
0
|
|
|
0
|
|
|
my ($cur, $prd) = @_; |
52
|
0
|
|
|
|
|
|
$cur =~ s:/\d+$:/:; |
53
|
0
|
|
|
|
|
|
$prd =~ s:/\d+$:/:; |
54
|
0
|
|
|
|
|
|
return $cur =~ /^\Q$prd\E/; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
sub _Printoffspring { |
57
|
1
|
|
|
1
|
|
5
|
no warnings 'recursion'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
531
|
|
58
|
0
|
|
|
0
|
|
|
my ($id, $gen, $opt, $ind, $seen, $out) = @_; |
59
|
0
|
0
|
|
|
|
|
my $top = $out? 0 : ($out = [], $seen = {}, 1); |
60
|
0
|
0
|
|
|
|
|
if ($seen->{$id}++) { |
61
|
0
|
0
|
0
|
|
|
|
push @{$out}, sprintf("%${ind}s\[alternative: ${id}\]", '') |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
unless $opt->{short} or $opt->{fmt}; |
63
|
0
|
|
|
|
|
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
0
|
|
|
|
|
my @p = @{ $gen->{$id}{parents} || [] }; |
|
0
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
my @c = @{ $gen->{$id}{children} || [] }; |
|
0
|
|
|
|
|
|
|
67
|
0
|
|
0
|
|
|
|
my $l = $gen->{$id}{labels} || ''; |
68
|
0
|
|
|
|
|
|
my ($s, $u) = ([], []); |
69
|
0
|
0
|
|
|
|
|
push @{$seen->{$_}? $s : $u}, $_ for @p; |
|
0
|
|
|
|
|
|
|
70
|
0
|
0
|
0
|
|
|
|
if (@{$u} and !($opt->{short} or $opt->{fmt})) { |
|
0
|
|
0
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $pprinted = 0; |
72
|
0
|
0
|
|
|
|
|
map{$pprinted++ if $gen->{$_}{printed}} @{$s}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
push @{$out}, ' 'x($ind-1) . '[contributor' . (@{$u}>1? 's' : '') . ': ' |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
|
. join(' ', @{$u}) . ']' if $pprinted and $ind; |
|
|
0
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
0
|
|
|
|
my $yes = ($opt->{all} or (@c != 1) or (@{$s} != 1) |
77
|
|
|
|
|
|
|
or !_Samebranch($id, $s->[0]) or !_Sosbranch($c[0], $id)); |
78
|
0
|
0
|
0
|
|
|
|
if ($l or $yes) { |
79
|
0
|
0
|
|
|
|
|
if ($opt->{short}) { |
80
|
0
|
0
|
|
|
|
|
if ($yes) { |
81
|
|
|
|
|
|
|
# the arg (0-indented) is being printed with its parents |
82
|
0
|
0
|
|
|
|
|
push @{$out}, sprintf("%${ind}s${id}", '') if $ind; |
|
0
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$gen->{$id}{printed}++; |
84
|
0
|
|
|
|
|
|
$ind++; # increase only if printed |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} else { |
87
|
0
|
0
|
|
|
|
|
if ($ind) { |
88
|
0
|
0
|
|
|
|
|
my $data = $opt->{fmt}? $l : "$id$l"; |
89
|
0
|
|
|
|
|
|
$data =~ s/\%/\%\%/g; #Escape possible percent signs |
90
|
0
|
|
|
|
|
|
push @{$out}, sprintf("%${ind}s$data", ''); |
|
0
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
$gen->{$id}{printed}++; |
93
|
0
|
|
|
|
|
|
$ind++; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
|
_Printoffspring($_, $gen, $opt, $ind, $seen, $out) for @c; |
97
|
0
|
0
|
|
|
|
|
map{print "$_\n"} reverse @{$out} if $top; # only once |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
sub _Printparents { |
100
|
1
|
|
|
1
|
|
5
|
no warnings 'recursion'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
714
|
|
101
|
0
|
|
|
0
|
|
|
my ($id, $gen, $seen, $opt, $ind) = @_; |
102
|
0
|
0
|
|
|
|
|
if ($seen->{$id}++) { |
103
|
0
|
0
|
0
|
|
|
|
printf("%${ind}s\[alternative: ${id}\]\n", '') |
104
|
|
|
|
|
|
|
unless $opt->{short} or $opt->{fmt}; |
105
|
0
|
|
|
|
|
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
0
|
0
|
|
|
|
|
my @p = @{ $gen->{$id}{parents} || [] }; |
|
0
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
my @c = @{ $gen->{$id}{children} || [] }; |
|
0
|
|
|
|
|
|
|
109
|
0
|
|
0
|
|
|
|
my $l = $gen->{$id}{labels} || ''; |
110
|
0
|
|
|
|
|
|
my (@s, @u) = (); |
111
|
0
|
|
|
|
|
|
foreach my $c (@c) { |
112
|
0
|
0
|
|
|
|
|
if ($seen->{$c}) { |
113
|
0
|
|
|
|
|
|
push @s, $c; |
114
|
|
|
|
|
|
|
} else { |
115
|
0
|
|
|
|
|
|
push @u, $c; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
0
|
0
|
0
|
|
|
|
if (scalar(@u) and !($opt->{short} or $opt->{fmt})) { |
|
|
|
0
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $cprinted = 0; |
120
|
0
|
|
|
|
|
|
for my $c (@s) { |
121
|
0
|
0
|
|
|
|
|
$cprinted++ if $gen->{$c}{printed}; |
122
|
|
|
|
|
|
|
} |
123
|
0
|
0
|
0
|
|
|
|
if (($cprinted or !$ind) and !$opt->{offspring}) { |
|
|
|
0
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
my $plural = @u>1? 's' : ''; |
125
|
0
|
0
|
|
|
|
|
if ($ind == 0) { |
126
|
0
|
|
|
|
|
|
print "\[offspring: "; |
127
|
|
|
|
|
|
|
} else { |
128
|
0
|
|
|
|
|
|
my $pind = $ind - 1; |
129
|
0
|
|
|
|
|
|
print ' 'x$pind, "\[sibling${plural}: "; |
130
|
|
|
|
|
|
|
} |
131
|
0
|
|
|
|
|
|
print join(' ', @u), "\]\n"; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
0
|
|
0
|
|
|
|
my $yes = ($opt->{all} or (scalar(@p) != 1) or (scalar(@s) != 1) |
135
|
|
|
|
|
|
|
or !_Samebranch($id, $s[0]) or !_Sosbranch($id, $p[0])); |
136
|
0
|
0
|
0
|
|
|
|
if ($l or $yes) { |
137
|
0
|
0
|
|
|
|
|
if ($opt->{short}) { |
138
|
0
|
0
|
|
|
|
|
if ($yes) { |
139
|
0
|
|
|
|
|
|
printf("%${ind}s${id}\n", ''); |
140
|
0
|
|
|
|
|
|
$gen->{$id}{printed}++; |
141
|
0
|
|
|
|
|
|
$ind++; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} else { |
144
|
0
|
0
|
|
|
|
|
my $data = $opt->{fmt}? $l : "$id$l"; |
145
|
0
|
|
|
|
|
|
$data =~ s/\%/\%\%/g; #Escape possible percent signs |
146
|
0
|
|
|
|
|
|
printf "%${ind}s$data\n", ''; |
147
|
0
|
|
|
|
|
|
$gen->{$id}{printed}++; |
148
|
0
|
|
|
|
|
|
$ind++; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
0
|
0
|
0
|
|
|
|
return if (defined($opt->{depth})) and ($opt->{depth} < $ind); |
152
|
0
|
|
|
|
|
|
foreach my $p (@p) { |
153
|
0
|
0
|
0
|
|
|
|
if ($gen->{$id}{depth} < $gen->{$p}{depth}) { |
|
|
0
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
_Printparents($p, $gen, $seen, $opt, $ind); |
155
|
|
|
|
|
|
|
} elsif (!($opt->{short} or $opt->{fmt})) { |
156
|
0
|
|
|
|
|
|
printf("%${ind}s\[alternative: ${p}\]\n", ''); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
sub _Findpredinstack { |
161
|
0
|
|
|
0
|
|
|
my ($g, $stack) = @_; |
162
|
0
|
|
|
|
|
|
while ($$stack[-1]) { |
163
|
0
|
0
|
|
|
|
|
return $$stack[-1] if _Sosbranch($g, $$stack[-1]); |
164
|
0
|
|
|
|
|
|
pop @{$stack}; |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
166
|
0
|
|
|
|
|
|
return 0; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
sub _Setdepths { |
169
|
1
|
|
|
1
|
|
5
|
no warnings 'recursion'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
153
|
|
170
|
0
|
|
|
0
|
|
|
my ($id, $dep, $gen) = @_; |
171
|
0
|
0
|
|
|
|
|
if (defined($gen->{$id}{depth})) { |
172
|
0
|
0
|
|
|
|
|
if ($gen->{$id}{depth} > $dep) { |
173
|
0
|
|
|
|
|
|
$gen->{$id}{depth} = $dep; |
174
|
|
|
|
|
|
|
} else { |
175
|
0
|
|
|
|
|
|
return; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} else { |
178
|
0
|
|
|
|
|
|
$gen->{$id}{depth} = $dep; |
179
|
|
|
|
|
|
|
} |
180
|
0
|
0
|
|
|
|
|
my @p = defined($gen->{$id}{parents}) ? @{ $gen->{$id}{parents} } : (); |
|
0
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
foreach my $p (@p) { |
182
|
0
|
|
|
|
|
|
_Setdepths($p, $gen->{$id}{depth} + 1, $gen); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
sub _Checkcs { |
186
|
1
|
|
|
1
|
|
9
|
use File::Basename; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
187
|
1
|
|
|
1
|
|
6
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5143
|
|
188
|
0
|
|
|
0
|
|
|
my ($v) = @_; |
189
|
0
|
|
|
|
|
|
$v =~ s/^(.*?)\@\@.*$/$1/; |
190
|
0
|
|
|
|
|
|
my $dest = dirname($v); |
191
|
0
|
0
|
|
|
|
|
$dest .= '/' unless $dest =~ m%/$%; |
192
|
0
|
|
|
|
|
|
my $pwd = getcwd(); |
193
|
0
|
0
|
|
|
|
|
$CT->cd($dest)->system if $dest; |
194
|
0
|
|
|
|
|
|
my @cs = grep /^\#\#:BranchOff: *root/, $CT->argv('catcs')->qx; |
195
|
0
|
0
|
|
|
|
|
$CT->cd($pwd)->system if $dest; |
196
|
0
|
|
|
|
|
|
return scalar @cs; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
sub _Pbrtype { |
199
|
0
|
|
|
0
|
|
|
my ($pbrt, $bt) = @_; |
200
|
0
|
0
|
|
|
|
|
if (!defined($pbrt->{$bt})) { |
201
|
0
|
|
|
|
|
|
my $tc = $CT->argv('des', qw(-fmt %[type_constraint]p), |
202
|
|
|
|
|
|
|
"brtype:$bt")->qx; |
203
|
0
|
|
|
|
|
|
$pbrt->{$bt} = ($tc =~ /one version per branch/); |
204
|
|
|
|
|
|
|
} |
205
|
0
|
|
|
|
|
|
return $pbrt->{$bt}; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
sub _Parsevtree { |
208
|
0
|
|
|
0
|
|
|
my ($ele, $obs, $sel) = @_; |
209
|
0
|
|
|
|
|
|
$CT->lsvtree; |
210
|
0
|
|
|
|
|
|
my @opt = qw(-merge -all); |
211
|
0
|
0
|
|
|
|
|
push @opt, '-obs' if $obs; |
212
|
0
|
|
|
|
|
|
$CT->opts(@opt); |
213
|
0
|
|
|
|
|
|
my @vt = $CT->args($ele)->qx; |
214
|
0
|
|
|
|
|
|
my $v0 = $vt[1]; |
215
|
0
|
|
|
|
|
|
@vt = grep m%(^$sel|[\\/]([1-9]\d*|CHECKEDOUT))( .*)?$%, @vt; |
216
|
0
|
|
|
|
|
|
map { s%\\%/%g } @vt, $v0; |
|
0
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
my (%gen, @root); |
218
|
0
|
0
|
|
|
|
|
$gen{$v0}{labels} = $1 if $v0 =~ s%/0( \(.*)$%/0%; |
219
|
0
|
|
|
|
|
|
my @stack = (); |
220
|
0
|
|
|
|
|
|
foreach my $g (@vt) { |
221
|
0
|
|
|
|
|
|
$g =~ s%^(.*/CHECKEDOUT) view ".*"(.*)$%$1$2%; |
222
|
0
|
0
|
|
|
|
|
if ($g =~ m%^(.*)( \(.*\))$%) { |
223
|
0
|
|
|
|
|
|
$g = $1; |
224
|
0
|
|
|
|
|
|
$gen{$g}{labels} = $2; |
225
|
|
|
|
|
|
|
} |
226
|
0
|
0
|
|
|
|
|
if ($g =~ /^ -> (.*)$/) { |
227
|
0
|
|
|
|
|
|
my $v = $1; |
228
|
0
|
|
|
|
|
|
my $n = "$ele\@\@$v"; |
229
|
0
|
|
|
|
|
|
push @{ $gen{$stack[-1]}{children} }, $n; |
|
0
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
push @{ $gen{$n}{parents} }, $stack[-1]; |
|
0
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
next; |
232
|
|
|
|
|
|
|
} |
233
|
0
|
0
|
0
|
|
|
|
if (_Findpredinstack($g, \@stack)) { |
|
|
0
|
|
|
|
|
|
234
|
0
|
|
|
|
|
|
push @{ $gen{$g}{parents} }, $stack[-1]; |
|
0
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
push @{ $gen{$stack[-1]}{children} }, $g; |
|
0
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
} elsif ($g ne $v0 and !$gen{$g}{parents}) { |
237
|
0
|
|
|
|
|
|
push @root, $g; #come back later |
238
|
|
|
|
|
|
|
} |
239
|
0
|
|
|
|
|
|
push @stack, $g; |
240
|
|
|
|
|
|
|
} |
241
|
0
|
|
|
|
|
|
for (@root) { |
242
|
0
|
0
|
|
|
|
|
next if $gen{$_}{parents}; |
243
|
0
|
|
|
|
|
|
push @{ $gen{$_}{parents} }, $v0; |
|
0
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
|
push @{ $gen{$v0}{children} }, $_; |
|
0
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
} |
246
|
0
|
|
|
|
|
|
return \%gen; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
sub _Parents { |
249
|
0
|
|
|
0
|
|
|
my ($ver, $ele) = @_; |
250
|
|
|
|
|
|
|
# v0 is $ele@@/main/0, whatever the actual name of 'main' for $ele |
251
|
|
|
|
|
|
|
# Only mention v0 as last recourse, if there is nothing else |
252
|
0
|
|
|
|
|
|
my $pred = $CT->des([qw(-fmt %En@@%PVn)], $ver)->qx; |
253
|
0
|
0
|
|
|
|
|
return if $pred eq "$ele@@"; # Only v0 has no parent |
254
|
0
|
|
|
|
|
|
my @ret = grep s/^<- .*?(@.*)/$ele$1/, |
255
|
|
|
|
|
|
|
$CT->des([qw(-s -ahl Merge)], $ver)->qx; |
256
|
0
|
|
|
|
|
|
$pred = $CT->des([qw(-fmt %En@@%PVn)], $pred)->qx |
257
|
|
|
|
|
|
|
while $pred =~ m%\@[^@]*[/\\][^@]+[/\\][^@]+[/\\]0$%; |
258
|
0
|
|
|
|
|
|
s%\\%/%g for grep $_, $pred, @ret; # Windows... |
259
|
0
|
0
|
0
|
|
|
|
push @ret, $pred unless $pred =~ m%/0$% and @ret; |
260
|
|
|
|
|
|
|
return @ret |
261
|
0
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
sub _Offspring { |
263
|
0
|
|
|
0
|
|
|
my ($ele, $sel, $gen) = @_; |
264
|
0
|
|
|
|
|
|
my @offsp = grep s/^-> .*?(@.*)/$ele$1/, |
265
|
|
|
|
|
|
|
$CT->des([qw(-s -ahl Merge)], $sel)->qx; |
266
|
0
|
|
|
|
|
|
my ($br, $nr) = ($sel =~ m%^(.*)/(\d+)$%); # $sel is normalized |
267
|
0
|
0
|
0
|
|
|
|
if ($br and opendir BR, $br) { # Skip for CHECKEDOUT |
268
|
0
|
|
|
|
|
|
my @f = grep !/^\.\.?/, readdir BR; |
269
|
0
|
|
|
|
|
|
closedir BR; |
270
|
0
|
0
|
|
|
|
|
my @n = sort {$a <=> $b} grep { /^\d+$/ and $_ > $nr } @f; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
271
|
0
|
0
|
|
|
|
|
push @offsp, join('/', $br, $n[0]) if @n; |
272
|
0
|
|
|
|
|
|
my $sil = new ClearCase::Argv({autochomp=>1, stderr=>0}); |
273
|
0
|
0
|
|
|
|
|
push @offsp, grep {$sil->des([qw(-fmt %Pn)], $_)->qx eq $sel} |
|
0
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
join('/', $br, $_, '0') |
275
|
0
|
|
|
|
|
|
for grep { /^\D/ and $sil->des(['-s'], "brtype:$_")->qx } @f; |
276
|
0
|
0
|
|
|
|
|
push @offsp, join('/', $br, 'CHECKEDOUT') |
277
|
|
|
|
|
|
|
if $sil->lsco([qw(-fmt %En@@%PVn)], $ele)->qx eq $sel; |
278
|
0
|
|
|
|
|
|
my %chld = map{$_ => 1} @{ $gen->{$sel}{children} }; # no duplicates |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
push @{ $gen->{$sel}{children} }, grep{!$chld{$_}} @offsp; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
sub _DesFmt { |
283
|
0
|
|
|
0
|
|
|
my ($fmt, $arg) = @_; |
284
|
0
|
|
|
|
|
|
my $ph = 'PlAcEhOlDeR'; |
285
|
0
|
0
|
|
|
|
|
if ($fmt =~ s/\%\[(.*?)\](N?)l/$ph/) { |
286
|
0
|
|
|
|
|
|
my ($re, $ncom) = (qr($1), $2); |
287
|
0
|
0
|
|
|
|
|
$CT = new ClearCase::Argv({autochomp=>1}) unless $CT; |
288
|
0
|
|
|
|
|
|
my @lb = grep /$re/, split / /, $CT->des([qw(-fmt %Nl)], $arg)->qx; |
289
|
0
|
0
|
|
|
|
|
my $lb = $ncom? join(' ', @lb) : @lb? '(' . join(', ', @lb) . ')' : ''; |
|
|
0
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
$fmt =~ s/$ph/$lb/; |
291
|
|
|
|
|
|
|
} |
292
|
0
|
|
|
|
|
|
return $CT->des(['-fmt', $fmt], $arg)->qx; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
sub _DepthGen { |
295
|
0
|
|
|
0
|
|
|
my ($ele, $dep, $sel, $verbose, $fmt, $gen) = @_; |
296
|
0
|
0
|
|
|
|
|
$gen = {} unless $gen; |
297
|
0
|
0
|
|
|
|
|
_Offspring($ele, $sel, $gen) if $verbose; |
298
|
0
|
0
|
|
|
|
|
if ($dep--) { |
|
|
0
|
|
|
|
|
|
299
|
0
|
0
|
|
|
|
|
return if defined $gen->{$sel}{parents}; |
300
|
0
|
|
|
|
|
|
my @p = _Parents($sel, $ele); |
301
|
0
|
|
|
|
|
|
@{ $gen->{$sel}{parents} } = @p; |
|
0
|
|
|
|
|
|
|
302
|
0
|
0
|
|
|
|
|
$gen->{$sel}{labels} = _DesFmt($fmt, $sel) if $fmt; |
303
|
0
|
|
|
|
|
|
push @{ $gen->{$_}{children} }, $sel for @p; |
|
0
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
|
_DepthGen($ele, $dep, $_, $verbose, $fmt, $gen) for @p; |
305
|
|
|
|
|
|
|
} elsif ($fmt) { |
306
|
0
|
|
|
|
|
|
$gen->{$sel}{labels} = _DesFmt($fmt, $sel); |
307
|
|
|
|
|
|
|
} |
308
|
0
|
|
|
|
|
|
return $gen; |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
sub _RecOff { |
311
|
0
|
|
|
0
|
|
|
my ($ele, $sel, $fmt, $gen, $seen) = @_; |
312
|
0
|
0
|
|
|
|
|
return if $seen->{$sel}++; |
313
|
0
|
|
|
|
|
|
($gen->{$sel}{labels}) = grep /\S/, _DesFmt($fmt, $sel); |
314
|
0
|
|
|
|
|
|
my %par = map{$_ => 1} @{ $gen->{$sel}{parents} }; # no duplicates |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
315
|
0
|
|
|
|
|
|
push @{ $gen->{$sel}{parents} }, grep{!$par{$_}} _Parents($sel, $ele); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
|
_Offspring($ele, $sel, $gen); |
317
|
0
|
|
|
|
|
|
_RecOff($ele, $_, $fmt, $gen, $seen) for @{ $gen->{$sel}{children} }; |
|
0
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
sub _RecGen { |
320
|
0
|
|
|
0
|
|
|
my ($ele, $sel, $opt) = @_; |
321
|
0
|
|
0
|
|
|
|
my $fmt = $opt->{fmt} || ' %l'; |
322
|
0
|
|
|
|
|
|
my $gen = _DepthGen($ele, $opt->{depth}, $sel, !$opt->{short}, $fmt); |
323
|
0
|
0
|
|
|
|
|
if ($opt->{offspring}) { |
324
|
0
|
|
|
|
|
|
my $seen = {}; |
325
|
0
|
|
|
|
|
|
_RecOff($ele, $sel, $fmt, $gen, $seen) |
326
|
|
|
|
|
|
|
} |
327
|
0
|
|
|
|
|
|
return $gen; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
sub _Ensuretypes { |
330
|
0
|
|
|
0
|
|
|
my @typ = ($EQHL, $PRHL); # Default value |
331
|
0
|
0
|
|
|
|
|
@typ = @{shift @_} if ref $_[0] eq 'ARRAY'; |
|
0
|
|
|
|
|
|
|
332
|
0
|
|
|
|
|
|
my @vob = @_; |
333
|
0
|
|
|
|
|
|
my %cmt = ($EQHL => q(Equivalent increment), |
334
|
|
|
|
|
|
|
$PRHL => q(Previous increment in a type chain), |
335
|
|
|
|
|
|
|
$FCHL => q(Full Copy of increment)); |
336
|
0
|
|
|
|
|
|
my $silent = $CT->clone({stdout=>0, stderr=>0}); |
337
|
0
|
|
|
|
|
|
my $die = $CT->clone({autofail=>1}); |
338
|
0
|
|
|
|
|
|
for my $t (@typ) { |
339
|
0
|
|
|
|
|
|
for my $v (@vob) { |
340
|
0
|
|
|
|
|
|
my $t2 = "$t\@$v"; |
341
|
0
|
0
|
|
|
|
|
$die->mkhltype([qw(-shared -c), $cmt{$t}], $t2)->system |
342
|
|
|
|
|
|
|
if $silent->des(['-s'], "hltype:$t2")->system; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
sub _Pfxmajminsfx { |
347
|
0
|
|
|
0
|
|
|
my $t = shift; |
348
|
0
|
0
|
|
|
|
|
if ($t =~ /^([\w.-]+[-_])(\d+)(?:\.(\d+))?(\@.*)?$/) { |
349
|
0
|
|
0
|
|
|
|
my $min = ($3 or ''); |
350
|
0
|
|
0
|
|
|
|
my $sfx = ($4 or ''); |
351
|
0
|
|
|
|
|
|
return ($1, $2, $min, $sfx); |
352
|
|
|
|
|
|
|
} else { |
353
|
0
|
|
|
|
|
|
warn Msg( |
354
|
|
|
|
|
|
|
'W', "$t doesn't match the pattern expected for an incremental type\n"); |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
sub _Nextinc { |
358
|
0
|
|
|
0
|
|
|
my $inc = shift; |
359
|
0
|
|
|
|
|
|
my ($pfx, $maj, $min, $sfx) = _Pfxmajminsfx($inc); |
360
|
0
|
0
|
0
|
|
|
|
return '' unless $pfx and $maj; |
361
|
0
|
0
|
|
|
|
|
my $count = defined($min)? $maj . q(.) . ++$min : ++$maj; |
362
|
0
|
|
|
|
|
|
return $pfx . $count . $sfx; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
sub _Findnext { # on input, the type exists |
365
|
0
|
|
|
0
|
|
|
my $c = shift; |
366
|
0
|
|
|
|
|
|
my @int = grep { s/^<- lbtype:(.*)$/$1/ } |
|
0
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
$CT->argv(qw(des -s -ahl), $PRHL, "lbtype:$c")->qx; |
368
|
0
|
0
|
|
|
|
|
if (@int) { |
369
|
0
|
|
|
|
|
|
my @i = (); |
370
|
0
|
|
|
|
|
|
for (@int) { |
371
|
0
|
|
|
|
|
|
push @i, _Findnext($_); |
372
|
|
|
|
|
|
|
} |
373
|
0
|
|
|
|
|
|
return @i; |
374
|
|
|
|
|
|
|
} else { |
375
|
0
|
|
|
|
|
|
return ($c); |
376
|
|
|
|
|
|
|
} |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
sub _Findfreeinc { # on input, the values may or may not exist |
379
|
0
|
|
|
0
|
|
|
my ($nxt, %n) = shift; |
380
|
0
|
|
|
|
|
|
while (my ($k, $v) = each %{$nxt}) { |
|
0
|
|
|
|
|
|
|
381
|
0
|
|
|
|
|
|
while ($CT->des(['-s'], "lbtype:$v")->stderr(0)->qx) { #exists |
382
|
0
|
|
|
|
|
|
my @cand = sort _Compareincs _Findnext($v); |
383
|
0
|
|
|
|
|
|
$v = _Nextinc($cand[$#cand]); |
384
|
|
|
|
|
|
|
} |
385
|
0
|
|
|
|
|
|
$n{$k} = $v; |
386
|
|
|
|
|
|
|
} |
387
|
0
|
|
|
|
|
|
while (my ($k, $v) = each %n) { $$nxt{$k} = $v } |
|
0
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
sub _Wanted { |
390
|
0
|
|
|
0
|
|
|
my $path = File::Spec->rel2abs($File::Find::name); |
391
|
0
|
0
|
|
|
|
|
$path =~ s%\\%/%g if $^O =~ /MSWin32|Windows_NT/i; |
392
|
0
|
0
|
0
|
|
|
|
if (-f $_ || -l $_) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
393
|
0
|
0
|
|
|
|
|
if (-r _) { |
394
|
|
|
|
|
|
|
# Passed all tests, put it on the list. |
395
|
0
|
|
|
|
|
|
$Xfer{$path} = $path; |
396
|
|
|
|
|
|
|
} else { |
397
|
0
|
|
|
|
|
|
warn Msg('E', "permission denied: $path"); |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
} elsif (-d _) { |
400
|
0
|
0
|
|
|
|
|
if ($_ eq 'lost+found') { |
401
|
0
|
|
|
|
|
|
$File::Find::prune = 1; |
402
|
0
|
|
|
|
|
|
return; |
403
|
|
|
|
|
|
|
} |
404
|
|
|
|
|
|
|
# Keep directories in the list only if they're empty. |
405
|
0
|
0
|
|
|
|
|
opendir(DIR, $_) || warn Msg('E', "$_: $!"); |
406
|
0
|
|
|
|
|
|
my @entries = readdir DIR; |
407
|
0
|
|
|
|
|
|
closedir(DIR); |
408
|
0
|
0
|
|
|
|
|
$Xfer{$path} = $path if @entries == 2; |
409
|
|
|
|
|
|
|
} elsif (! -e _) { |
410
|
0
|
|
|
|
|
|
die Msg('E', "no such file or directory: $path"); |
411
|
|
|
|
|
|
|
} else { |
412
|
0
|
|
|
|
|
|
warn Msg('E', "unsupported file type: $path"); |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
sub _Yesno { |
416
|
0
|
|
|
0
|
|
|
my ($cmd, $fn, $yn, $test, $errmsg) = @_; |
417
|
0
|
|
|
|
|
|
my $ret = 0; |
418
|
0
|
|
|
|
|
|
my @opts = $cmd->opts; |
419
|
0
|
|
|
|
|
|
for my $arg ($cmd->args) { |
420
|
0
|
|
|
|
|
|
$cmd->opts(@opts); #reset |
421
|
0
|
0
|
|
|
|
|
if ($test) { |
422
|
0
|
|
|
|
|
|
my $res = $test->($arg); |
423
|
0
|
0
|
|
|
|
|
if (!$res) { |
|
|
0
|
|
|
|
|
|
424
|
0
|
|
0
|
|
|
|
warn ($res or Msg('E', $errmsg . '"' . $arg . "\".\n")); |
425
|
0
|
|
|
|
|
|
next; |
426
|
|
|
|
|
|
|
} elsif ($res == -1) { # Skip interactive part |
427
|
0
|
|
|
|
|
|
$ret |= $fn->($cmd); |
428
|
0
|
|
|
|
|
|
next; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
} |
431
|
0
|
|
|
|
|
|
printf $yn->{format}, $arg; |
432
|
0
|
|
|
|
|
|
my $ans = ; chomp $ans; $ans = lc($ans); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
433
|
0
|
0
|
|
|
|
|
$ans = $yn->{default} unless $ans; |
434
|
0
|
|
|
|
|
|
while ($ans !~ $yn->{valid}) { |
435
|
0
|
|
|
|
|
|
print $yn->{instruct}; |
436
|
0
|
|
|
|
|
|
$ans = ; chomp $ans; $ans = lc($ans); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
437
|
0
|
0
|
|
|
|
|
$ans = $yn->{default} unless $ans; |
438
|
|
|
|
|
|
|
} |
439
|
0
|
0
|
|
|
|
|
if ($yn->{opt}->{$ans}) { |
440
|
0
|
|
|
|
|
|
$cmd->opts(@opts, $yn->{opt}->{$ans}); |
441
|
0
|
|
|
|
|
|
$cmd->args($arg); |
442
|
0
|
|
|
|
|
|
$ret |= $fn->($cmd); |
443
|
|
|
|
|
|
|
} else { |
444
|
0
|
|
|
|
|
|
$ret = 1; |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
} |
447
|
0
|
|
|
|
|
|
exit $ret; |
448
|
|
|
|
|
|
|
} |
449
|
1
|
|
|
1
|
|
1156
|
use AutoLoader 'AUTOLOAD'; |
|
1
|
|
|
|
|
2854
|
|
|
1
|
|
|
|
|
7
|
|
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
############################################################################# |
452
|
|
|
|
|
|
|
# Usage Message Extensions |
453
|
|
|
|
|
|
|
############################################################################# |
454
|
|
|
|
|
|
|
{ |
455
|
|
|
|
|
|
|
local $^W = 0; |
456
|
1
|
|
|
1
|
|
60
|
no strict 'vars'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
487
|
|
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
my $z = $ARGV[0] || ''; |
459
|
|
|
|
|
|
|
$checkin = "\n* [-dir|-rec|-all|-avobs] [-ok] [-diff [diff-opts]] [-revert]"; |
460
|
|
|
|
|
|
|
$lsgenealogy = "$z [-short] [-all] [-fmt format] [-obsolete] [-depth d]" |
461
|
|
|
|
|
|
|
. "\n[-offspring] pname ..."; |
462
|
|
|
|
|
|
|
$mkbrtype = "\n* [-archive]"; |
463
|
|
|
|
|
|
|
$mklabel = "\n* [-up] [-force] [-over type [-all]]"; |
464
|
|
|
|
|
|
|
$mklbtype = "\n* [-family] [-increment] [-archive] [-fullcopy type] \n" |
465
|
|
|
|
|
|
|
. "[-config cr [-exclude vobs]]"; |
466
|
|
|
|
|
|
|
$rmtype = "\n* [-family] [-increment]"; |
467
|
|
|
|
|
|
|
$setcs = "\n* [-clone view-tag] [-expand] [-sync|-needed]"; |
468
|
|
|
|
|
|
|
$mkview = "\n* [-clone view-tag [-equiv lbtype,timestamp]]"; |
469
|
|
|
|
|
|
|
$describe = "\n* [-par/ents ] [-fam/ily ]"; |
470
|
|
|
|
|
|
|
$rollout = "$z [-force] [-c comment] -to baseline brtype|lbtype"; |
471
|
|
|
|
|
|
|
$rollback = "$z [-force] [-c comment] -to increment"; |
472
|
|
|
|
|
|
|
$archive = "$z [-c comment|-nc] brtype|lbtype ..."; |
473
|
|
|
|
|
|
|
$annotate = "\n* [-line|-grep regexp]"; |
474
|
|
|
|
|
|
|
$synctree = "$z -from sbase [-c comment] [-quiet] [-force] [-rollback]" |
475
|
|
|
|
|
|
|
. "\n[-summary] [-label type] [pname ...]"; |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
############################################################################# |
479
|
|
|
|
|
|
|
# Command Aliases |
480
|
|
|
|
|
|
|
############################################################################# |
481
|
|
|
|
|
|
|
*co = *checkout; |
482
|
|
|
|
|
|
|
*ci = *checkin; |
483
|
|
|
|
|
|
|
*des = *describe; |
484
|
|
|
|
|
|
|
*desc = *describe; |
485
|
|
|
|
|
|
|
*lsg = *lsgenealogy; |
486
|
|
|
|
|
|
|
*lsge = *lsgenealogy; |
487
|
|
|
|
|
|
|
*lsgen = *lsgenealogy; |
488
|
|
|
|
|
|
|
*unco = *uncheckout; |
489
|
|
|
|
|
|
|
*ro = *rollout; |
490
|
|
|
|
|
|
|
*rb = *rollback; |
491
|
|
|
|
|
|
|
*ar = *archive; |
492
|
|
|
|
|
|
|
*arc = *archive; |
493
|
|
|
|
|
|
|
*arch = *archive; |
494
|
|
|
|
|
|
|
*an = *annotate; |
495
|
|
|
|
|
|
|
*ann = *annotate; |
496
|
|
|
|
|
|
|
*anno = *annotate; |
497
|
|
|
|
|
|
|
*st = *synctree; |
498
|
|
|
|
|
|
|
*sy = *synctree; |
499
|
|
|
|
|
|
|
*syn = *synctree; |
500
|
|
|
|
|
|
|
*sync = *synctree; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
1; |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
__END__ |