X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-cvsserver.perl;h=6f10d4c95199d8d56244437b8e2991467e9b7285;hb=cd1333db4f41c44930884176601a8f7725fdd0fa;hp=d20d1a8c4ba5a4e8d17fd47b1cca000fcf84dda5;hpb=52e8a6e9bf92a38015ab8f6d19dabeff7acc0651;p=git.git diff --git a/git-cvsserver.perl b/git-cvsserver.perl index d20d1a8c..6f10d4c9 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -53,6 +53,7 @@ my $methods = { 'Entry' => \&req_Entry, 'Modified' => \&req_Modified, 'Unchanged' => \&req_Unchanged, + 'Questionable' => \&req_Questionable, 'Argument' => \&req_Argument, 'Argumentx' => \&req_Argument, 'expand-modules' => \&req_expandmodules, @@ -63,6 +64,7 @@ my $methods = { 'ci' => \&req_ci, 'diff' => \&req_diff, 'log' => \&req_log, + 'rlog' => \&req_log, 'tag' => \&req_CATCHALL, 'status' => \&req_status, 'admin' => \&req_CATCHALL, @@ -459,6 +461,22 @@ sub req_Unchanged #$log->debug("req_Unchanged : $data"); } +# Questionable filename \n +# Response expected: no. Additional data: no. +# Tell the server to check whether filename should be ignored, +# and if not, next time the server sends responses, send (in +# a M response) `?' followed by the directory and filename. +# filename must not contain `/'; it needs to be a file in the +# directory named by the most recent Directory request. +sub req_Questionable +{ + my ( $cmd, $data ) = @_; + + $state->{entries}{$state->{directory}.$data}{questionable} = 1; + + #$log->debug("req_Questionable : $data"); +} + # Argument text \n # Response expected: no. Save argument for use in a subsequent command. # Arguments accumulate until an argument-using command is given, at which @@ -553,8 +571,20 @@ sub req_co my $updater = GITCVS::updater->new($state->{CVSROOT}, $module, $log); $updater->update(); + $checkout_path =~ s|/$||; # get rid of trailing slashes + + # Eclipse seems to need the Clear-sticky command + # to prepare the 'Entries' file for the new directory. + print "Clear-sticky $checkout_path/\n"; + print $state->{CVSROOT} . "/$module/\n"; + print "Clear-static-directory $checkout_path/\n"; + print $state->{CVSROOT} . "/$module/\n"; + # instruct the client that we're checking out to $checkout_path - print "E cvs server: updating $checkout_path\n"; + print "E cvs checkout: Updating $checkout_path\n"; + + my %seendirs = (); + my $lastdir =''; foreach my $git ( @{$updater->gethead} ) { @@ -567,21 +597,31 @@ sub req_co print "Mod-time $git->{modified}\n"; # print some information to the client - print "MT +updated\n"; - print "MT text U\n"; if ( defined ( $git->{dir} ) and $git->{dir} ne "./" ) { - print "MT fname $checkout_path/$git->{dir}$git->{name}\n"; + print "M U $checkout_path/$git->{dir}$git->{name}\n"; } else { - print "MT fname $checkout_path/$git->{name}\n"; + print "M U $checkout_path/$git->{name}\n"; } - print "MT newline\n"; - print "MT -updated\n"; + + if (length($git->{dir}) && $git->{dir} ne './' + && $git->{dir} ne $lastdir && !exists($seendirs{$git->{dir}})) { + + # Eclipse seems to need the Clear-sticky command + # to prepare the 'Entries' file for the new directory. + print "Clear-sticky $checkout_path/$git->{dir}\n"; + print $state->{CVSROOT} . "/$module/$git->{dir}\n"; + print "Clear-static-directory $checkout_path/$git->{dir}\n"; + print $state->{CVSROOT} . "/$module/$git->{dir}\n"; + print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n"; + $lastdir = $git->{dir}; + $seendirs{$git->{dir}} = 1; + } # instruct client we're sending a file to put in this path - print "Created $checkout_path/" . ( defined ( $git->{dir} ) ? $git->{dir} . "/" : "" ) . "\n"; + print "Created $checkout_path/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "\n"; - print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) ? $git->{dir} . "/" : "" ) . "$git->{name}\n"; + print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n"; # this is an "entries" line print "/$git->{name}/1.$git->{revision}///\n"; @@ -612,6 +652,26 @@ sub req_update argsplit("update"); + # + # It may just be a client exploring the available heads/modukles + # in that case, list them as top level directories and leave it + # at that. Eclipse uses this technique to offer you a list of + # projects (heads in this case) to checkout. + # + if ($state->{module} eq '') { + print "E cvs update: Updating .\n"; + opendir HEADS, $state->{CVSROOT} . '/refs/heads'; + while (my $head = readdir(HEADS)) { + if (-f $state->{CVSROOT} . '/refs/heads/' . $head) { + print "E cvs update: New directory `$head'\n"; + } + } + closedir HEADS; + print "ok\n"; + return 1; + } + + # Grab a handle to the SQLite db and do any necessary updates my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log); @@ -657,8 +717,27 @@ sub req_update #$log->debug("Target revision is $meta->{revision}, current working revision is $wrev"); - # Files are up to date if the working copy and repo copy have the same revision, and the working copy is unmodified _and_ the user hasn't specified -C - next if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev == $meta->{revision} and $state->{entries}{$filename}{unchanged} and not exists ( $state->{opt}{C} ) ); + # Files are up to date if the working copy and repo copy have the same revision, + # and the working copy is unmodified _and_ the user hasn't specified -C + next if ( defined ( $wrev ) + and defined($meta->{revision}) + and $wrev == $meta->{revision} + and $state->{entries}{$filename}{unchanged} + and not exists ( $state->{opt}{C} ) ); + + # If the working copy and repo copy have the same revision, + # but the working copy is modified, tell the client it's modified + if ( defined ( $wrev ) + and defined($meta->{revision}) + and $wrev == $meta->{revision} + and not exists ( $state->{opt}{C} ) ) + { + $log->info("Tell the client the file is modified"); + print "MT text U\n"; + print "MT fname $filename\n"; + print "MT newline\n"; + next; + } if ( $meta->{filehash} eq "deleted" ) { @@ -670,7 +749,8 @@ sub req_update print "Removed $dirpart\n"; print "$filepart\n"; } - elsif ( not defined ( $state->{entries}{$filename}{modified_hash} ) or $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} ) + elsif ( not defined ( $state->{entries}{$filename}{modified_hash} ) + or $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} ) { $log->info("Updating '$filename'"); # normal update, just send the new revision (either U=Update, or A=Add, or R=Remove) @@ -706,6 +786,7 @@ sub req_update # transmit file transmitfile($meta->{filehash}); } else { + $log->info("Updating '$filename'"); my ( $filepart, $dirpart ) = filenamesplit($meta->{name}); my $dir = tempdir( DIR => $TEMP_DIR, CLEANUP => 1 ) . "/"; @@ -2271,7 +2352,7 @@ sub gethead return $self->{gethead_cache} if ( defined ( $self->{gethead_cache} ) ); - my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, mode, revision, modified, commithash, author FROM head",{},1); + my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, mode, revision, modified, commithash, author FROM head ORDER BY name ASC",{},1); $db_query->execute(); my $tree = [];