diff options
author | Julien Rioux <jrioux@physics.utoronto.ca> | 2012-10-05 18:09:48 -0400 |
---|---|---|
committer | Julien Rioux <jrioux@physics.utoronto.ca> | 2012-10-12 15:20:43 -0400 |
commit | 91f8d0ab0bfbd603b8f7801ef9f5c03529cbfa66 (patch) | |
tree | 267eaba73e2bcb8ca0507f87f8041dd0d6558d11 /scripts | |
parent | 36379a15aaee3a4c1fa85f9d37048bd0d4a23b76 (diff) |
convert-ly: Don't update \version when no rule is applied.
Note that this is not the same as what the existing -d
--diff-version-update command does. The behavior of convert-ly is
unchanged when rules are being applied, and -d is still used in the
same way. The change concerns itself only with the case that no rule
applies, because the version of the file is already up-to-date. In
this case, it used to be that the version in the file would be set to
version of the last rule, which would sometimes mean that the version
of the file upon output is lower than the version at input. This is
what we avoid in this patch.
This fixes issue 2670.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/convert-ly.py | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 8795f343ae..e14a137f97 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -185,11 +185,9 @@ string.""" ly.progress (_ ("Applying conversion: "), newline = False) - last_conversion = () + last_conversion = None errors = 0 try: - if not conv_list: - last_conversion = to_version for x in conv_list: if x != conv_list[-1]: ly.progress (tup_to_str (x[0]), newline = False) @@ -260,10 +258,10 @@ def do_one_file (infile_name): (last, result, errors) = do_conversion (input, from_version, to_version) + if global_options.force_current_version and \ + (last is None or last == to_version): + last = str_to_tuple (program_version) if last: - if global_options.force_current_version and last == to_version: - last = str_to_tuple (program_version) - if global_options.diff_version_update: if result == input: # check the y in x.y.z (minor version number) @@ -283,21 +281,20 @@ def do_one_file (infile_name): elif not global_options.skip_version_add: result = newversion + '\n' + result - ly.progress ('\n') - - if global_options.edit: - try: - os.remove(infile_name + '~') - except: - pass - os.rename (infile_name, infile_name + '~') - outfile = open (infile_name, 'w') - else: - outfile = sys.stdout - + ly.progress ('\n') - outfile.write (result) + if global_options.edit: + try: + os.remove (infile_name + '~') + except: + pass + os.rename (infile_name, infile_name + '~') + outfile = open (infile_name, 'w') + else: + outfile = sys.stdout + outfile.write (result) + sys.stderr.flush () return errors |