X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fauxiliar%2Fbuildlib.py;h=a2a553aa04f8d4edcf94f1d5d10038d28548f15d;hb=dbec1f388833bc7dfc8fc91d730018782062bdcc;hp=04a72c7924df43b4ed89eb75cab166643b476ff8;hpb=cfbe8689b937bddd0d977e622b0954046cf8bdb9;p=lilypond.git diff --git a/python/auxiliar/buildlib.py b/python/auxiliar/buildlib.py index 04a72c7924..a2a553aa04 100644 --- a/python/auxiliar/buildlib.py +++ b/python/auxiliar/buildlib.py @@ -19,8 +19,42 @@ def read_pipe (command): error = code + ' ' + error return (output, error) +### Renamed files map to ensure continuity of file history +## Map of new_name: old_name +renames_map = { + 'usage.tely': 'user/lilypond-program.tely', + 'notation.tely': 'user/lilypond.tely', + 'learning.tely': 'user/lilypond-learning.tely', + 'changes.tely': 'topdocs/NEWS.tely', +} + +# FIXME: Hardcoded file names!? +manuals_subdirectories_re = \ + re.compile ('(usage|automated-engraving|changes|essay|extending|web|learning|notation)/') + +def add_old_name (file_path): + for new_path in renames_map: + if file_path.endswith (new_path): + old_file_path = file_path.replace (new_path, + renames_map[new_path]) + break + else: + if file_path.endswith ('macros.itexi'): + old_file_path = file_path.replace ('macros.itexi', + 'user/macros.itexi') + elif file_path.endswith ('.itely'): + old_file_path = manuals_subdirectories_re.sub ('user/', + file_path) + elif 'snippets/' in file_path: + old_file_path = file_path.replace ('snippets/', + '../input/lsr/') + else: + return file_path + return file_path + ' ' + old_file_path + revision_re = re.compile ('GIT [Cc]ommittish:\s+([a-f0-9]+)') -vc_diff_cmd = 'git diff --patience -M %(color_flag)s %(revision)s %(upper_revision)s -- %(original)s | cat' +vc_diff_cmd = 'git diff -M %(color_flag)s %(revision)s \ +%(upper_revision)s -- %(original_with_old_name)s | cat' no_committish_fatal_error = """error: %s: no 'GIT committish: ' found. Please check the whole file against the original in English, then fill in HEAD committish in the header. @@ -33,11 +67,14 @@ def check_translated_doc (original, translated_file, translated_contents, sys.stderr.write (no_committish_fatal_error % translated_file) sys.exit (1) revision = m.group (1) + if revision == '0': + return '', 0 if color: color_flag = '--color --color-words' else: color_flag = '--no-color' + original_with_old_name = add_old_name (original) c = vc_diff_cmd % vars () if verbose: sys.stderr.write ('running: ' + c)