[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

smart_change.pl patch



Hi all,

After I applied the https patch, I discovered that smart_change.pl bumps
translation headers even when the substitution does not result in any
change to the english/* files. I've attached a patch that fixes it for
me but I don't know much about the script to know if I've caused any
regressions. Could someone review the patch and check if it causes any
problems with the normal uses of the script?

-- 
bye,
pabs

http://wiki.debian.org/PaulWise
Index: smart_change.pl
===================================================================
RCS file: /cvs/webwml/webwml/smart_change.pl,v
retrieving revision 1.8
diff -p -u -r1.8 smart_change.pl
--- smart_change.pl	5 Nov 2010 20:39:07 -0000	1.8
+++ smart_change.pl	26 Nov 2012 10:11:44 -0000
@@ -3,10 +3,6 @@
 # This script perform changes in WML source files and bump version
 # number when translated files are up to date.
 
-# Known Issues:
-# when there is no change to the origfile the translation="" revision is
-# updated for current translations nevertheless
-
 use strict;
 use Getopt::Long;
 
@@ -58,6 +54,7 @@ sub verbose {
 if (not @opt_l) {
         my $l = Webwml::Langs->new();
         @opt_l = $l->names();
+        @opt_l = grep { $_ ne "english" } @opt_l;
 }
 
 my $eval_opt_s = '1';
@@ -87,6 +84,20 @@ foreach my $argfile (@ARGV) {
         $nextrev =~ s/(\d+)$/(1+$1)/e;
         verbose("Next revision: $nextrev");
 
+        my $origtext = '';
+        my $substext = '';
+        open (ARG, "< $argfile");
+        while (<ARG>) { $origtext .= $_; }
+        $substext = &$substitute($origtext);
+        if ($origtext ne $substext) {
+                verbose("Writing $argfile");
+                open (ARG, "> $argfile");
+                print ARG $substext;
+                close (ARG);
+        } elsif (scalar @opt_s) {
+                next;
+        }
+
         foreach my $lang (@opt_l) {
                 my $transfile = $argfile;
                 $transfile =~ s/^english/$lang/ || next;

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: