]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/build/output-distance.py
Fix 1529: hashed snippet filename changes should not count as log differences
[lilypond.git] / scripts / build / output-distance.py
index 59499d16aca879705d59f6b2acad422a821919ff..b90bda55488480543c4837d4296788b56fcac30b 100644 (file)
@@ -3,6 +3,7 @@ import sys
 import optparse
 import os
 import math
+import re
 
 ## so we can call directly as scripts/build/output-distance.py
 me_path = os.path.abspath (os.path.split (sys.argv[0])[0])
@@ -468,11 +469,22 @@ class GitFileCompareLink (FileCompareLink):
         return d
 
 
+snippet_fn_re = re.compile (r"`\./([0-9a-f]{2}/lily-[0-9a-f]{8}).eps'");
 class TextFileCompareLink (FileCompareLink):
     def calc_distance (self):
         import difflib
-        diff = difflib.unified_diff (self.contents[0].strip().split ('\n'),
-                                     self.contents[1].strip().split ('\n'),
+        # Extract the old and the new hashed snippet names from the log file
+        # and replace the old by the new, so file name changes don't show
+        # up as log differences...
+        cont0 = self.contents[0].strip();
+        cont1 = self.contents[1].strip();
+        m0 = re.search (snippet_fn_re, cont0);
+        m1 = re.search (snippet_fn_re, cont1);
+        if (m0 and m1 and (m0.group(1) != m1.group(1))):
+            cont0 = cont0.replace (m0.group(1), m1.group(1));
+
+        diff = difflib.unified_diff (cont0.split ('\n'),
+                                     cont1.split ('\n'),
                                      fromfiledate = self.file_names[0],
                                      tofiledate = self.file_names[1]
                                      )
@@ -754,7 +766,6 @@ class SignatureFileLink (FileLink):
 # Files/directories
 
 import glob
-import re
 
 def compare_signature_files (f1, f2):
     s1 = read_signature_file (f1)