Skip to content

Commit 6be32d4

Browse files
Martin LanghoffJunio C Hamano
authored andcommitted
cvsserver: nested directory creation fixups for Eclipse clients
To create nested directories without (or before) sending file entries is rather tricky. Most clients just work. Eclipse, however, expects a very specific sequence of events. With this patch, cvsserver meets those expectations. Note: we may want to reuse prepdir() in req_update -- should move it outside of req_co. Right now prepdir() is tied to how req_co() works. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent be97292 commit 6be32d4

File tree

1 file changed

+56
-17
lines changed

1 file changed

+56
-17
lines changed

git-cvsserver.perl

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -579,20 +579,73 @@ sub req_co
579579
print $state->{CVSROOT} . "/$module/\n";
580580
print "Clear-static-directory $checkout_path/\n";
581581
print $state->{CVSROOT} . "/$module/\n";
582+
print "Clear-sticky $checkout_path/\n"; # yes, twice
583+
print $state->{CVSROOT} . "/$module/\n";
584+
print "Template $checkout_path/\n";
585+
print $state->{CVSROOT} . "/$module/\n";
586+
print "0\n";
582587

583588
# instruct the client that we're checking out to $checkout_path
584589
print "E cvs checkout: Updating $checkout_path\n";
585590

586591
my %seendirs = ();
587592
my $lastdir ='';
588593

594+
# recursive
595+
sub prepdir {
596+
my ($dir, $repodir, $remotedir, $seendirs) = @_;
597+
my $parent = dirname($dir);
598+
$dir =~ s|/+$||;
599+
$repodir =~ s|/+$||;
600+
$remotedir =~ s|/+$||;
601+
$parent =~ s|/+$||;
602+
$log->debug("announcedir $dir, $repodir, $remotedir" );
603+
604+
if ($parent eq '.' || $parent eq './') {
605+
$parent = '';
606+
}
607+
# recurse to announce unseen parents first
608+
if (length($parent) && !exists($seendirs->{$parent})) {
609+
prepdir($parent, $repodir, $remotedir, $seendirs);
610+
}
611+
# Announce that we are going to modify at the parent level
612+
if ($parent) {
613+
print "E cvs checkout: Updating $remotedir/$parent\n";
614+
} else {
615+
print "E cvs checkout: Updating $remotedir\n";
616+
}
617+
print "Clear-sticky $remotedir/$parent/\n";
618+
print "$repodir/$parent/\n";
619+
620+
print "Clear-static-directory $remotedir/$dir/\n";
621+
print "$repodir/$dir/\n";
622+
print "Clear-sticky $remotedir/$parent/\n"; # yes, twice
623+
print "$repodir/$parent/\n";
624+
print "Template $remotedir/$dir/\n";
625+
print "$repodir/$dir/\n";
626+
print "0\n";
627+
628+
$seendirs->{$dir} = 1;
629+
}
630+
589631
foreach my $git ( @{$updater->gethead} )
590632
{
591633
# Don't want to check out deleted files
592634
next if ( $git->{filehash} eq "deleted" );
593635

594636
( $git->{name}, $git->{dir} ) = filenamesplit($git->{name});
595637

638+
if (length($git->{dir}) && $git->{dir} ne './'
639+
&& $git->{dir} ne $lastdir ) {
640+
unless (exists($seendirs{$git->{dir}})) {
641+
prepdir($git->{dir}, $state->{CVSROOT} . "/$module/",
642+
$checkout_path, \%seendirs);
643+
$lastdir = $git->{dir};
644+
$seendirs{$git->{dir}} = 1;
645+
}
646+
print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n";
647+
}
648+
596649
# modification time of this file
597650
print "Mod-time $git->{modified}\n";
598651

@@ -604,24 +657,10 @@ sub req_co
604657
print "M U $checkout_path/$git->{name}\n";
605658
}
606659

607-
if (length($git->{dir}) && $git->{dir} ne './'
608-
&& $git->{dir} ne $lastdir && !exists($seendirs{$git->{dir}})) {
609-
610-
# Eclipse seems to need the Clear-sticky command
611-
# to prepare the 'Entries' file for the new directory.
612-
print "Clear-sticky $checkout_path/$git->{dir}\n";
613-
print $state->{CVSROOT} . "/$module/$git->{dir}\n";
614-
print "Clear-static-directory $checkout_path/$git->{dir}\n";
615-
print $state->{CVSROOT} . "/$module/$git->{dir}\n";
616-
print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n";
617-
$lastdir = $git->{dir};
618-
$seendirs{$git->{dir}} = 1;
619-
}
620-
621-
# instruct client we're sending a file to put in this path
622-
print "Created $checkout_path/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "\n";
660+
# instruct client we're sending a file to put in this path
661+
print "Created $checkout_path/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "\n";
623662

624-
print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n";
663+
print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n";
625664

626665
# this is an "entries" line
627666
print "/$git->{name}/1.$git->{revision}///\n";

0 commit comments

Comments
 (0)