diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2018-02-02 21:34:18 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2018-02-02 21:34:18 +0300 |
commit | dd5b9e83d5251aafe6880008b09ef59f9be4b634 (patch) | |
tree | c24535ef04b777159b06d3a34b05f5070e4a1a7f | |
parent | 1ff7fde354b962c91558cf7834487989997b8c38 (diff) |
Also warn about pointless replace-versions: when it's equal to current version
-rwxr-xr-x | calm/package.py | 4 | ||||
-rw-r--r-- | calm/version.py | 12 |
2 files changed, 7 insertions, 9 deletions
diff --git a/calm/package.py b/calm/package.py index 4c263c8..8c45dc0 100755 --- a/calm/package.py +++ b/calm/package.py @@ -653,8 +653,8 @@ def validate_packages(args, packages): if 'replace-versions' in packages[p].override_hints: if packages[p].best_version: for rv in packages[p].override_hints['replace-versions'].split(): - if SetupVersion(rv) < SetupVersion(packages[p].best_version): - logging.warning("package '%s' replace-versions: lists version '%s' which is less than current version" % (p, rv)) + if SetupVersion(rv) <= SetupVersion(packages[p].best_version): + logging.warning("package '%s' replace-versions: uselessly lists version '%s', which is <= current version" % (p, rv)) # If the install tarball is empty and there is no source tarball, we # should probably be marked obsolete diff --git a/calm/version.py b/calm/version.py index f00ddbb..508260e 100644 --- a/calm/version.py +++ b/calm/version.py @@ -21,6 +21,7 @@ # THE SOFTWARE. # +import functools import itertools import re @@ -37,6 +38,7 @@ def cmp(a, b): # a helper class which implements the same version ordering as setup # +@functools.total_ordering class SetupVersion: def __init__(self, version_string): self._version_string = version_string @@ -56,17 +58,13 @@ class SetupVersion: def __str__(self): return '%s (V=%s R=%s)' % (self._version_string, str(self._V), str(self._R)) - # XXX: Implementing the __lt__ comparison operator in terms of the obsolete - # __cmp__ operator is rather over-complicated. If we really only need - # __lt__ (which is sufficent to make this class sortable), then we should - # just implement it directly. For the moment, keep __cmp__ around in case - # we need to do other comparisons. (in which case, see also functools - # @total_ordering class decorator) def __lt__(self, other): return self.__cmp__(other) == -1 - def __cmp__(self, other): + def __eq__(self, other): + return self.__cmp__(other) == 0 + def __cmp__(self, other): # compare V c = SetupVersion._compare(self._V, other._V) if c != 0: |