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 --- touch_translations.pl | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'touch_translations.pl') diff --git a/touch_translations.pl b/touch_translations.pl index 125bcfc692f..c72592c04a4 100755 --- a/touch_translations.pl +++ b/touch_translations.pl @@ -21,14 +21,21 @@ # - think of a better way to check when the file has been rebuilt last # These modules reside under webwml/Perl +# +# FIXME 93sam 2018-05-17: Converted to use Local::VCS to allow for +# usage with git, but not tested much. It's not clear at all if this +# script is still used or not. + use lib ($0 =~ m|(.*)/|, $1 or ".") ."/Perl"; -use Local::Cvsinfo; +use Local::VCS; use Webwml::Langs; use Webwml::TransCheck; # Set this to 1 for debugging $debug = 0; +my $VCS = Local::VCS->new(); + sub rebuild { my $file = shift; $now = time; @@ -72,8 +79,6 @@ sub when_forced { } } -# We call constructor without argument. It means there must be a -# CVS/Repository file or program will abort. my $l = Webwml::Langs->new(); my %langs = $l->iso_name(); my @langs = $l->names(); @@ -84,10 +89,12 @@ $arglang = $langs{$ARGV[1]} or die "Invalid lang argument: $ARGV[1]"; $argfile =~ m+(.*)/(.*\.wml)+ or die "pattern does not match"; my ($path, $file) = ($1, $2); -my $cvs = Local::Cvsinfo->new(); -$cvs->options(matchfile => [ $file ]); -$cvs->readinfo($path); -my $origrev = $cvs->revision($argfile) || "1.0"; +my %file_info = $VCS->file_info($argfile); +my $origrev = $file_info{'cmt_rev'}; +unless ($origrev) +{ + die "Could not get revision number for $argfile - bug in script?\n"; +} foreach $lang (@langs) { next if ($lang eq $arglang); @@ -104,15 +111,10 @@ foreach $lang (@langs) { $original = $transcheck->original(); $maxdelta = $transcheck->maxdelta() if $transcheck->maxdelta(); $mindelta = $transcheck->mindelta() if $transcheck->mindelta(); - # TODO - would cause unspecified results if 1. changed to 2. - $origrev =~ s/1\.//; - $langrev =~ s/1\.//; next unless not defined $original or $original eq $arglang; - # Compare the revisions - print "Orig: $origrev, lang: $langrev\n" if $debug; - $difference = $origrev-$langrev; + $difference = $VCS->count_changes($argfile, $langrev, $origrev); if ($difference < $mindelta) { next unless was_forced($transfile); print "unlinking $transfile.forced\n" if $debug; -- cgit v1.2.3