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>
Martin Langhoff committed
Mar 4, 2006 at 17:47 UTC
6be32d4791126da12e0eade17362ae8ad3f13971
1 file changed
+56
-17
git-cvsserver.perl
+56
-17
@@ -579,6 +579,11 @@ sub req_co
579
print $state->{CVSROOT} . "/$module/\n";
580
print "Clear-static-directory $checkout_path/\n";
581
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";
587
588
# instruct the client that we're checking out to $checkout_path
589
print "E cvs checkout: Updating $checkout_path\n";
@@ -586,6 +591,43 @@ sub req_co
591
my %seendirs = ();
592
my $lastdir ='';
593
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
+
631
foreach my $git ( @{$updater->gethead} )
632
{
633
# Don't want to check out deleted files
@@ -593,6 +635,17 @@ sub req_co
635
636
( $git->{name}, $git->{dir} ) = filenamesplit($git->{name});
637
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
+
649
# modification time of this file
650
print "Mod-time $git->{modified}\n";
651
@@ -604,24 +657,10 @@ sub req_co
657
print "M U $checkout_path/$git->{name}\n";
658
}
659
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";
662
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";
664
665
# this is an "entries" line
666
print "/$git->{name}/1.$git->{revision}///\n";