Commit e0554edb authored by Tim Peters's avatar Tim Peters
Browse files

Since we always fail to update some version number in each

release, tried to make this script much more robust.  Use
r-strings for regexps.  Junk unnecessary code that a Unixhead
probably thought was needed for Windows (replacing forward
slashes in filepaths -- Windows accepts those too).  Made
the search criteria for NEWS.txt much looser (this is the
one we seem to blow most often).  Changed replace() in
several ways:  only replace the first occurrence of the
pattern (we never need more than that, and looser searches
are dangerous when replacing all occurrences); provide
feedback on everything done; if the pattern isn't found
at all, print a noisy msg saying so.  Completed the list
of modified files in the module docstring.
parent 40e080c2
...@@ -7,22 +7,38 @@ version should be a string like "3.2c1" ...@@ -7,22 +7,38 @@ version should be a string like "3.2c1"
date should be a string like "23-Sep-2003" date should be a string like "23-Sep-2003"
The following files are updated: The following files are updated:
- setup.py gets a version number - setup.py
- NEWS.txt
- doc/guide/zodb.tex
- src/ZEO/__init__.py
- src/ZEO/version.txt
- src/ZODB/__init__.py
""" """
import fileinput import fileinput
import os import os
import re import re
def fixpath(path): # In file filename, replace the first occurrence of regexp pat with
parts = path.split("/") # string repl.
return os.sep.join(parts)
def replace(filename, pat, repl): def replace(filename, pat, repl):
parts = filename.split("/") foundone = False
filename = os.sep.join(parts)
for line in fileinput.input([filename], inplace=True, backup="~"): for line in fileinput.input([filename], inplace=True, backup="~"):
print re.sub(pat, repl, line), if foundone:
print line,
else:
new = re.sub(pat, repl, line)
if new != line:
foundone = True
print "In %r, replaced:" % filename
print " ", line
print "by:"
print " ", new
print new,
if not foundone:
print "*" * 60, "Oops!"
print " Failed to find %r in %r" % (pat, filename)
def compute_zeoversion(version): def compute_zeoversion(version):
# ZEO version's trail ZODB versions by one full revision. # ZEO version's trail ZODB versions by one full revision.
...@@ -32,7 +48,7 @@ def compute_zeoversion(version): ...@@ -32,7 +48,7 @@ def compute_zeoversion(version):
return "%s.%s" % (major, rest) return "%s.%s" % (major, rest)
def write_zeoversion(path, version): def write_zeoversion(path, version):
f = open(fixpath(path), "wb") f = file(path, "w")
print >> f, version print >> f, version
f.close() f.close()
...@@ -40,16 +56,19 @@ def main(args): ...@@ -40,16 +56,19 @@ def main(args):
version, date = args version, date = args
zeoversion = compute_zeoversion(version) zeoversion = compute_zeoversion(version)
replace("setup.py", 'version="\S+"', 'version="%s"' % version) replace("setup.py",
r'version="\S+"',
'version="%s"' % version)
replace("src/ZODB/__init__.py", replace("src/ZODB/__init__.py",
'__version__ = "\S+"', r'__version__ = "\S+"',
'__version__ = "%s"' % version) '__version__ = "%s"' % version)
replace("src/ZEO/__init__.py", replace("src/ZEO/__init__.py",
'version = "\S+"', r'version = "\S+"',
'version = "%s"' % zeoversion) 'version = "%s"' % zeoversion)
write_zeoversion("src/ZEO/version.txt", zeoversion) write_zeoversion("src/ZEO/version.txt", zeoversion)
replace("NEWS.txt", replace("NEWS.txt",
"Release date: XX-\S+-\S+", "Release date: %s" % date) r"^Release date: .*",
"Release date: %s" % date)
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment