Merge branch 'sp/cvsexport'

* sp/cvsexport:
  Optimized cvsexportcommit: calling 'cvs status' once instead of once per touched file.
This commit is contained in:
Junio C Hamano
2007-05-18 17:28:50 -07:00

View File

@ -160,36 +160,51 @@ foreach my $p (@afiles) {
} }
} }
# ... check dirs,
foreach my $d (@dirs) { foreach my $d (@dirs) {
if (-e $d) { if (-e $d) {
$dirty = 1; $dirty = 1;
warn "$d exists and is not a directory!\n"; warn "$d exists and is not a directory!\n";
} }
} }
foreach my $f (@afiles) {
# This should return only one value # ... query status of all files that we have a directory for and parse output of 'cvs status' to %cvsstat.
if ($f =~ m,(.*)/[^/]*$,) { my @canstatusfiles;
my $p = $1; foreach my $f (@files) {
next if (grep { $_ eq $p } @dirs); my $path = dirname $f;
} next if (grep { $_ eq $path } @dirs);
my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f)); push @canstatusfiles, $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 /) { my %cvsstat;
$dirty = 1; if (@canstatusfiles) {
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"; my @cvsoutput;
warn "Status was: $status[0]\n"; @cvsoutput= safe_pipe_capture(@cvs, 'status', @canstatusfiles);
my $matchcount = 0;
foreach my $l (@cvsoutput) {
chomp $l;
if ( $l =~ /^File:/ and $l =~ /Status: (.*)$/ ) {
$cvsstat{$canstatusfiles[$matchcount]} = $1;
$matchcount++;
}
} }
} }
# ... validate new files,
foreach my $f (@afiles) {
if (defined ($cvsstat{$f}) and $cvsstat{$f} ne "Unknown") {
$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: $cvsstat{$f}\n";
}
}
# ... validate known files.
foreach my $f (@files) { foreach my $f (@files) {
next if grep { $_ eq $f } @afiles; next if grep { $_ eq $f } @afiles;
# TODO:we need to handle removed in cvs # TODO:we need to handle removed in cvs
my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f)); unless (defined ($cvsstat{$f}) and $cvsstat{$f} eq "Up-to-date") {
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
unless ($status[0] =~ m/Status: Up-to-date$/) {
$dirty = 1; $dirty = 1;
warn "File $f not up to date in your CVS checkout!\n"; warn "File $f not up to date but has status '$cvsstat{$f}' in your CVS checkout!\n";
} }
} }
if ($dirty) { if ($dirty) {