]> git.donarmstrong.com Git - lilypond.git/commitdiff
use md5 for hashing ly snippets. This makes snippets lilypond-book
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 11 Dec 2006 21:59:07 +0000 (22:59 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 11 Dec 2006 21:59:07 +0000 (22:59 +0100)
documents reproducible across platforms.

scripts/lilypond-book.py

index 66e0704e69ec6ab41e039d50f829619b2bf198ab..6699ba2dcb8b5a269536238c32f4331b6c5f92cb 100644 (file)
@@ -35,6 +35,7 @@ import commands
 import os
 import sys
 import re
+import md5
 
 ################
 # RELOCATION
@@ -1066,17 +1067,20 @@ class Lilypond_snippet (Snippet):
         d.update (locals())
         return (PREAMBLE_LY + body) % d
 
-    # TODO: Use md5?
     def get_hash (self):
         if not self.hash:
-            self.hash = abs (hash (self.relevant_contents (self.full_ly ())))
+            hash = md5.md5 (self.relevant_contents (self.full_ly ()))
+
+            ## let's not create too long names.
+            self.hash = hash.hexdigest ()[:10]
+            
         return self.hash
 
     def basename (self):
         if FILENAME in self.option_dict:
             return self.option_dict[FILENAME]
         if global_options.use_hash:
-            return 'lily-%d' % self.get_hash ()
+            return 'lily-%s' % self.get_hash ()
         raise 'to be done'
 
     def write_ly (self):