Commit efc00108 authored by Steve McIntyre's avatar Steve McIntyre

Add get_newest_revision() and test harness code for it

parent 9ad73da7
......@@ -545,6 +545,28 @@ sub get_oldest_revision
return '1.1'; # earliest possible revision of any file, easy!
}
=item get_newest_revision
Return the version of the newest version of a file
The first argument is a name of a file.
This function finds the newest revision of a file that is known in the
repository and returns it.
Example use:
my $rev = get_newest_revision( 'foo.c');
=cut
sub get_newest_revision
{
# NOT SUPPORTED in the CVS code
croak("NOT SUPPORTED IN THE CVS CODE");
}
=item next_revision
Given a file path and a current revision of that file, move backwards
......
......@@ -756,6 +756,37 @@ sub get_oldest_revision
croak(" Could not find any revisions for $file");
}
=item get_newest_revision
Return the version of the newest version of a file
The first argument is a name of a file.
This function finds the newest revision of a file that is known in the
repository and returns it.
Example use:
my $rev = get_newest_revision( 'foo.c');
=cut
sub get_newest_revision
{
my $self = shift;
my $file = shift or croak("No file specified");
croak( "No such file: $file" ) unless -f $file;
my @commits = $self->_grab_commits($file);
if (@commits) {
# Simply return the last revision in our list
return $commits[0]{'cmt_rev'};
}
# Should hopefully never get here!
croak(" Could not find any revisions for $file");
}
=item next_revision
Given a file path and a current revision of that file, move backwards
......
......@@ -309,6 +309,12 @@ print "VCS->get_oldest_revision on $file :::\n";
$ret = $VCS->get_oldest_revision($file);
print "Got \"$ret\"\n";
##########################################################
print "#############################\n";
print "VCS->get_newest_revision on $file :::\n";
$ret = $VCS->get_newest_revision($file);
print "Got \"$ret\"\n";
##########################################################
print "#############################\n";
print "VCS->next_revision (-1) on $file :::\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment