From: Han-Wen Nienhuys Date: Mon, 11 Dec 2006 21:59:07 +0000 (+0100) Subject: use md5 for hashing ly snippets. This makes snippets lilypond-book X-Git-Tag: release/2.10.2-1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=84efc11f6dfff0d4591e9301bcaa9152eb375657;p=lilypond.git use md5 for hashing ly snippets. This makes snippets lilypond-book documents reproducible across platforms. --- diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 66e0704e69..6699ba2dcb 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -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):