-foreach my $f (@afiles, @mfiles, @dfiles) {
- # TODO:we need to handle removed in cvs and/or new (from git)
- my $status = `cvs -q status "$f" | grep '^File: '`;
-
- unless ($status =~ m/Status: Up-to-date$/) {
+foreach my $d (@dirs) {
+ if (-e $d) {
+ $dirty = 1;
+ warn "$d exists and is not a directory!\n";
+ }
+}
+foreach my $f (@afiles) {
+ # This should return only one value
+ my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f));
+ if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
+ if (-d dirname $f and $status[0] !~ m/Status: Unknown$/
+ and $status[0] !~ m/^File: no file /) {
+ $dirty = 1;
+ 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";
+ warn "Status was: $status\n";
+ }
+}
+foreach my $f (@mfiles, @dfiles) {
+ # TODO:we need to handle removed in cvs
+ my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f));
+ if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
+ unless ($status[0] =~ m/Status: Up-to-date$/) {