cvsserver: Allow to "add" a removed file
CVS allows you to add a removed file (where the removal is not yet committed) which will cause the server to send the latest revision of the file and to delete the "removed" status. Copy this behaviour. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Frank Lichtenheld committed
Apr 12, 2007 at 00:51 UTC
4db0c8dec5c009cbbb61135a321a48278e668a25
1 file changed
+40
git-cvsserver.perl
+40
@@ -360,12 +360,52 @@ sub req_add
360
361
argsplit("add");
362
363
+ my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
364
+ $updater->update();
365
+
366
+ argsfromdir($updater);
367
+
368
my $addcount = 0;
369
370
foreach my $filename ( @{$state->{args}} )
371
{
372
$filename = filecleanup($filename);
373
374
+ my $meta = $updater->getmeta($filename);
375
+ my $wrev = revparse($filename);
376
+
377
+ if ($wrev && $meta && ($wrev < 0))
378
+ {
379
+ # previously removed file, add back
380
+ $log->info("added file $filename was previously removed, send 1.$meta->{revision}");
381
+
382
+ print "MT +updated\n";
383
+ print "MT text U \n";
384
+ print "MT fname $filename\n";
385
+ print "MT newline\n";
386
+ print "MT -updated\n";
387
+
388
+ unless ( $state->{globaloptions}{-n} )
389
+ {
390
+ my ( $filepart, $dirpart ) = filenamesplit($filename,1);
391
+
392
+ print "Created $dirpart\n";
393
+ print $state->{CVSROOT} . "/$state->{module}/$filename\n";
394
+
395
+ # this is an "entries" line
396
+ my $kopts = kopts_from_path($filepart);
397
+ $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
398
+ print "/$filepart/1.$meta->{revision}//$kopts/\n";
399
+ # permissions
400
+ $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
401
+ print "u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\n";
402
+ # transmit file
403
+ transmitfile($meta->{filehash});
404
+ }
405
+
406
+ next;
407
+ }
408
+
409
unless ( defined ( $state->{entries}{$filename}{modified_filename} ) )
410
{
411
print "E cvs add: nothing known about `$filename'\n";