From afdb29732ca24242f1a2e94f98e90034f9925f46 Mon Sep 17 00:00:00 2001 From: Steve McIntyre <93sam> Date: Wed, 30 May 2018 02:26:19 +0000 Subject: Major updates to perl scripts Add new git backend in VCS_git.pm Switch from an old-style set of function calls to an OO API. This allows for initialisation and some state to be kept in the VCS_git.pm module - namely a per-file cache of commit hashes for a massive performance boost when doing lots of lookups. Extend the API with 2 new utility functions: * get_oldest_revision() * next_revision() Extended the vcs_cmp_rev() function to take a filename too. Add a test harness to validate the git and cvs backends. Add switch_to_git_translations.pl to walk the tree and switch from cvs revisions to git commit hashes in translation-check headers. Change all of our local scripts to use the new Local::VCS frontend *where it makes sense*. Some scripts will behave slightly differently, as the new world can't exactly match the old behaviour. CVS version numbers check_desc_trans.pl: 1.9 -> 1.10 check_trans.pl: 1.93 -> 1.94 copypage.pl: 1.42 -> 1.43 karma.pl: 1.6 -> 1.7 remove_stale.pl: 1.22 -> 1.23 smart_change.pl: 1.8 -> 1.9 stattrans.pl: 1.127 -> 1.128 switch_to_git_translations.pl: INITIAL -> 1.1 touch_translations.pl: 1.9 -> 1.10 vcs-test.pl: INITIAL -> 1.1 Perl/Local/Util.pm: 1.4 -> 1.5 Perl/Local/VCS.pm: 1.3 -> 1.4 Perl/Local/VCS_CVS.pm: 1.13 -> 1.14 Perl/Local/VCS_git.pm: 1.12 -> 1.13 Perl/Webwml/Langs.pm: 1.5 -> 1.6 Perl/Webwml/TransIgnore.pm: 1.3 -> 1.4 --- check_desc_trans.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'check_desc_trans.pl') diff --git a/check_desc_trans.pl b/check_desc_trans.pl index 4311458ec64..0215caf08fa 100755 --- a/check_desc_trans.pl +++ b/check_desc_trans.pl @@ -90,15 +90,17 @@ my $directory = catdir( 'MailingLists' , 'desc' ); my $srcdir = catdir( 'english', $directory ); my $destdir = catdir( $language, $directory ); -# read svn info about files in source dir -my %revision_info = vcs_path_info( $srcdir, 'recursive' => 1 ); +my $VCS = Local::VCS->new(); + +# read VCS info about files in source dir +my %revision_info = $VCS->path_info( $srcdir, 'recursive' => 1 ); # read the translation-check files in dest dir my %transcheck = read_transcheck( $destdir ); # check all files my ($nr_uptodate,$nr_old,$nr_needtrans,$nr_obsolete,$nr_error) = - check_all( $language, $directory, \%transcheck, \%revision_info ); + check_all( $VCS, $language, $directory, \%transcheck, \%revision_info ); # print results print "\nResults:\n"; @@ -160,6 +162,7 @@ sub read_transcheck # check all translations sub check_all { + my $VCS = shift; my $lang = shift or die("No language specified"); my $dir = shift or die("No directory specified"); my $files = shift or die("No transcheck files specified"); @@ -202,7 +205,7 @@ sub check_all if ( -e $file_english and -e $file_transl ) { # needs update - if ( vcs_cmp_rev( $files->{$file}, $revinfo->{$file}->{'cmt_rev'} ) == -1 ) + if ( $VCS->cmp_rev( $file_english, $files->{$file}, $revinfo->{$file}->{'cmt_rev'} ) == -1 ) { $nr_old++; print color('blue'), $file_transl, color('reset'); @@ -210,7 +213,7 @@ sub check_all $files->{$file}, $revinfo->{$file}->{'cmt_rev'}; } # translated file is too new - elsif ( vcs_cmp_rev( $files->{$file}, $revinfo->{$file}->{'cmt_rev'} ) == -1 ) + elsif ( $VCS->cmp_rev( $file_english, $files->{$file}, $revinfo->{$file}->{'cmt_rev'} ) == -1 ) { $nr_error++; print color('blue'), $file_transl, color('reset'); -- cgit v1.2.3