Skip to content

Apache Lucene open-source search software

Improve addVersion.py: in Version.java, remove 'Use this to get the latest...' from the previous LATEST, and add it to the new LATEST

Steve Rowe04a133f9cc3e
diff --git a/dev-tools/scripts/addVersion.py b/dev-tools/scripts/addVersion.py
index 414e4a12a5c..12769a7a7a1 100644
--- a/dev-tools/scripts/addVersion.py
+++ b/dev-tools/scripts/addVersion.py
@@ -48,28 +48,36 @@ def add_constant(new_version, deprecate):
last = buffer[-1]
if last.strip() != '@Deprecated':
spaces = ' ' * (len(last) - len(last.lstrip()) - 1)
- buffer[-1] = spaces + (' * @deprecated (%s) Use latest\n' % new_version)
- buffer.append(spaces + ' */\n')
- buffer.append(spaces + '@Deprecated\n')
+ del buffer[-1] # Remove comment closer line
+ if (len(buffer) >= 4 and re.search('for Lucene.\s*$', buffer[-1]) != None):
+ del buffer[-3:] # drop the trailing lines '<p> / Use this to get the latest ... / ... for Lucene.'
+ buffer.append(( '{0} * @deprecated ({1}) Use latest\n'
+ + '{0} */\n'
+ + '{0}@Deprecated\n').format(spaces, new_version))
def buffer_constant(buffer, line):
spaces = ' ' * (len(line) - len(line.lstrip()))
- buffer.append('\n' + spaces + '/**\n')
- buffer.append(spaces + ' * Match settings and bugs in Lucene\'s %s release.\n' % new_version)
+ buffer.append(( '\n{0}/**\n'
+ + '{0} * Match settings and bugs in Lucene\'s {1} release.\n')
+ .format(spaces, new_version))
if deprecate:
- buffer.append(spaces + ' * @deprecated Use latest\n')
- buffer.append(spaces + ' */\n')
+ buffer.append('%s * @deprecated Use latest\n' % spaces)
+ else:
+ buffer.append(( '{0} * <p>\n'
+ + '{0} * Use this to get the latest &amp; greatest settings, bug\n'
+ + '{0} * fixes, etc, for Lucene.\n').format(spaces))
+ buffer.append('%s */\n' % spaces)
if deprecate:
- buffer.append(spaces + '@Deprecated\n')
- buffer.append(spaces + 'public static final Version %s = new Version(%d, %d, %d);\n' %
- (new_version.constant, new_version.major, new_version.minor, new_version.bugfix))
+ buffer.append('%s@Deprecated\n' % spaces)
+ buffer.append('{0}public static final Version {1} = new Version({2}, {3}, {4});\n'.format
+ (spaces, new_version.constant, new_version.major, new_version.minor, new_version.bugfix))
class Edit(object):
found = -1
def __call__(self, buffer, match, line):
if new_version.constant in line:
return None # constant already exists
- # outter match is just to find lines declaring version constants
+ # outer match is just to find lines declaring version constants
match = prev_matcher.search(line)
if match is not None:
ensure_deprecated(buffer) # old version should be deprecated