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>
Matthew Ogilvie committed
Oct 13, 2012 at 23:42 UTC
4d804c0e64d50e0a9b7b5af7f93b50a5659b1ffc
1 file changed
+159
-61
git-cvsserver.perl
+159
-61
@@ -1559,10 +1559,12 @@ sub req_status
1559
#$log->debug("status state : " . Dumper($state));
1560
1561
# Grab a handle to the SQLite db and do any necessary updates
1562
- my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
1562
+ my $updater;
1563
+ $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
1564
$updater->update();
1565
1565
- # if no files were specified, we need to work out what files we should be providing status on ...
1566
+ # if no files were specified, we need to work out what files we should
1567
+ # be providing status on ...
1568
argsfromdir($updater);
1569
1570
# foreach file specified on the command line ...
@@ -1570,14 +1572,19 @@ sub req_status
1572
{
1573
$filename = filecleanup($filename);
1574
1573
- next if exists($state->{opt}{l}) && index($filename, '/', length($state->{prependdir})) >= 0;
1575
+ if ( exists($state->{opt}{l}) &&
1576
+ index($filename, '/', length($state->{prependdir})) >= 0 )
1577
+ {
1578
+ next;
1579
+ }
1580
1581
my $meta = $updater->getmeta($filename);
1582
my $oldmeta = $meta;
1583
1584
my $wrev = revparse($filename);
1585
1580
- # If the working copy is an old revision, lets get that version too for comparison.
1586
+ # If the working copy is an old revision, lets get that
1587
+ # version too for comparison.
1588
if ( defined($wrev) and $wrev != $meta->{revision} )
1589
{
1590
$oldmeta = $updater->getmeta($filename, $wrev);
@@ -1585,49 +1592,95 @@ sub req_status
1592
1593
# TODO : All possible statuses aren't yet implemented
1594
my $status;
1588
- # Files are up to date if the working copy and repo copy have the same revision, and the working copy is unmodified
1589
- $status = "Up-to-date" if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev == $meta->{revision}
1590
- and
1591
- ( ( $state->{entries}{$filename}{unchanged} and ( not defined ( $state->{entries}{$filename}{conflict} ) or $state->{entries}{$filename}{conflict} !~ /^\+=/ ) )
1592
- or ( defined($state->{entries}{$filename}{modified_hash}) and $state->{entries}{$filename}{modified_hash} eq $meta->{filehash} ) )
1593
- );
1594
-
1595
- # Need checkout if the working copy has an older revision than the repo copy, and the working copy is unmodified
1596
- $status ||= "Needs Checkout" if ( defined ( $wrev ) and defined ( $meta->{revision} ) and $meta->{revision} > $wrev
1597
- and
1598
- ( $state->{entries}{$filename}{unchanged}
1599
- or ( defined($state->{entries}{$filename}{modified_hash}) and $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} ) )
1600
- );
1601
-
1602
- # Need checkout if it exists in the repo but doesn't have a working copy
1603
- $status ||= "Needs Checkout" if ( not defined ( $wrev ) and defined ( $meta->{revision} ) );
1604
-
1605
- # Locally modified if working copy and repo copy have the same revision but there are local changes
1606
- $status ||= "Locally Modified" if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev == $meta->{revision} and $state->{entries}{$filename}{modified_filename} );
1607
-
1608
- # Needs Merge if working copy revision is less than repo copy and there are local changes
1609
- $status ||= "Needs Merge" if ( defined ( $wrev ) and defined ( $meta->{revision} ) and $meta->{revision} > $wrev and $state->{entries}{$filename}{modified_filename} );
1610
-
1611
- $status ||= "Locally Added" if ( defined ( $state->{entries}{$filename}{revision} ) and not defined ( $meta->{revision} ) );
1612
- $status ||= "Locally Removed" if ( defined ( $wrev ) and defined ( $meta->{revision} ) and -$wrev == $meta->{revision} );
1613
- $status ||= "Unresolved Conflict" if ( defined ( $state->{entries}{$filename}{conflict} ) and $state->{entries}{$filename}{conflict} =~ /^\+=/ );
1614
- $status ||= "File had conflicts on merge" if ( 0 );
1595
+ # Files are up to date if the working copy and repo copy have
1596
+ # the same revision, and the working copy is unmodified
1597
+ if ( defined ( $wrev ) and defined($meta->{revision}) and
1598
+ $wrev == $meta->{revision} and
1599
+ ( ( $state->{entries}{$filename}{unchanged} and
1600
+ ( not defined ( $state->{entries}{$filename}{conflict} ) or
1601
+ $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
1602
+ ( defined($state->{entries}{$filename}{modified_hash}) and
1603
+ $state->{entries}{$filename}{modified_hash} eq
1604
+ $meta->{filehash} ) ) )
1605
+ {
1606
+ $status = "Up-to-date";
1607
+ }
1608
+
1609
+ # Need checkout if the working copy has an older revision than
1610
+ # the repo copy, and the working copy is unmodified
1611
+ if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
1612
+ $meta->{revision} > $wrev and
1613
+ ( $state->{entries}{$filename}{unchanged} or
1614
+ ( defined($state->{entries}{$filename}{modified_hash}) and
1615
+ $state->{entries}{$filename}{modified_hash} eq
1616
+ $oldmeta->{filehash} ) ) )
1617
+ {
1618
+ $status ||= "Needs Checkout";
1619
+ }
1620
+
1621
+ # Need checkout if it exists in the repo but doesn't have a working
1622
+ # copy
1623
+ if ( not defined ( $wrev ) and defined ( $meta->{revision} ) )
1624
+ {
1625
+ $status ||= "Needs Checkout";
1626
+ }
1627
+
1628
+ # Locally modified if working copy and repo copy have the
1629
+ # same revision but there are local changes
1630
+ if ( defined ( $wrev ) and defined($meta->{revision}) and
1631
+ $wrev == $meta->{revision} and
1632
+ $state->{entries}{$filename}{modified_filename} )
1633
+ {
1634
+ $status ||= "Locally Modified";
1635
+ }
1636
+
1637
+ # Needs Merge if working copy revision is less than repo copy
1638
+ # and there are local changes
1639
+ if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
1640
+ $meta->{revision} > $wrev and
1641
+ $state->{entries}{$filename}{modified_filename} )
1642
+ {
1643
+ $status ||= "Needs Merge";
1644
+ }
1645
+
1646
+ if ( defined ( $state->{entries}{$filename}{revision} ) and
1647
+ not defined ( $meta->{revision} ) )
1648
+ {
1649
+ $status ||= "Locally Added";
1650
+ }
1651
+ if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
1652
+ -$wrev == $meta->{revision} )
1653
+ {
1654
+ $status ||= "Locally Removed";
1655
+ }
1656
+ if ( defined ( $state->{entries}{$filename}{conflict} ) and
1657
+ $state->{entries}{$filename}{conflict} =~ /^\+=/ )
1658
+ {
1659
+ $status ||= "Unresolved Conflict";
1660
+ }
1661
+ if ( 0 )
1662
+ {
1663
+ $status ||= "File had conflicts on merge";
1664
+ }
1665
1666
$status ||= "Unknown";
1667
1668
my ($filepart) = filenamesplit($filename);
1669
1620
- print "M ===================================================================\n";
1670
+ print "M =======" . ( "=" x 60 ) . "\n";
1671
print "M File: $filepart\tStatus: $status\n";
1672
if ( defined($state->{entries}{$filename}{revision}) )
1673
{
1624
- print "M Working revision:\t" . $state->{entries}{$filename}{revision} . "\n";
1674
+ print "M Working revision:\t" .
1675
+ $state->{entries}{$filename}{revision} . "\n";
1676
} else {
1677
print "M Working revision:\tNo entry for $filename\n";
1678
}
1679
if ( defined($meta->{revision}) )
1680
{
1630
- print "M Repository revision:\t1." . $meta->{revision} . "\t$state->{CVSROOT}/$state->{module}/$filename,v\n";
1681
+ print "M Repository revision:\t1." .
1682
+ $meta->{revision} .
1683
+ "\t$state->{CVSROOT}/$state->{module}/$filename,v\n";
1684
print "M Sticky Tag:\t\t(none)\n";
1685
print "M Sticky Date:\t\t(none)\n";
1686
print "M Sticky Options:\t\t(none)\n";
@@ -1661,13 +1714,17 @@ sub req_diff
1714
$revision1 =~ s/^1\.// if ( defined ( $revision1 ) );
1715
$revision2 =~ s/^1\.// if ( defined ( $revision2 ) );
1716
1664
- $log->debug("Diffing revisions " . ( defined($revision1) ? $revision1 : "[NULL]" ) . " and " . ( defined($revision2) ? $revision2 : "[NULL]" ) );
1717
+ $log->debug("Diffing revisions " .
1718
+ ( defined($revision1) ? $revision1 : "[NULL]" ) .
1719
+ " and " . ( defined($revision2) ? $revision2 : "[NULL]" ) );
1720
1721
# Grab a handle to the SQLite db and do any necessary updates
1667
- my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
1722
+ my $updater;
1723
+ $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
1724
$updater->update();
1725
1670
- # if no files were specified, we need to work out what files we should be providing status on ...
1726
+ # if no files were specified, we need to work out what files we should
1727
+ # be providing status on ...
1728
argsfromdir($updater);
1729
1730
# foreach file specified on the command line ...
@@ -1722,7 +1779,8 @@ sub req_diff
1779
$file2 = $state->{entries}{$filename}{modified_filename};
1780
}
1781
1725
- # if we have been given -r, and we don't have a $file2 yet, lets get one
1782
+ # if we have been given -r, and we don't have a $file2 yet, lets
1783
+ # get one
1784
if ( defined ( $revision1 ) and not defined ( $file2 ) )
1785
{
1786
( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
@@ -1733,21 +1791,37 @@ sub req_diff
1791
# We need to have retrieved something useful
1792
next unless ( defined ( $meta1 ) );
1793
1736
- # Files to date if the working copy and repo copy have the same revision, and the working copy is unmodified
1737
- next if ( not defined ( $meta2 ) and $wrev == $meta1->{revision}
1738
- and
1739
- ( ( $state->{entries}{$filename}{unchanged} and ( not defined ( $state->{entries}{$filename}{conflict} ) or $state->{entries}{$filename}{conflict} !~ /^\+=/ ) )
1740
- or ( defined($state->{entries}{$filename}{modified_hash}) and $state->{entries}{$filename}{modified_hash} eq $meta1->{filehash} ) )
1741
- );
1794
+ # Files to date if the working copy and repo copy have the same
1795
+ # revision, and the working copy is unmodified
1796
+ if ( not defined ( $meta2 ) and $wrev == $meta1->{revision} and
1797
+ ( ( $state->{entries}{$filename}{unchanged} and
1798
+ ( not defined ( $state->{entries}{$filename}{conflict} ) or
1799
+ $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
1800
+ ( defined($state->{entries}{$filename}{modified_hash}) and
1801
+ $state->{entries}{$filename}{modified_hash} eq
1802
+ $meta1->{filehash} ) ) )
1803
+ {
1804
+ next;
1805
+ }
1806
1807
# Apparently we only show diffs for locally modified files
1744
- next unless ( defined($meta2) or defined ( $state->{entries}{$filename}{modified_filename} ) );
1808
+ unless ( defined($meta2) or
1809
+ defined ( $state->{entries}{$filename}{modified_filename} ) )
1810
+ {
1811
+ next;
1812
+ }
1813
1814
print "M Index: $filename\n";
1747
- print "M ===================================================================\n";
1815
+ print "M =======" . ( "=" x 60 ) . "\n";
1816
print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n";
1749
- print "M retrieving revision 1.$meta1->{revision}\n" if ( defined ( $meta1 ) );
1750
- print "M retrieving revision 1.$meta2->{revision}\n" if ( defined ( $meta2 ) );
1817
+ if ( defined ( $meta1 ) )
1818
+ {
1819
+ print "M retrieving revision 1.$meta1->{revision}\n"
1820
+ }
1821
+ if ( defined ( $meta2 ) )
1822
+ {
1823
+ print "M retrieving revision 1.$meta2->{revision}\n"
1824
+ }
1825
print "M diff ";
1826
foreach my $opt ( keys %{$state->{opt}} )
1827
{
@@ -1759,18 +1833,27 @@ sub req_diff
1833
}
1834
} else {
1835
print "-$opt ";
1762
- print "$state->{opt}{$opt} " if ( defined ( $state->{opt}{$opt} ) );
1836
+ if ( defined ( $state->{opt}{$opt} ) )
1837
+ {
1838
+ print "$state->{opt}{$opt} "
1839
+ }
1840
}
1841
}
1842
print "$filename\n";
1843
1767
- $log->info("Diffing $filename -r $meta1->{revision} -r " . ( $meta2->{revision} or "workingcopy" ));
1844
+ $log->info("Diffing $filename -r $meta1->{revision} -r " .
1845
+ ( $meta2->{revision} or "workingcopy" ));
1846
1847
( $fh, $filediff ) = tempfile ( DIR => $TEMP_DIR );
1848
1849
if ( exists $state->{opt}{u} )
1850
{
1773
- system("diff -u -L '$filename revision 1.$meta1->{revision}' -L '$filename " . ( defined($meta2->{revision}) ? "revision 1.$meta2->{revision}" : "working copy" ) . "' $file1 $file2 > $filediff");
1851
+ system("diff -u -L '$filename revision 1.$meta1->{revision}'" .
1852
+ " -L '$filename " .
1853
+ ( defined($meta2->{revision}) ?
1854
+ "revision 1.$meta2->{revision}" :
1855
+ "working copy" ) .
1856
+ "' $file1 $file2 > $filediff" );
1857
} else {
1858
system("diff $file1 $file2 > $filediff");
1859
}
@@ -1795,7 +1878,8 @@ sub req_log
1878
#$log->debug("log state : " . Dumper($state));
1879
1880
my ( $minrev, $maxrev );
1798
- if ( defined ( $state->{opt}{r} ) and $state->{opt}{r} =~ /([\d.]+)?(::?)([\d.]+)?/ )
1881
+ if ( defined ( $state->{opt}{r} ) and
1882
+ $state->{opt}{r} =~ /([\d.]+)?(::?)([\d.]+)?/ )
1883
{
1884
my $control = $2;
1885
$minrev = $1;
@@ -1806,10 +1890,12 @@ sub req_log
1890
}
1891
1892
# Grab a handle to the SQLite db and do any necessary updates
1809
- my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
1893
+ my $updater;
1894
+ $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
1895
$updater->update();
1896
1812
- # if no files were specified, we need to work out what files we should be providing status on ...
1897
+ # if no files were specified, we need to work out what files we
1898
+ # should be providing status on ...
1899
argsfromdir($updater);
1900
1901
# foreach file specified on the command line ...
@@ -1825,7 +1911,8 @@ sub req_log
1911
if ( defined ( $minrev ) )
1912
{
1913
$log->debug("Removing revisions less than $minrev");
1828
- while ( scalar(@$revisions) > 0 and $revisions->[-1]{revision} < $minrev )
1914
+ while ( scalar(@$revisions) > 0 and
1915
+ $revisions->[-1]{revision} < $minrev )
1916
{
1917
pop @$revisions;
1918
}
@@ -1833,7 +1920,8 @@ sub req_log
1920
if ( defined ( $maxrev ) )
1921
{
1922
$log->debug("Removing revisions greater than $maxrev");
1836
- while ( scalar(@$revisions) > 0 and $revisions->[0]{revision} > $maxrev )
1923
+ while ( scalar(@$revisions) > 0 and
1924
+ $revisions->[0]{revision} > $maxrev )
1925
{
1926
shift @$revisions;
1927
}
@@ -1850,7 +1938,8 @@ sub req_log
1938
print "M access list:\n";
1939
print "M symbolic names:\n";
1940
print "M keyword substitution: kv\n";
1853
- print "M total revisions: $totalrevisions;\tselected revisions: " . scalar(@$revisions) . "\n";
1941
+ print "M total revisions: $totalrevisions;\tselected revisions: " .
1942
+ scalar(@$revisions) . "\n";
1943
print "M description:\n";
1944
1945
foreach my $revision ( @$revisions )
@@ -1858,14 +1947,23 @@ sub req_log
1947
print "M ----------------------------\n";
1948
print "M revision 1.$revision->{revision}\n";
1949
# reformat the date for log output
1861
- $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}) );
1950
+ if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\S+)/ and
1951
+ defined($DATE_LIST->{$2}) )
1952
+ {
1953
+ $revision->{modified} = sprintf('%04d/%02d/%02d %s',
1954
+ $3, $DATE_LIST->{$2}, $1, $4 );
1955
+ }
1956
$revision->{author} = cvs_author($revision->{author});
1863
- print "M date: $revision->{modified}; author: $revision->{author}; state: " . ( $revision->{filehash} eq "deleted" ? "dead" : "Exp" ) . "; lines: +2 -3\n";
1864
- my $commitmessage = $updater->commitmessage($revision->{commithash});
1957
+ print "M date: $revision->{modified};" .
1958
+ " author: $revision->{author}; state: " .
1959
+ ( $revision->{filehash} eq "deleted" ? "dead" : "Exp" ) .
1960
+ "; lines: +2 -3\n";
1961
+ my $commitmessage;
1962
+ $commitmessage = $updater->commitmessage($revision->{commithash});
1963
$commitmessage =~ s/^/M /mg;
1964
print $commitmessage . "\n";
1965
}
1868
- print "M =============================================================================\n";
1966
+ print "M =======" . ( "=" x 70 ) . "\n";
1967
}
1968
1969
print "ok\n";