cvsserver: use whole CVS rev number in-process; don't strip "1." prefix

Keep track of the whole CVS revision number in-process. This will clarify code when we start handling non-linear revision numbers later. There is one externally visible change: conflict markers after an update will now include the full CVS revision number, including the "1." prefix. It used to leave off the prefix. Other than the conflict marker, this change doesn't effect external functionality. No new features, and the DB schema is unchanged such that it continues to store just the stripped rev numbers (without prefix). 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 ab07681fed75f3810f6c1fca526b763a88d2ba94
2 files changed +123 -104
git-cvsserver.perl
+122 -103
@@ -554,10 +554,10 @@ sub req_add
554 my $meta = $updater->getmeta($filename);
555 my $wrev = revparse($filename);
556
557 - if ($wrev && $meta && ($wrev < 0))
557 + if ($wrev && $meta && ($wrev=~/^-/))
558 {
559 # previously removed file, add back
560 - $log->info("added file $filename was previously removed, send 1.$meta->{revision}");
560 + $log->info("added file $filename was previously removed, send $meta->{revision}");
561
562 print "MT +updated\n";
563 print "MT text U \n";
@@ -574,8 +574,8 @@ sub req_add
574
575 # this is an "entries" line
576 my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
577 - $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
578 - print "/$filepart/1.$meta->{revision}//$kopts/\n";
577 + $log->debug("/$filepart/$meta->{revision}//$kopts/");
578 + print "/$filepart/$meta->{revision}//$kopts/\n";
579 # permissions
580 $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
581 print "u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\n";
@@ -683,13 +683,13 @@ sub req_remove
683 next;
684 }
685
686 - if ( defined($wrev) and $wrev < 0 )
686 + if ( defined($wrev) and ($wrev=~/^-/) )
687 {
688 print "E cvs remove: file `$filename' already scheduled for removal\n";
689 next;
690 }
691
692 - unless ( $wrev == $meta->{revision} )
692 + unless ( $wrev eq $meta->{revision} )
693 {
694 # TODO : not sure if the format of this message is quite correct.
695 print "E cvs remove: Up to date check failed for `$filename'\n";
@@ -704,7 +704,7 @@ sub req_remove
704 print "Checked-in $dirpart\n";
705 print "$filename\n";
706 my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
707 - print "/$filepart/-1.$wrev//$kopts/\n";
707 + print "/$filepart/-$wrev//$kopts/\n";
708
709 $rmcount++;
710 }
@@ -995,7 +995,7 @@ sub req_co
995
996 # this is an "entries" line
997 my $kopts = kopts_from_path($fullName,"sha1",$git->{filehash});
998 - print "/$git->{name}/1.$git->{revision}//$kopts/\n";
998 + print "/$git->{name}/$git->{revision}//$kopts/\n";
999 # permissions
1000 print "u=$git->{mode},g=$git->{mode},o=$git->{mode}\n";
1001
@@ -1083,7 +1083,7 @@ sub req_update
1083 }
1084
1085 my $meta;
1086 - if ( defined($state->{opt}{r}) and $state->{opt}{r} =~ /^1\.(\d+)/ )
1086 + if ( defined($state->{opt}{r}) and $state->{opt}{r} =~ /^(1\.\d+)$/ )
1087 {
1088 $meta = $updater->getmeta($filename, $1);
1089 } else {
@@ -1105,7 +1105,7 @@ sub req_update
1105 {
1106 $meta = {
1107 name => $filename,
1108 - revision => 0,
1108 + revision => '0',
1109 filehash => 'added'
1110 };
1111 }
@@ -1115,7 +1115,7 @@ sub req_update
1115 my $wrev = revparse($filename);
1116
1117 # If the working copy is an old revision, lets get that version too for comparison.
1118 - if ( defined($wrev) and $wrev != $meta->{revision} )
1118 + if ( defined($wrev) and $wrev ne $meta->{revision} )
1119 {
1120 $oldmeta = $updater->getmeta($filename, $wrev);
1121 }
@@ -1126,7 +1126,7 @@ sub req_update
1126 # and the working copy is unmodified _and_ the user hasn't specified -C
1127 next if ( defined ( $wrev )
1128 and defined($meta->{revision})
1129 - and $wrev == $meta->{revision}
1129 + and $wrev eq $meta->{revision}
1130 and $state->{entries}{$filename}{unchanged}
1131 and not exists ( $state->{opt}{C} ) );
1132
@@ -1134,7 +1134,7 @@ sub req_update
1134 # but the working copy is modified, tell the client it's modified
1135 if ( defined ( $wrev )
1136 and defined($meta->{revision})
1137 - and $wrev == $meta->{revision}
1137 + and $wrev eq $meta->{revision}
1138 and defined($state->{entries}{$filename}{modified_hash})
1139 and not exists ( $state->{opt}{C} ) )
1140 {
@@ -1168,7 +1168,7 @@ sub req_update
1168 {
1169 # normal update, just send the new revision (either U=Update,
1170 # or A=Add, or R=Remove)
1171 - if ( defined($wrev) && $wrev < 0 )
1171 + if ( defined($wrev) && ($wrev=~/^-/) )
1172 {
1173 $log->info("Tell the client the file is scheduled for removal");
1174 print "MT text R \n";
@@ -1176,7 +1176,8 @@ sub req_update
1176 print "MT newline\n";
1177 next;
1178 }
1179 - elsif ( (!defined($wrev) || $wrev == 0) && (!defined($meta->{revision}) || $meta->{revision} == 0) )
1179 + elsif ( (!defined($wrev) || $wrev eq '0') &&
1180 + (!defined($meta->{revision}) || $meta->{revision} eq '0') )
1181 {
1182 $log->info("Tell the client the file is scheduled for addition");
1183 print "MT text A \n";
@@ -1186,7 +1187,7 @@ sub req_update
1187
1188 }
1189 else {
1189 - $log->info("Updating '$filename' to ".$meta->{revision});
1190 + $log->info("UpdatingX3 '$filename' to ".$meta->{revision});
1191 print "MT +updated\n";
1192 print "MT text U \n";
1193 print "MT fname $filename\n";
@@ -1218,8 +1219,8 @@ sub req_update
1219
1220 # this is an "entries" line
1221 my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
1221 - $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
1222 - print "/$filepart/1.$meta->{revision}//$kopts/\n";
1222 + $log->debug("/$filepart/$meta->{revision}//$kopts/");
1223 + print "/$filepart/$meta->{revision}//$kopts/\n";
1224
1225 # permissions
1226 $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
@@ -1229,7 +1230,6 @@ sub req_update
1230 transmitfile($meta->{filehash});
1231 }
1232 } else {
1232 - $log->info("Updating '$filename'");
1233 my ( $filepart, $dirpart ) = filenamesplit($meta->{name},1);
1234
1235 my $mergeDir = setupTmpDir();
@@ -1244,7 +1244,7 @@ sub req_update
1244
1245 # we need to merge with the local changes ( M=successful merge, C=conflict merge )
1246 $log->info("Merging $file_local, $file_old, $file_new");
1247 - print "M Merging differences between 1.$oldmeta->{revision} and 1.$meta->{revision} into $filename\n";
1247 + print "M Merging differences between $oldmeta->{revision} and $meta->{revision} into $filename\n";
1248
1249 $log->debug("Temporary directory for merge is $mergeDir");
1250
@@ -1267,8 +1267,8 @@ sub req_update
1267 print $state->{CVSROOT} . "/$state->{module}/$filename\n";
1268 my $kopts = kopts_from_path("$dirpart/$filepart",
1269 "file",$mergedFile);
1270 - $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
1271 - print "/$filepart/1.$meta->{revision}//$kopts/\n";
1270 + $log->debug("/$filepart/$meta->{revision}//$kopts/");
1271 + print "/$filepart/$meta->{revision}//$kopts/\n";
1272 }
1273 }
1274 elsif ( $return == 1 )
@@ -1284,7 +1284,7 @@ sub req_update
1284 print $state->{CVSROOT} . "/$state->{module}/$filename\n";
1285 my $kopts = kopts_from_path("$dirpart/$filepart",
1286 "file",$mergedFile);
1287 - print "/$filepart/1.$meta->{revision}/+/$kopts/\n";
1287 + print "/$filepart/$meta->{revision}/+/$kopts/\n";
1288 }
1289 }
1290 else
@@ -1387,11 +1387,12 @@ sub req_ci
1387
1388 my $addflag = 0;
1389 my $rmflag = 0;
1390 - $rmflag = 1 if ( defined($wrev) and $wrev < 0 );
1390 + $rmflag = 1 if ( defined($wrev) and ($wrev=~/^-/) );
1391 $addflag = 1 unless ( -e $filename );
1392
1393 # Do up to date checking
1394 - unless ( $addflag or $wrev == $meta->{revision} or ( $rmflag and -$wrev == $meta->{revision} ) )
1394 + unless ( $addflag or $wrev eq $meta->{revision} or
1395 + ( $rmflag and $wrev eq "-$meta->{revision}" ) )
1396 {
1397 # fail everything if an up to date check fails
1398 print "error 1 Up to date check failed for $filename\n";
@@ -1428,7 +1429,7 @@ sub req_ci
1429 $log->info("Adding file '$filename'");
1430 system("git", "update-index", "--add", $filename);
1431 } else {
1431 - $log->info("Updating file '$filename'");
1432 + $log->info("UpdatingX2 file '$filename'");
1433 system("git", "update-index", $filename);
1434 }
1435 }
@@ -1519,7 +1520,7 @@ sub req_ci
1520
1521 my $meta = $updater->getmeta($filename);
1522 unless (defined $meta->{revision}) {
1522 - $meta->{revision} = 1;
1523 + $meta->{revision} = "1.1";
1524 }
1525
1526 my ( $filepart, $dirpart ) = filenamesplit($filename, 1);
@@ -1529,19 +1530,19 @@ sub req_ci
1530 print "M $state->{CVSROOT}/$state->{module}/$filename,v <-- $dirpart$filepart\n";
1531 if ( defined $meta->{filehash} && $meta->{filehash} eq "deleted" )
1532 {
1532 - print "M new revision: delete; previous revision: 1.$oldmeta{$filename}{revision}\n";
1533 + print "M new revision: delete; previous revision: $oldmeta{$filename}{revision}\n";
1534 print "Remove-entry $dirpart\n";
1535 print "$filename\n";
1536 } else {
1536 - if ($meta->{revision} == 1) {
1537 + if ($meta->{revision} eq "1.1") {
1538 print "M initial revision: 1.1\n";
1539 } else {
1539 - print "M new revision: 1.$meta->{revision}; previous revision: 1.$oldmeta{$filename}{revision}\n";
1540 + print "M new revision: $meta->{revision}; previous revision: $oldmeta{$filename}{revision}\n";
1541 }
1542 print "Checked-in $dirpart\n";
1543 print "$filename\n";
1544 my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
1544 - print "/$filepart/1.$meta->{revision}//$kopts/\n";
1545 + print "/$filepart/$meta->{revision}//$kopts/\n";
1546 }
1547 }
1548
@@ -1585,7 +1586,7 @@ sub req_status
1586
1587 # If the working copy is an old revision, lets get that
1588 # version too for comparison.
1588 - if ( defined($wrev) and $wrev != $meta->{revision} )
1589 + if ( defined($wrev) and $wrev ne $meta->{revision} )
1590 {
1591 $oldmeta = $updater->getmeta($filename, $wrev);
1592 }
@@ -1595,21 +1596,22 @@ sub req_status
1596 # Files are up to date if the working copy and repo copy have
1597 # the same revision, and the working copy is unmodified
1598 if ( defined ( $wrev ) and defined($meta->{revision}) and
1598 - $wrev == $meta->{revision} and
1599 + $wrev eq $meta->{revision} and
1600 ( ( $state->{entries}{$filename}{unchanged} and
1601 ( not defined ( $state->{entries}{$filename}{conflict} ) or
1602 $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
1603 ( defined($state->{entries}{$filename}{modified_hash}) and
1604 $state->{entries}{$filename}{modified_hash} eq
1604 - $meta->{filehash} ) ) )
1605 + $meta->{filehash} ) ) )
1606 {
1606 - $status = "Up-to-date";
1607 + $status = "Up-to-date"
1608 }
1609
1609 - # Need checkout if the working copy has an older revision than
1610 - # the repo copy, and the working copy is unmodified
1610 + # Need checkout if the working copy has a different (usually
1611 + # older) revision than the repo copy, and the working copy is
1612 + # unmodified
1613 if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
1612 - $meta->{revision} > $wrev and
1614 + $meta->{revision} ne $wrev and
1615 ( $state->{entries}{$filename}{unchanged} or
1616 ( defined($state->{entries}{$filename}{modified_hash}) and
1617 $state->{entries}{$filename}{modified_hash} eq
@@ -1628,16 +1630,16 @@ sub req_status
1630 # Locally modified if working copy and repo copy have the
1631 # same revision but there are local changes
1632 if ( defined ( $wrev ) and defined($meta->{revision}) and
1631 - $wrev == $meta->{revision} and
1633 + $wrev eq $meta->{revision} and
1634 $state->{entries}{$filename}{modified_filename} )
1635 {
1636 $status ||= "Locally Modified";
1637 }
1638
1637 - # Needs Merge if working copy revision is less than repo copy
1638 - # and there are local changes
1639 + # Needs Merge if working copy revision is different
1640 + # (usually older) than repo copy and there are local changes
1641 if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
1640 - $meta->{revision} > $wrev and
1642 + $meta->{revision} ne $wrev and
1643 $state->{entries}{$filename}{modified_filename} )
1644 {
1645 $status ||= "Needs Merge";
@@ -1649,7 +1651,7 @@ sub req_status
1651 $status ||= "Locally Added";
1652 }
1653 if ( defined ( $wrev ) and defined ( $meta->{revision} ) and
1652 - -$wrev == $meta->{revision} )
1654 + $wrev eq "-$meta->{revision}" )
1655 {
1656 $status ||= "Locally Removed";
1657 }
@@ -1678,7 +1680,7 @@ sub req_status
1680 }
1681 if ( defined($meta->{revision}) )
1682 {
1681 - print "M Repository revision:\t1." .
1683 + print "M Repository revision:\t" .
1684 $meta->{revision} .
1685 "\t$state->{CVSROOT}/$state->{module}/$filename,v\n";
1686 print "M Sticky Tag:\t\t(none)\n";
@@ -1711,9 +1713,6 @@ sub req_diff
1713 $revision1 = $state->{opt}{r};
1714 }
1715
1714 - $revision1 =~ s/^1\.// if ( defined ( $revision1 ) );
1715 - $revision2 =~ s/^1\.// if ( defined ( $revision2 ) );
1716 -
1716 $log->debug("Diffing revisions " .
1717 ( defined($revision1) ? $revision1 : "[NULL]" ) .
1718 " and " . ( defined($revision2) ? $revision2 : "[NULL]" ) );
@@ -1746,7 +1745,7 @@ sub req_diff
1745 $meta1 = $updater->getmeta($filename, $revision1);
1746 unless ( defined ( $meta1 ) and $meta1->{filehash} ne "deleted" )
1747 {
1749 - print "E File $filename at revision 1.$revision1 doesn't exist\n";
1748 + print "E File $filename at revision $revision1 doesn't exist\n";
1749 next;
1750 }
1751 transmitfile($meta1->{filehash}, { targetfile => $file1 });
@@ -1767,7 +1766,7 @@ sub req_diff
1766
1767 unless ( defined ( $meta2 ) and $meta2->{filehash} ne "deleted" )
1768 {
1770 - print "E File $filename at revision 1.$revision2 doesn't exist\n";
1769 + print "E File $filename at revision $revision2 doesn't exist\n";
1770 next;
1771 }
1772
@@ -1793,7 +1792,7 @@ sub req_diff
1792
1793 # Files to date if the working copy and repo copy have the same
1794 # revision, and the working copy is unmodified
1796 - if ( not defined ( $meta2 ) and $wrev == $meta1->{revision} and
1795 + if ( not defined ( $meta2 ) and $wrev eq $meta1->{revision} and
1796 ( ( $state->{entries}{$filename}{unchanged} and
1797 ( not defined ( $state->{entries}{$filename}{conflict} ) or
1798 $state->{entries}{$filename}{conflict} !~ /^\+=/ ) ) or
@@ -1816,11 +1815,11 @@ sub req_diff
1815 print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n";
1816 if ( defined ( $meta1 ) )
1817 {
1819 - print "M retrieving revision 1.$meta1->{revision}\n"
1818 + print "M retrieving revision $meta1->{revision}\n"
1819 }
1820 if ( defined ( $meta2 ) )
1821 {
1823 - print "M retrieving revision 1.$meta2->{revision}\n"
1822 + print "M retrieving revision $meta2->{revision}\n"
1823 }
1824 print "M diff ";
1825 foreach my $opt ( keys %{$state->{opt}} )
@@ -1848,10 +1847,10 @@ sub req_diff
1847
1848 if ( exists $state->{opt}{u} )
1849 {
1851 - system("diff -u -L '$filename revision 1.$meta1->{revision}'" .
1850 + system("diff -u -L '$filename revision $meta1->{revision}'" .
1851 " -L '$filename " .
1852 ( defined($meta2->{revision}) ?
1854 - "revision 1.$meta2->{revision}" :
1853 + "revision $meta2->{revision}" :
1854 "working copy" ) .
1855 "' $file1 $file2 > $filediff" );
1856 } else {
@@ -1877,16 +1876,10 @@ sub req_log
1876 $log->debug("req_log : " . ( defined($data) ? $data : "[NULL]" ));
1877 #$log->debug("log state : " . Dumper($state));
1878
1880 - my ( $minrev, $maxrev );
1881 - if ( defined ( $state->{opt}{r} ) and
1882 - $state->{opt}{r} =~ /([\d.]+)?(::?)([\d.]+)?/ )
1883 - {
1884 - my $control = $2;
1885 - $minrev = $1;
1886 - $maxrev = $3;
1887 - $minrev =~ s/^1\.// if ( defined ( $minrev ) );
1888 - $maxrev =~ s/^1\.// if ( defined ( $maxrev ) );
1889 - $minrev++ if ( defined($minrev) and $control eq "::" );
1879 + my ( $revFilter );
1880 + if ( defined ( $state->{opt}{r} ) )
1881 + {
1882 + $revFilter = $state->{opt}{r};
1883 }
1884
1885 # Grab a handle to the SQLite db and do any necessary updates
@@ -1905,34 +1898,15 @@ sub req_log
1898
1899 my $headmeta = $updater->getmeta($filename);
1900
1908 - my $revisions = $updater->getlog($filename);
1909 - my $totalrevisions = scalar(@$revisions);
1910 -
1911 - if ( defined ( $minrev ) )
1912 - {
1913 - $log->debug("Removing revisions less than $minrev");
1914 - while ( scalar(@$revisions) > 0 and
1915 - $revisions->[-1]{revision} < $minrev )
1916 - {
1917 - pop @$revisions;
1918 - }
1919 - }
1920 - if ( defined ( $maxrev ) )
1921 - {
1922 - $log->debug("Removing revisions greater than $maxrev");
1923 - while ( scalar(@$revisions) > 0 and
1924 - $revisions->[0]{revision} > $maxrev )
1925 - {
1926 - shift @$revisions;
1927 - }
1928 - }
1901 + my ($revisions,$totalrevisions) = $updater->getlog($filename,
1902 + $revFilter);
1903
1904 next unless ( scalar(@$revisions) );
1905
1906 print "M \n";
1907 print "M RCS file: $state->{CVSROOT}/$state->{module}/$filename,v\n";
1908 print "M Working file: $filename\n";
1935 - print "M head: 1.$headmeta->{revision}\n";
1909 + print "M head: $headmeta->{revision}\n";
1910 print "M branch:\n";
1911 print "M locks: strict\n";
1912 print "M access list:\n";
@@ -1945,7 +1919,7 @@ sub req_log
1919 foreach my $revision ( @$revisions )
1920 {
1921 print "M ----------------------------\n";
1948 - print "M revision 1.$revision->{revision}\n";
1922 + print "M revision $revision->{revision}\n";
1923 # reformat the date for log output
1924 if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\S+)/ and
1925 defined($DATE_LIST->{$2}) )
@@ -2069,7 +2043,7 @@ sub req_annotate
2043 $metadata->{$commithash}{author} = cvs_author($metadata->{$commithash}{author});
2044 $metadata->{$commithash}{modified} = sprintf("%02d-%s-%02d", $1, $2, $3) if ( $metadata->{$commithash}{modified} =~ /^(\d+)\s(\w+)\s\d\d(\d\d)/ );
2045 }
2072 - printf("M 1.%-5d (%-8s %10s): %s\n",
2046 + printf("M %-7s (%-8s %10s): %s\n",
2047 $metadata->{$commithash}{revision},
2048 $metadata->{$commithash}{author},
2049 $metadata->{$commithash}{modified},
@@ -2190,7 +2164,7 @@ sub argsfromdir
2164 # push added files
2165 foreach my $file (keys %{$state->{entries}}) {
2166 if ( exists $state->{entries}{$file}{revision} &&
2193 - $state->{entries}{$file}{revision} == 0 )
2167 + $state->{entries}{$file}{revision} eq '0' )
2168 {
2169 push @gethead, { name => $file, filehash => 'added' };
2170 }
@@ -2234,20 +2208,15 @@ sub statecleanup
2208 $state->{entries} = {};
2209 }
2210
2237 -# Return working directory revision int "X" from CVS revision "1.X" out
2211 +# Return working directory CVS revision "1.X" out
2212 # of the the working directory "entries" state, for the given filename.
2239 -# Return negative "X" to represent the file is scheduled for removal
2213 +# This is prefixed with a dash if the file is scheduled for removal
2214 # when it is committed.
2215 sub revparse
2216 {
2217 my $filename = shift;
2218
2245 - return undef unless ( defined ( $state->{entries}{$filename}{revision} ) );
2246 -
2247 - return $1 if ( $state->{entries}{$filename}{revision} =~ /^1\.(\d+)/ );
2248 - return -$1 if ( $state->{entries}{$filename}{revision} =~ /^-1\.(\d+)/ );
2249 -
2250 - return undef;
2219 + return $state->{entries}{$filename}{revision};
2220 }
2221
2222 # This method takes a file hash and does a CVS "file transfer". Its
@@ -3230,7 +3199,7 @@ sub update
3199 my $commitcount = 0;
3200
3201 # Load the head table into $head (for cached lookups during the update process)
3233 - foreach my $file ( @{$self->gethead()} )
3202 + foreach my $file ( @{$self->gethead(1)} )
3203 {
3204 $head->{$file->{name}} = $file;
3205 }
@@ -3580,6 +3549,7 @@ sub _set_prop
3549 sub gethead
3550 {
3551 my $self = shift;
3552 + my $intRev = shift;
3553 my $tablename = $self->tablename("head");
3554
3555 return $self->{gethead_cache} if ( defined ( $self->{gethead_cache} ) );
@@ -3590,6 +3560,10 @@ sub gethead
3560 my $tree = [];
3561 while ( my $file = $db_query->fetchrow_hashref )
3562 {
3563 + if(!$intRev)
3564 + {
3565 + $file->{revision} = "1.$file->{revision}"
3566 + }
3567 push @$tree, $file;
3568 }
3569
@@ -3608,18 +3582,49 @@ sub getlog
3582 {
3583 my $self = shift;
3584 my $filename = shift;
3585 + my $revFilter = shift;
3586 +
3587 my $tablename = $self->tablename("revision");
3588
3589 + # Filters:
3590 + # TODO: date, state, or by specific logins filters?
3591 + # TODO: Handle comma-separated list of revFilter items, each item
3592 + # can be a range [only case currently handled] or individual
3593 + # rev or branch or "branch.".
3594 + # TODO: Adjust $db_query WHERE clause based on revFilter, instead of
3595 + # manually filtering the results of the query?
3596 + my ( $minrev, $maxrev );
3597 + if( defined($revFilter) and
3598 + $state->{opt}{r} =~ /^(1.(\d+))?(::?)(1.(\d.+))?$/ )
3599 + {
3600 + my $control = $3;
3601 + $minrev = $2;
3602 + $maxrev = $5;
3603 + $minrev++ if ( defined($minrev) and $control eq "::" );
3604 + }
3605 +
3606 my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, author, mode, revision, modified, commithash FROM $tablename WHERE name=? ORDER BY revision DESC",{},1);
3607 $db_query->execute($filename);
3608
3609 + my $totalRevs=0;
3610 my $tree = [];
3611 while ( my $file = $db_query->fetchrow_hashref )
3612 {
3613 + $totalRevs++;
3614 + if( defined($minrev) and $file->{revision} < $minrev )
3615 + {
3616 + next;
3617 + }
3618 + if( defined($maxrev) and $file->{revision} > $maxrev )
3619 + {
3620 + next;
3621 + }
3622 +
3623 + $file->{revision} = "1." . $file->{revision};
3624 push @$tree, $file;
3625 }
3626
3622 - return $tree;
3627 + return ($tree,$totalRevs);
3628 }
3629
3630 =head2 getmeta
@@ -3638,10 +3643,11 @@ sub getmeta
3643 my $tablename_head = $self->tablename("head");
3644
3645 my $db_query;
3641 - if ( defined($revision) and $revision =~ /^\d+$/ )
3646 + if ( defined($revision) and $revision =~ /^1\.(\d+)$/ )
3647 {
3648 + my ($intRev) = $1;
3649 $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_rev WHERE name=? AND revision=?",{},1);
3644 - $db_query->execute($filename, $revision);
3650 + $db_query->execute($filename, $intRev);
3651 }
3652 elsif ( defined($revision) and $revision =~ /^[a-zA-Z0-9]{40}$/ )
3653 {
@@ -3652,7 +3658,12 @@ sub getmeta
3658 $db_query->execute($filename);
3659 }
3660
3655 - return $db_query->fetchrow_hashref;
3661 + my $meta = $db_query->fetchrow_hashref;
3662 + if($meta)
3663 + {
3664 + $meta->{revision} = "1.$meta->{revision}";
3665 + }
3666 + return $meta;
3667 }
3668
3669 =head2 commitmessage
@@ -3709,7 +3720,15 @@ sub gethistorydense
3720 $db_query = $self->{dbh}->prepare_cached("SELECT revision, filehash, commithash FROM $tablename WHERE name=? AND filehash!='deleted' ORDER BY revision DESC",{},1);
3721 $db_query->execute($filename);
3722
3712 - return $db_query->fetchall_arrayref;
3723 + my $result = $db_query->fetchall_arrayref;
3724 +
3725 + my $i;
3726 + for($i=0 ; $i<scalar(@$result) ; $i++)
3727 + {
3728 + $result->[$i][0]="1." . $result->[$i][0];
3729 + }
3730 +
3731 + return $result;
3732 }
3733
3734 =head2 in_array()
t/t9400-git-cvsserver-server.sh
+1 -1
@@ -400,7 +400,7 @@ cat >expected.C <<EOF
400 Line 0
401 =======
402 LINE 0
403 ->>>>>>> merge.3
403 +>>>>>>> merge.1.3
404 EOF
405
406 for i in 1 2 3 4 5 6 7 8