diff options
author | Steve McIntyre <steve@einval.com> | 2018-05-31 11:36:38 +0100 |
---|---|---|
committer | Steve McIntyre <steve@einval.com> | 2018-05-31 11:36:38 +0100 |
commit | efc00108d1057ca715beea03271cfe9ebb55c22e (patch) | |
tree | d4888a4a16186dfe062751bee13c44a38b55273c /Perl | |
parent | 9ad73da75f60b351ba43e8be99363e58ce624367 (diff) |
Add get_newest_revision() and test harness code for it
Diffstat (limited to 'Perl')
-rw-r--r-- | Perl/Local/VCS_CVS.pm | 22 | ||||
-rw-r--r-- | Perl/Local/VCS_git.pm | 31 |
2 files changed, 53 insertions, 0 deletions
diff --git a/Perl/Local/VCS_CVS.pm b/Perl/Local/VCS_CVS.pm index 890f544c3a6..1f140742d47 100644 --- a/Perl/Local/VCS_CVS.pm +++ b/Perl/Local/VCS_CVS.pm @@ -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 diff --git a/Perl/Local/VCS_git.pm b/Perl/Local/VCS_git.pm index 136d19f4153..d8ef385555f 100644 --- a/Perl/Local/VCS_git.pm +++ b/Perl/Local/VCS_git.pm @@ -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 |