Don't allow unversioned migrationitems to be hashed

Unversioned migration items match different versioned items for the same
source, so hashing them will not produce a correct result.

Closes: #945471
ubuntu/rebased
Ivo De Decker 5 years ago
parent 18f71a01f5
commit 62c309da07

@ -83,7 +83,8 @@ class Hint(object):
if self.type != other.type:
return False
else:
return frozenset(self.packages) == frozenset(other.packages)
# we can't use sets, because unversioned items cannot be hashed
return sorted(self.packages) == sorted(other.packages)
@property
def type(self):

@ -76,6 +76,10 @@ class MigrationItem(object):
return isequal
def __hash__(self):
if not self.version:
raise AssertionError("trying to hash unversioned MigrationItem: %s" %
(self.name))
return hash((self.uvname, self.version))
def __lt__(self, other):

Loading…
Cancel
Save