From 680e33ef9119320b7cb217a7a54940a554747636 Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Sat, 13 Nov 2010 23:39:54 -0800 Subject: [PATCH] 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 --- .../EGG-INFO/PKG-INFO | 2 +- .../EGG-INFO/SOURCES.txt | 0 .../EGG-INFO/dependency_links.txt | 0 .../EGG-INFO/entry_points.txt | 0 .../EGG-INFO/not-zip-safe | 0 .../EGG-INFO/top_level.txt | 0 .../darcsver/__init__.py | 0 .../darcsver/_version.py | 2 +- .../darcsver/darcsvermodule.py | 68 +++++++++++-------- .../darcsver/setuptools_command.py | 16 +++-- .../scripts/__init__.py | 0 .../scripts/darcsverscript.py | 0 .../share/doc/python-darcsver/README.txt | 0 13 files changed, 50 insertions(+), 38 deletions(-) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/EGG-INFO/PKG-INFO (99%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/EGG-INFO/SOURCES.txt (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/EGG-INFO/dependency_links.txt (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/EGG-INFO/entry_points.txt (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/EGG-INFO/not-zip-safe (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/EGG-INFO/top_level.txt (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/darcsver/__init__.py (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/darcsver/_version.py (98%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/darcsver/darcsvermodule.py (80%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/darcsver/setuptools_command.py (87%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/scripts/__init__.py (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/scripts/darcsverscript.py (100%) rename {darcsver-1.6.3.egg => darcsver-1.7.0.egg}/share/doc/python-darcsver/README.txt (100%) diff --git a/darcsver-1.6.3.egg/EGG-INFO/PKG-INFO b/darcsver-1.7.0.egg/EGG-INFO/PKG-INFO similarity index 99% rename from darcsver-1.6.3.egg/EGG-INFO/PKG-INFO rename to darcsver-1.7.0.egg/EGG-INFO/PKG-INFO index 0bee80ff..cf6a8e75 100644 --- a/darcsver-1.6.3.egg/EGG-INFO/PKG-INFO +++ b/darcsver-1.7.0.egg/EGG-INFO/PKG-INFO @@ -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 diff --git a/darcsver-1.6.3.egg/EGG-INFO/SOURCES.txt b/darcsver-1.7.0.egg/EGG-INFO/SOURCES.txt similarity index 100% rename from darcsver-1.6.3.egg/EGG-INFO/SOURCES.txt rename to darcsver-1.7.0.egg/EGG-INFO/SOURCES.txt diff --git a/darcsver-1.6.3.egg/EGG-INFO/dependency_links.txt b/darcsver-1.7.0.egg/EGG-INFO/dependency_links.txt similarity index 100% rename from darcsver-1.6.3.egg/EGG-INFO/dependency_links.txt rename to darcsver-1.7.0.egg/EGG-INFO/dependency_links.txt diff --git a/darcsver-1.6.3.egg/EGG-INFO/entry_points.txt b/darcsver-1.7.0.egg/EGG-INFO/entry_points.txt similarity index 100% rename from darcsver-1.6.3.egg/EGG-INFO/entry_points.txt rename to darcsver-1.7.0.egg/EGG-INFO/entry_points.txt diff --git a/darcsver-1.6.3.egg/EGG-INFO/not-zip-safe b/darcsver-1.7.0.egg/EGG-INFO/not-zip-safe similarity index 100% rename from darcsver-1.6.3.egg/EGG-INFO/not-zip-safe rename to darcsver-1.7.0.egg/EGG-INFO/not-zip-safe diff --git a/darcsver-1.6.3.egg/EGG-INFO/top_level.txt b/darcsver-1.7.0.egg/EGG-INFO/top_level.txt similarity index 100% rename from darcsver-1.6.3.egg/EGG-INFO/top_level.txt rename to darcsver-1.7.0.egg/EGG-INFO/top_level.txt diff --git a/darcsver-1.6.3.egg/darcsver/__init__.py b/darcsver-1.7.0.egg/darcsver/__init__.py similarity index 100% rename from darcsver-1.6.3.egg/darcsver/__init__.py rename to darcsver-1.7.0.egg/darcsver/__init__.py diff --git a/darcsver-1.6.3.egg/darcsver/_version.py b/darcsver-1.7.0.egg/darcsver/_version.py similarity index 98% rename from darcsver-1.6.3.egg/darcsver/_version.py rename to darcsver-1.7.0.egg/darcsver/_version.py index 9d41f7dd..a3b174f3 100644 --- a/darcsver-1.6.3.egg/darcsver/_version.py +++ b/darcsver-1.7.0.egg/darcsver/_version.py @@ -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) diff --git a/darcsver-1.6.3.egg/darcsver/darcsvermodule.py b/darcsver-1.7.0.egg/darcsver/darcsvermodule.py similarity index 80% rename from darcsver-1.6.3.egg/darcsver/darcsvermodule.py rename to darcsver-1.7.0.egg/darcsver/darcsvermodule.py index 4f03572e..8f00205b 100644 --- a/darcsver-1.6.3.egg/darcsver/darcsvermodule.py +++ b/darcsver-1.7.0.egg/darcsver/darcsvermodule.py @@ -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("")+len("") - 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: diff --git a/darcsver-1.6.3.egg/darcsver/setuptools_command.py b/darcsver-1.7.0.egg/darcsver/setuptools_command.py similarity index 87% rename from darcsver-1.6.3.egg/darcsver/setuptools_command.py rename to darcsver-1.7.0.egg/darcsver/setuptools_command.py index 44fd50c7..e90db85e 100644 --- a/darcsver-1.6.3.egg/darcsver/setuptools_command.py +++ b/darcsver-1.7.0.egg/darcsver/setuptools_command.py @@ -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 diff --git a/darcsver-1.6.3.egg/scripts/__init__.py b/darcsver-1.7.0.egg/scripts/__init__.py similarity index 100% rename from darcsver-1.6.3.egg/scripts/__init__.py rename to darcsver-1.7.0.egg/scripts/__init__.py diff --git a/darcsver-1.6.3.egg/scripts/darcsverscript.py b/darcsver-1.7.0.egg/scripts/darcsverscript.py similarity index 100% rename from darcsver-1.6.3.egg/scripts/darcsverscript.py rename to darcsver-1.7.0.egg/scripts/darcsverscript.py diff --git a/darcsver-1.6.3.egg/share/doc/python-darcsver/README.txt b/darcsver-1.7.0.egg/share/doc/python-darcsver/README.txt similarity index 100% rename from darcsver-1.6.3.egg/share/doc/python-darcsver/README.txt rename to darcsver-1.7.0.egg/share/doc/python-darcsver/README.txt -- 2.45.2