lilypond-devel
[Top][All Lists]
Advanced

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

Fix 1529: hashed snippet filename changes should not count as log differ


From: reinhold . kainhofer
Subject: Fix 1529: hashed snippet filename changes should not count as log differences (issue 4893044)
Date: Sun, 21 Aug 2011 15:54:29 +0000

Reviewers: ,


http://codereview.appspot.com/4893044/diff/1/scripts/build/output-distance.py
File scripts/build/output-distance.py (right):

http://codereview.appspot.com/4893044/diff/1/scripts/build/output-distance.py#newcode481
scripts/build/output-distance.py:481: print "Replacing old filename %s
by %s" % (m0.group(1), m1.group(1))
This debug statement will be remove before pushing, of course.

Description:
Fix 1529: hashed snippet filename changes should not count as log
differences

If the contents of a regtest change, the regtest gets a new hash and
thus a new filename. Unfortunately, this will be detected by
output-distance as a change and will show up in the regtest analysis.
To work around this, I'm simply extracting the old and the new filename
before we compare the log files and if they differ, I replace the old
filename with the new filename in the old log file. Thus, it will
appear as if the new filename was also used in the baseline and it
will not be flagged as a difference.

Please review this at http://codereview.appspot.com/4893044/

Affected files:
  M scripts/build/output-distance.py


Index: scripts/build/output-distance.py
diff --git a/scripts/build/output-distance.py b/scripts/build/output-distance.py index 537363b63a4958b26ab2698e72d08ff91c858aaa..00074dc3927f533380a8cbf6f4378a13ce0d9847 100644
--- a/scripts/build/output-distance.py
+++ b/scripts/build/output-distance.py
@@ -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])
@@ -466,11 +467,23 @@ 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))):
+ print "Replacing old filename %s by %s" % (m0.group(1), m1.group(1))
+            #print "New filename: %s" % 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]
                                      )
@@ -752,7 +765,6 @@ class SignatureFileLink (FileLink):
 # Files/directories

 import glob
-import re

 def compare_signature_files (f1, f2):
     s1 = read_signature_file (f1)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]