1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 17:16:34 +02:00

cvsserver: split up long lines in req_{status,diff,log}

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Matthew Ogilvie 2012-10-13 23:42:20 -06:00 committed by Junio C Hamano
parent 566c69e715
commit 4d804c0e64

View File

@ -1559,10 +1559,12 @@ sub req_status
#$log->debug("status state : " . Dumper($state)); #$log->debug("status state : " . Dumper($state));
# Grab a handle to the SQLite db and do any necessary updates # Grab a handle to the SQLite db and do any necessary updates
my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log); my $updater;
$updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
$updater->update(); $updater->update();
# if no files were specified, we need to work out what files we should be providing status on ... # if no files were specified, we need to work out what files we should
# be providing status on ...
argsfromdir($updater); argsfromdir($updater);
# foreach file specified on the command line ... # foreach file specified on the command line ...
@ -1570,14 +1572,19 @@ sub req_status
{ {
$filename = filecleanup($filename); $filename = filecleanup($filename);
next if exists($state->{opt}{l}) && index($filename, '/', length($state->{prependdir})) >= 0; if ( exists($state->{opt}{l}) &&
index($filename, '/', length($state->{prependdir})) >= 0 )
{
next;
}
my $meta = $updater->getmeta($filename); my $meta = $updater->getmeta($filename);
my $oldmeta = $meta; my $oldmeta = $meta;
my $wrev = revparse($filename); my $wrev = revparse($filename);
# If the working copy is an old revision, lets get that version too for comparison. # If the working copy is an old revision, lets get that
# version too for comparison.
if ( defined($wrev) and $wrev != $meta->{revision} ) if ( defined($wrev) and $wrev != $meta->{revision} )
{ {
$oldmeta = $updater->getmeta($filename, $wrev); $oldmeta = $updater->getmeta($filename, $wrev);
@ -1585,49 +1592,95 @@ sub req_status
# TODO : All possible statuses aren't yet implemented # TODO : All possible statuses aren't yet implemented
my $status; my $status;
# Files are up to date if the working copy and repo copy have the same revision, and the working copy is unmodified # Files are up to date if the working copy and repo copy have
$status = "Up-to-date" if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev == $meta->{revision} # the same revision, and the working copy is unmodified
and if ( defined ( $wrev ) and defined($meta->{revision}) and
( ( $state->{entries}{$filename}{unchanged} and ( not defined ( $state->{entries}{$filename}{conflict} ) or $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) $wrev == $meta->{revision} and
or ( defined($state->{entries}{$filename}{modified_hash}) and $state->{entries}{$filename}{modified_hash} eq $meta->{filehash} ) ) ( ( $state->{entries}{$filename}{unchanged} and
); ( not defined ( $state->{entries}{$filename}{conflict} ) or
$state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
( defined($state->{entries}{$filename}{modified_hash}) and
$state->{entries}{$filename}{modified_hash} eq
$meta->{filehash} ) ) )
{
$status = "Up-to-date";
}
# Need checkout if the working copy has an older revision than the repo copy, and the working copy is unmodified # Need checkout if the working copy has an older revision than
$status ||= "Needs Checkout" if ( defined ( $wrev ) and defined ( $meta->{revision} ) and $meta->{revision} > $wrev # the repo copy, and the working copy is unmodified
and if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
( $state->{entries}{$filename}{unchanged} $meta->{revision} > $wrev and
or ( defined($state->{entries}{$filename}{modified_hash}) and $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} ) ) ( $state->{entries}{$filename}{unchanged} or
); ( defined($state->{entries}{$filename}{modified_hash}) and
$state->{entries}{$filename}{modified_hash} eq
$oldmeta->{filehash} ) ) )
{
$status ||= "Needs Checkout";
}
# Need checkout if it exists in the repo but doesn't have a working copy # Need checkout if it exists in the repo but doesn't have a working
$status ||= "Needs Checkout" if ( not defined ( $wrev ) and defined ( $meta->{revision} ) ); # copy
if ( not defined ( $wrev ) and defined ( $meta->{revision} ) )
{
$status ||= "Needs Checkout";
}
# Locally modified if working copy and repo copy have the same revision but there are local changes # Locally modified if working copy and repo copy have the
$status ||= "Locally Modified" if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev == $meta->{revision} and $state->{entries}{$filename}{modified_filename} ); # same revision but there are local changes
if ( defined ( $wrev ) and defined($meta->{revision}) and
$wrev == $meta->{revision} and
$state->{entries}{$filename}{modified_filename} )
{
$status ||= "Locally Modified";
}
# Needs Merge if working copy revision is less than repo copy and there are local changes # Needs Merge if working copy revision is less than repo copy
$status ||= "Needs Merge" if ( defined ( $wrev ) and defined ( $meta->{revision} ) and $meta->{revision} > $wrev and $state->{entries}{$filename}{modified_filename} ); # and there are local changes
if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
$meta->{revision} > $wrev and
$state->{entries}{$filename}{modified_filename} )
{
$status ||= "Needs Merge";
}
$status ||= "Locally Added" if ( defined ( $state->{entries}{$filename}{revision} ) and not defined ( $meta->{revision} ) ); if ( defined ( $state->{entries}{$filename}{revision} ) and
$status ||= "Locally Removed" if ( defined ( $wrev ) and defined ( $meta->{revision} ) and -$wrev == $meta->{revision} ); not defined ( $meta->{revision} ) )
$status ||= "Unresolved Conflict" if ( defined ( $state->{entries}{$filename}{conflict} ) and $state->{entries}{$filename}{conflict} =~ /^\+=/ ); {
$status ||= "File had conflicts on merge" if ( 0 ); $status ||= "Locally Added";
}
if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
-$wrev == $meta->{revision} )
{
$status ||= "Locally Removed";
}
if ( defined ( $state->{entries}{$filename}{conflict} ) and
$state->{entries}{$filename}{conflict} =~ /^\+=/ )
{
$status ||= "Unresolved Conflict";
}
if ( 0 )
{
$status ||= "File had conflicts on merge";
}
$status ||= "Unknown"; $status ||= "Unknown";
my ($filepart) = filenamesplit($filename); my ($filepart) = filenamesplit($filename);
print "M ===================================================================\n"; print "M =======" . ( "=" x 60 ) . "\n";
print "M File: $filepart\tStatus: $status\n"; print "M File: $filepart\tStatus: $status\n";
if ( defined($state->{entries}{$filename}{revision}) ) if ( defined($state->{entries}{$filename}{revision}) )
{ {
print "M Working revision:\t" . $state->{entries}{$filename}{revision} . "\n"; print "M Working revision:\t" .
$state->{entries}{$filename}{revision} . "\n";
} else { } else {
print "M Working revision:\tNo entry for $filename\n"; print "M Working revision:\tNo entry for $filename\n";
} }
if ( defined($meta->{revision}) ) if ( defined($meta->{revision}) )
{ {
print "M Repository revision:\t1." . $meta->{revision} . "\t$state->{CVSROOT}/$state->{module}/$filename,v\n"; print "M Repository revision:\t1." .
$meta->{revision} .
"\t$state->{CVSROOT}/$state->{module}/$filename,v\n";
print "M Sticky Tag:\t\t(none)\n"; print "M Sticky Tag:\t\t(none)\n";
print "M Sticky Date:\t\t(none)\n"; print "M Sticky Date:\t\t(none)\n";
print "M Sticky Options:\t\t(none)\n"; print "M Sticky Options:\t\t(none)\n";
@ -1661,13 +1714,17 @@ sub req_diff
$revision1 =~ s/^1\.// if ( defined ( $revision1 ) ); $revision1 =~ s/^1\.// if ( defined ( $revision1 ) );
$revision2 =~ s/^1\.// if ( defined ( $revision2 ) ); $revision2 =~ s/^1\.// if ( defined ( $revision2 ) );
$log->debug("Diffing revisions " . ( defined($revision1) ? $revision1 : "[NULL]" ) . " and " . ( defined($revision2) ? $revision2 : "[NULL]" ) ); $log->debug("Diffing revisions " .
( defined($revision1) ? $revision1 : "[NULL]" ) .
" and " . ( defined($revision2) ? $revision2 : "[NULL]" ) );
# Grab a handle to the SQLite db and do any necessary updates # Grab a handle to the SQLite db and do any necessary updates
my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log); my $updater;
$updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
$updater->update(); $updater->update();
# if no files were specified, we need to work out what files we should be providing status on ... # if no files were specified, we need to work out what files we should
# be providing status on ...
argsfromdir($updater); argsfromdir($updater);
# foreach file specified on the command line ... # foreach file specified on the command line ...
@ -1722,7 +1779,8 @@ sub req_diff
$file2 = $state->{entries}{$filename}{modified_filename}; $file2 = $state->{entries}{$filename}{modified_filename};
} }
# if we have been given -r, and we don't have a $file2 yet, lets get one # if we have been given -r, and we don't have a $file2 yet, lets
# get one
if ( defined ( $revision1 ) and not defined ( $file2 ) ) if ( defined ( $revision1 ) and not defined ( $file2 ) )
{ {
( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 ); ( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
@ -1733,21 +1791,37 @@ sub req_diff
# We need to have retrieved something useful # We need to have retrieved something useful
next unless ( defined ( $meta1 ) ); next unless ( defined ( $meta1 ) );
# Files to date if the working copy and repo copy have the same revision, and the working copy is unmodified # Files to date if the working copy and repo copy have the same
next if ( not defined ( $meta2 ) and $wrev == $meta1->{revision} # revision, and the working copy is unmodified
and if ( not defined ( $meta2 ) and $wrev == $meta1->{revision} and
( ( $state->{entries}{$filename}{unchanged} and ( not defined ( $state->{entries}{$filename}{conflict} ) or $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) ( ( $state->{entries}{$filename}{unchanged} and
or ( defined($state->{entries}{$filename}{modified_hash}) and $state->{entries}{$filename}{modified_hash} eq $meta1->{filehash} ) ) ( not defined ( $state->{entries}{$filename}{conflict} ) or
); $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
( defined($state->{entries}{$filename}{modified_hash}) and
$state->{entries}{$filename}{modified_hash} eq
$meta1->{filehash} ) ) )
{
next;
}
# Apparently we only show diffs for locally modified files # Apparently we only show diffs for locally modified files
next unless ( defined($meta2) or defined ( $state->{entries}{$filename}{modified_filename} ) ); unless ( defined($meta2) or
defined ( $state->{entries}{$filename}{modified_filename} ) )
{
next;
}
print "M Index: $filename\n"; print "M Index: $filename\n";
print "M ===================================================================\n"; print "M =======" . ( "=" x 60 ) . "\n";
print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n"; print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n";
print "M retrieving revision 1.$meta1->{revision}\n" if ( defined ( $meta1 ) ); if ( defined ( $meta1 ) )
print "M retrieving revision 1.$meta2->{revision}\n" if ( defined ( $meta2 ) ); {
print "M retrieving revision 1.$meta1->{revision}\n"
}
if ( defined ( $meta2 ) )
{
print "M retrieving revision 1.$meta2->{revision}\n"
}
print "M diff "; print "M diff ";
foreach my $opt ( keys %{$state->{opt}} ) foreach my $opt ( keys %{$state->{opt}} )
{ {
@ -1759,18 +1833,27 @@ sub req_diff
} }
} else { } else {
print "-$opt "; print "-$opt ";
print "$state->{opt}{$opt} " if ( defined ( $state->{opt}{$opt} ) ); if ( defined ( $state->{opt}{$opt} ) )
{
print "$state->{opt}{$opt} "
}
} }
} }
print "$filename\n"; print "$filename\n";
$log->info("Diffing $filename -r $meta1->{revision} -r " . ( $meta2->{revision} or "workingcopy" )); $log->info("Diffing $filename -r $meta1->{revision} -r " .
( $meta2->{revision} or "workingcopy" ));
( $fh, $filediff ) = tempfile ( DIR => $TEMP_DIR ); ( $fh, $filediff ) = tempfile ( DIR => $TEMP_DIR );
if ( exists $state->{opt}{u} ) if ( exists $state->{opt}{u} )
{ {
system("diff -u -L '$filename revision 1.$meta1->{revision}' -L '$filename " . ( defined($meta2->{revision}) ? "revision 1.$meta2->{revision}" : "working copy" ) . "' $file1 $file2 > $filediff"); system("diff -u -L '$filename revision 1.$meta1->{revision}'" .
" -L '$filename " .
( defined($meta2->{revision}) ?
"revision 1.$meta2->{revision}" :
"working copy" ) .
"' $file1 $file2 > $filediff" );
} else { } else {
system("diff $file1 $file2 > $filediff"); system("diff $file1 $file2 > $filediff");
} }
@ -1795,7 +1878,8 @@ sub req_log
#$log->debug("log state : " . Dumper($state)); #$log->debug("log state : " . Dumper($state));
my ( $minrev, $maxrev ); my ( $minrev, $maxrev );
if ( defined ( $state->{opt}{r} ) and $state->{opt}{r} =~ /([\d.]+)?(::?)([\d.]+)?/ ) if ( defined ( $state->{opt}{r} ) and
$state->{opt}{r} =~ /([\d.]+)?(::?)([\d.]+)?/ )
{ {
my $control = $2; my $control = $2;
$minrev = $1; $minrev = $1;
@ -1806,10 +1890,12 @@ sub req_log
} }
# Grab a handle to the SQLite db and do any necessary updates # Grab a handle to the SQLite db and do any necessary updates
my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log); my $updater;
$updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
$updater->update(); $updater->update();
# if no files were specified, we need to work out what files we should be providing status on ... # if no files were specified, we need to work out what files we
# should be providing status on ...
argsfromdir($updater); argsfromdir($updater);
# foreach file specified on the command line ... # foreach file specified on the command line ...
@ -1825,7 +1911,8 @@ sub req_log
if ( defined ( $minrev ) ) if ( defined ( $minrev ) )
{ {
$log->debug("Removing revisions less than $minrev"); $log->debug("Removing revisions less than $minrev");
while ( scalar(@$revisions) > 0 and $revisions->[-1]{revision} < $minrev ) while ( scalar(@$revisions) > 0 and
$revisions->[-1]{revision} < $minrev )
{ {
pop @$revisions; pop @$revisions;
} }
@ -1833,7 +1920,8 @@ sub req_log
if ( defined ( $maxrev ) ) if ( defined ( $maxrev ) )
{ {
$log->debug("Removing revisions greater than $maxrev"); $log->debug("Removing revisions greater than $maxrev");
while ( scalar(@$revisions) > 0 and $revisions->[0]{revision} > $maxrev ) while ( scalar(@$revisions) > 0 and
$revisions->[0]{revision} > $maxrev )
{ {
shift @$revisions; shift @$revisions;
} }
@ -1850,7 +1938,8 @@ sub req_log
print "M access list:\n"; print "M access list:\n";
print "M symbolic names:\n"; print "M symbolic names:\n";
print "M keyword substitution: kv\n"; print "M keyword substitution: kv\n";
print "M total revisions: $totalrevisions;\tselected revisions: " . scalar(@$revisions) . "\n"; print "M total revisions: $totalrevisions;\tselected revisions: " .
scalar(@$revisions) . "\n";
print "M description:\n"; print "M description:\n";
foreach my $revision ( @$revisions ) foreach my $revision ( @$revisions )
@ -1858,14 +1947,23 @@ sub req_log
print "M ----------------------------\n"; print "M ----------------------------\n";
print "M revision 1.$revision->{revision}\n"; print "M revision 1.$revision->{revision}\n";
# reformat the date for log output # reformat the date for log output
$revision->{modified} = sprintf('%04d/%02d/%02d %s', $3, $DATE_LIST->{$2}, $1, $4 ) if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\S+)/ and defined($DATE_LIST->{$2}) ); if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\S+)/ and
defined($DATE_LIST->{$2}) )
{
$revision->{modified} = sprintf('%04d/%02d/%02d %s',
$3, $DATE_LIST->{$2}, $1, $4 );
}
$revision->{author} = cvs_author($revision->{author}); $revision->{author} = cvs_author($revision->{author});
print "M date: $revision->{modified}; author: $revision->{author}; state: " . ( $revision->{filehash} eq "deleted" ? "dead" : "Exp" ) . "; lines: +2 -3\n"; print "M date: $revision->{modified};" .
my $commitmessage = $updater->commitmessage($revision->{commithash}); " author: $revision->{author}; state: " .
( $revision->{filehash} eq "deleted" ? "dead" : "Exp" ) .
"; lines: +2 -3\n";
my $commitmessage;
$commitmessage = $updater->commitmessage($revision->{commithash});
$commitmessage =~ s/^/M /mg; $commitmessage =~ s/^/M /mg;
print $commitmessage . "\n"; print $commitmessage . "\n";
} }
print "M =============================================================================\n"; print "M =======" . ( "=" x 70 ) . "\n";
} }
print "ok\n"; print "ok\n";