mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
setup: upgrade bundled darcsver from 1.6.3 to 1.7.0
ref #1259, we're going to use its 'versionfiles' setup() keyword argument to specify where to write the version file. Remember, we have to bundle darcsver to work-around http://bitbucket.org/tarek/distribute/issue/55/revision-control-plugin-automatically-installed-as-a-build-dependency-is-not-present-when-another-build-dependency-is-being
This commit is contained in:
parent
c14e20c2f8
commit
680e33ef91
@ -1,6 +1,6 @@
|
||||
Metadata-Version: 1.0
|
||||
Name: darcsver
|
||||
Version: 1.6.3
|
||||
Version: 1.7.0
|
||||
Summary: generate a version number from darcs history
|
||||
Home-page: http://tahoe-lafs.org/trac/darcsver
|
||||
Author: Zooko O'Whielacronx
|
@ -6,7 +6,7 @@
|
||||
# pyutil.version_class for a description of what the different fields mean.
|
||||
|
||||
__pkgname__ = "darcsver"
|
||||
verstr = "1.6.3"
|
||||
verstr = "1.7.0"
|
||||
try:
|
||||
from pyutil.version_class import Version as pyutil_Version
|
||||
__version__ = pyutil_Version(verstr)
|
@ -78,6 +78,7 @@ def update(pkgname, verfilename, revision_number=False, loud=False, abort_if_sna
|
||||
verfilenames = [verfilename]
|
||||
else:
|
||||
verfilenames = verfilename
|
||||
assert all([isinstance(vfn, basestring) for vfn in verfilenames]), [vfn for vfn in verfilenames if not isinstance(vfn, basestring)]
|
||||
if isinstance(version_body, basestring):
|
||||
verbodies = [version_body]
|
||||
else:
|
||||
@ -105,7 +106,6 @@ def update(pkgname, verfilename, revision_number=False, loud=False, abort_if_sna
|
||||
cmd = ["changes", "--xml-output"]
|
||||
if not revision_number:
|
||||
cmd.append("--from-tag=^%s" % (pkgname,))
|
||||
errput = None
|
||||
try:
|
||||
p = subprocess.Popen(["darcs"] + cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||
except OSError:
|
||||
@ -115,6 +115,7 @@ def update(pkgname, verfilename, revision_number=False, loud=False, abort_if_sna
|
||||
rc = p.returncode
|
||||
if rc != 0 and errput:
|
||||
log.info("%s: darcs wrote to stderr: '%s'" % (EXE_NAME, errput,))
|
||||
errput = None
|
||||
else:
|
||||
if all([os.path.exists(vfn) for vfn in verfilenames]):
|
||||
log.info("%s: using extant version file %s" % (EXE_NAME, verfilenames))
|
||||
@ -128,48 +129,55 @@ def update(pkgname, verfilename, revision_number=False, loud=False, abort_if_sna
|
||||
allbadchars = "".join([chr(i) for i in range(0x0a) + [0x0b, 0x0c] + range(0x0e, 0x20) + range(0x7f,0x100)])
|
||||
tt = string.maketrans(allbadchars, "-"*len(allbadchars))
|
||||
output = output.translate(tt)
|
||||
regexstr = "^TAG %s-(%s)$" % (pkgname, VERSION_BASE_RE_STR)
|
||||
last_tag = None
|
||||
|
||||
# strip off trailing warning messages that darcs 2.3.1 writes to stdout
|
||||
endi = output.find("</changelog>")+len("</changelog>")
|
||||
output = output[:endi]
|
||||
doc = xml.dom.minidom.parseString(output)
|
||||
|
||||
changelog = doc.getElementsByTagName("changelog")[0]
|
||||
patches = changelog.getElementsByTagName("patch")
|
||||
regexstr = "^TAG %s-(%s)$" % (pkgname, VERSION_BASE_RE_STR)
|
||||
version_re = re.compile(regexstr)
|
||||
last_tag = None
|
||||
count_since_last_patch = 0
|
||||
if abort_if_snapshot:
|
||||
for patch in patches:
|
||||
name = get_text(patch.getElementsByTagName("name")[0].childNodes)
|
||||
m = version_re.match(name)
|
||||
if m:
|
||||
last_tag = m.group(1)
|
||||
last_tag = last_tag.encode("utf-8")
|
||||
break
|
||||
else:
|
||||
sys.exit(0) # because abort_if_snapshot
|
||||
if endi != -1:
|
||||
output = output[:endi]
|
||||
try:
|
||||
doc = xml.dom.minidom.parseString(output)
|
||||
except xml.parsers.expat.ExpatError:
|
||||
# Okay maybe this is an error message instead of an XML output.
|
||||
pass
|
||||
else:
|
||||
for patch in patches:
|
||||
name = get_text(patch.getElementsByTagName("name")[0].childNodes)
|
||||
m = version_re.match(name)
|
||||
if m:
|
||||
last_tag = m.group(1)
|
||||
last_tag = last_tag.encode("utf-8")
|
||||
break
|
||||
else:
|
||||
count_since_last_patch += 1
|
||||
changelog = doc.getElementsByTagName("changelog")[0]
|
||||
patches = changelog.getElementsByTagName("patch")
|
||||
version_re = re.compile(regexstr)
|
||||
count_since_last_patch = 0
|
||||
if abort_if_snapshot:
|
||||
for patch in patches:
|
||||
name = get_text(patch.getElementsByTagName("name")[0].childNodes)
|
||||
m = version_re.match(name)
|
||||
if m:
|
||||
last_tag = m.group(1)
|
||||
last_tag = last_tag.encode("utf-8")
|
||||
break
|
||||
else:
|
||||
sys.exit(0) # because abort_if_snapshot
|
||||
else:
|
||||
for patch in patches:
|
||||
name = get_text(patch.getElementsByTagName("name")[0].childNodes)
|
||||
m = version_re.match(name)
|
||||
if m:
|
||||
last_tag = m.group(1)
|
||||
last_tag = last_tag.encode("utf-8")
|
||||
break
|
||||
else:
|
||||
count_since_last_patch += 1
|
||||
|
||||
if not last_tag:
|
||||
if errput:
|
||||
log.info("%s: darcs wrote to stderr: '%s'" % (EXE_NAME, errput,))
|
||||
errput = None
|
||||
assert all([isinstance(vfn, basestring) for vfn in verfilenames]), [vfn for vfn in verfilenames if not isinstance(vfn, basestring)]
|
||||
if all([os.path.exists(vfn) for vfn in verfilenames]):
|
||||
log.warn("%s: I'm unable to find a tag in the darcs history matching \"%s\", so I'm leaving %s alone." % (EXE_NAME, regexstr, verfilenames,))
|
||||
return (0, read_version_py(verfilenames[0]))
|
||||
else:
|
||||
log.warn("%s: I'm unable to find a tag in the darcs history matching \"%s\", and %s don't exist." % (EXE_NAME, regexstr, verfilenames,))
|
||||
return (0, None)
|
||||
return (-1, None)
|
||||
|
||||
if revision_number:
|
||||
if count_since_last_patch:
|
@ -46,14 +46,14 @@ class DarcsVer(setuptools.Command):
|
||||
description = "generate a version number from darcs history"
|
||||
user_options = [
|
||||
('project-name', None, "name of the project as it appears in the project's release tags (default's the to the distribution name)"),
|
||||
('version-file', None, "path to file into which the version number should be written (defaults to the package directory's _version.py)"),
|
||||
('filename', None, "path to file into which the version number should be written (defaults to the package directory's _version.py)"),
|
||||
('count-all-patches', None, "If true, count the total number of patches in all history. If false, count the total number of patches since the most recent release tag."),
|
||||
('abort-if-snapshot', None, "If true, the if the current version is a snapshot (not a release tag), then immediately exit the process with exit code 0."),
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
self.project_name = None
|
||||
self.version_file = None
|
||||
self.filename = None
|
||||
self.count_all_patches = None
|
||||
self.abort_if_snapshot = None
|
||||
|
||||
@ -61,10 +61,12 @@ class DarcsVer(setuptools.Command):
|
||||
if self.project_name is None:
|
||||
self.project_name = self.distribution.get_name()
|
||||
|
||||
# If the user passed --version-file on the cmdline, override
|
||||
# If the user passed --filename on the cmdline, override
|
||||
# the setup.py's versionfiles argument.
|
||||
if self.version_file is not None:
|
||||
self.distribution.versionfiles = [self.version_file]
|
||||
if self.filename is not None:
|
||||
if not isinstance(self.filename, basestring):
|
||||
raise TypeError("filename is required to be a string, not %s, filename: %s" % (type(self.filename), self.filename))
|
||||
self.distribution.versionfiles = [self.filename]
|
||||
|
||||
if self.abort_if_snapshot is None:
|
||||
self.abort_if_snapshot=False
|
||||
@ -112,5 +114,7 @@ class DarcsVer(setuptools.Command):
|
||||
if self.distribution.versionbodies is None:
|
||||
self.distribution.versionbodies = [PYTHON_VERSION_BODY]
|
||||
|
||||
assert all([isinstance(vfn, basestring) for vfn in self.distribution.versionfiles]), self.distribution.versionfiles
|
||||
(rc, verstr) = darcsvermodule.update(self.project_name, self.distribution.versionfiles, self.count_all_patches, abort_if_snapshot=self.abort_if_snapshot, EXE_NAME="setup.py darcsver", version_body=self.distribution.versionbodies)
|
||||
self.distribution.metadata.version = verstr
|
||||
if rc == 0:
|
||||
self.distribution.metadata.version = verstr
|
Loading…
Reference in New Issue
Block a user