]> git.donarmstrong.com Git - lilypond.git/commitdiff
Docs: handle file renames in translation checking
authorJohn Mandereau <john.mandereau@gmail.com>
Sun, 9 Aug 2009 09:43:12 +0000 (11:43 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Sun, 9 Aug 2009 16:04:53 +0000 (18:04 +0200)
All renames in documentation in English must be registered manually in
python/auxiliar/buildlib.py.

python/auxiliar/buildlib.py

index 04a72c7924df43b4ed89eb75cab166643b476ff8..5ec022e16af31bc81c285bf5b55c68bab6bb1301 100644 (file)
@@ -19,8 +19,41 @@ 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 = {
+    'application.tely': 'user/lilypond-program.tely',
+    'notation.tely': 'user/lilypond.tely',
+    'learning.tely': 'user/lilypond-learning.tely',
+    'changes.tely': 'topdocs/NEWS.tely',
+}
+
+manuals_subdirectories_re = \
+    re.compile ('(application|essay|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: <hash>' found.
 Please check the whole file against the original in English, then
 fill in HEAD committish in the header.
@@ -38,6 +71,7 @@ def check_translated_doc (original, translated_file, translated_contents,
         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)