@matheusbsbs / matheus-bagliano / commits / 0a7a9a12d6
Fork 0

cvsserver: Show correct letters for modified, removed and added files

Earlier, cvsserver showed always an 'U', sometimes even without a space between the 'U' and the name. Now, the correct letter is shown, with a space. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Oct 11, 2006 at 00:20 UTC 0a7a9a12d65ca75601f841c93222652f41de09c0
1 file changed +51 -12
git-cvsserver.perl
+51 -12
@@ -805,7 +805,14 @@ sub req_update
805 $meta = $updater->getmeta($filename);
806 }
807
808 - next unless ( $meta->{revision} );
808 + if ( ! defined $meta )
809 + {
810 + $meta = {
811 + name => $filename,
812 + revision => 0,
813 + filehash => 'added'
814 + };
815 + }
816
817 my $oldmeta = $meta;
818
@@ -835,7 +842,7 @@ sub req_update
842 and not exists ( $state->{opt}{C} ) )
843 {
844 $log->info("Tell the client the file is modified");
838 - print "MT text U\n";
845 + print "MT text M \n";
846 print "MT fname $filename\n";
847 print "MT newline\n";
848 next;
@@ -855,15 +862,36 @@ sub req_update
862 }
863 }
864 elsif ( not defined ( $state->{entries}{$filename}{modified_hash} )
858 - or $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} )
865 + or $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash}
866 + or $meta->{filehash} eq 'added' )
867 {
860 - $log->info("Updating '$filename'");
861 - # normal update, just send the new revision (either U=Update, or A=Add, or R=Remove)
862 - print "MT +updated\n";
863 - print "MT text U\n";
864 - print "MT fname $filename\n";
865 - print "MT newline\n";
866 - print "MT -updated\n";
868 + # normal update, just send the new revision (either U=Update,
869 + # or A=Add, or R=Remove)
870 + if ( defined($wrev) && $wrev < 0 )
871 + {
872 + $log->info("Tell the client the file is scheduled for removal");
873 + print "MT text R \n";
874 + print "MT fname $filename\n";
875 + print "MT newline\n";
876 + next;
877 + }
878 + elsif ( !defined($wrev) || $wrev == 0 )
879 + {
880 + $log->info("Tell the client the file will be added");
881 + print "MT text A \n";
882 + print "MT fname $filename\n";
883 + print "MT newline\n";
884 + next;
885 +
886 + }
887 + else {
888 + $log->info("Updating '$filename' $wrev");
889 + print "MT +updated\n";
890 + print "MT text U \n";
891 + print "MT fname $filename\n";
892 + print "MT newline\n";
893 + print "MT -updated\n";
894 + }
895
896 my ( $filepart, $dirpart ) = filenamesplit($filename,1);
897
@@ -1709,6 +1737,17 @@ sub argsfromdir
1737
1738 return if ( scalar ( @{$state->{args}} ) > 1 );
1739
1740 + my @gethead = @{$updater->gethead};
1741 +
1742 + # push added files
1743 + foreach my $file (keys %{$state->{entries}}) {
1744 + if ( exists $state->{entries}{$file}{revision} &&
1745 + $state->{entries}{$file}{revision} == 0 )
1746 + {
1747 + push @gethead, { name => $file, filehash => 'added' };
1748 + }
1749 + }
1750 +
1751 if ( scalar(@{$state->{args}}) == 1 )
1752 {
1753 my $arg = $state->{args}[0];
@@ -1716,7 +1755,7 @@ sub argsfromdir
1755
1756 $log->info("Only one arg specified, checking for directory expansion on '$arg'");
1757
1719 - foreach my $file ( @{$updater->gethead} )
1758 + foreach my $file ( @gethead )
1759 {
1760 next if ( $file->{filehash} eq "deleted" and not defined ( $state->{entries}{$file->{name}} ) );
1761 next unless ( $file->{name} =~ /^$arg\// or $file->{name} eq $arg );
@@ -1729,7 +1768,7 @@ sub argsfromdir
1768
1769 $state->{args} = [];
1770
1732 - foreach my $file ( @{$updater->gethead} )
1771 + foreach my $file ( @gethead )
1772 {
1773 next if ( $file->{filehash} eq "deleted" and not defined ( $state->{entries}{$file->{name}} ) );
1774 next unless ( $file->{name} =~ s/^$state->{prependdir}// );