|
225 | 225 | foreach my $name (keys %todo) {
|
226 | 226 | my $basename = basename($name);
|
227 | 227 |
|
228 |
| - $basename = "no file " . $basename if (exists($added{$basename})); |
| 228 | + # CVS reports files that don't exist in the current revision as |
| 229 | + # "no file $basename" in its "status" output, so we should |
| 230 | + # anticipate that. Totally unknown files will have a status |
| 231 | + # "Unknown". However, if they exist in the Attic, their status |
| 232 | + # will be "Up-to-date" (this means they were added once but have |
| 233 | + # been removed). |
| 234 | + $basename = "no file $basename" if $added{$basename}; |
| 235 | + |
229 | 236 | $basename =~ s/^\s+//;
|
230 | 237 | $basename =~ s/\s+$//;
|
231 | 238 |
|
232 | 239 | if (!exists($fullname{$basename})) {
|
233 | 240 | $fullname{$basename} = $name;
|
234 | 241 | push (@canstatusfiles2, $name);
|
235 | 242 | delete($todo{$name});
|
236 |
| - } |
| 243 | + } |
237 | 244 | }
|
238 | 245 | my @cvsoutput;
|
239 | 246 | @cvsoutput = xargs_safe_pipe_capture([@cvs, 'status'], @canstatusfiles2);
|
240 | 247 | foreach my $l (@cvsoutput) {
|
241 |
| - chomp $l; |
242 |
| - if ($l =~ /^File:\s+(.*\S)\s+Status: (.*)$/) { |
243 |
| - if (!exists($fullname{$1})) { |
244 |
| - print STDERR "Huh? Status reported for unexpected file '$1'\n"; |
245 |
| - } else { |
246 |
| - $cvsstat{$fullname{$1}} = $2; |
247 |
| - } |
248 |
| - } |
| 248 | + chomp $l; |
| 249 | + next unless |
| 250 | + my ($file, $status) = $l =~ /^File:\s+(.*\S)\s+Status: (.*)$/; |
| 251 | + |
| 252 | + my $fullname = $fullname{$file}; |
| 253 | + print STDERR "Huh? Status '$status' reported for unexpected file '$file'\n" |
| 254 | + unless defined $fullname; |
| 255 | + |
| 256 | + # This response means the file does not exist except in |
| 257 | + # CVS's attic, so set the status accordingly |
| 258 | + $status = "In-attic" |
| 259 | + if $file =~ /^no file / |
| 260 | + && $status eq 'Up-to-date'; |
| 261 | + |
| 262 | + $cvsstat{$fullname{$file}} = $status; |
249 | 263 | }
|
250 | 264 | }
|
251 | 265 | }
|
252 | 266 |
|
253 |
| -# ... validate new files, |
| 267 | +# ... Validate that new files have the correct status |
254 | 268 | foreach my $f (@afiles) {
|
255 |
| - if (defined ($cvsstat{$f}) and $cvsstat{$f} ne "Unknown") { |
256 |
| - $dirty = 1; |
| 269 | + next unless defined(my $stat = $cvsstat{$f}); |
| 270 | + |
| 271 | + # This means the file has never been seen before |
| 272 | + next if $stat eq 'Unknown'; |
| 273 | + |
| 274 | + # This means the file has been seen before but was removed |
| 275 | + next if $stat eq 'In-attic'; |
| 276 | + |
| 277 | + $dirty = 1; |
257 | 278 | warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n";
|
258 | 279 | warn "Status was: $cvsstat{$f}\n";
|
259 |
| - } |
260 | 280 | }
|
| 281 | + |
261 | 282 | # ... validate known files.
|
262 | 283 | foreach my $f (@files) {
|
263 | 284 | next if grep { $_ eq $f } @afiles;
|
|
0 commit comments