patch cache: fix bug finding inherited packages (#29574)

This commit is contained in:
Greg Becker 2022-03-30 05:19:52 -07:00 committed by GitHub
parent d13c1cfa9f
commit 58a32b04d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -400,6 +400,21 @@ def fullname(self):
"""Name of this package, including the namespace"""
return '%s.%s' % (self.namespace, self.name)
@property
def fullnames(self):
"""
Fullnames for this package and any packages from which it inherits.
"""
fullnames = []
for cls in inspect.getmro(self):
namespace = getattr(cls, 'namespace', None)
if namespace:
fullnames.append('%s.%s' % (namespace, self.name))
if namespace == 'builtin':
# builtin packages cannot inherit from other repos
break
return fullnames
@property
def name(self):
"""The name of this package.
@ -911,6 +926,10 @@ def fullname(self):
"""Name of this package, including namespace: namespace.name."""
return type(self).fullname
@property
def fullnames(self):
return type(self).fullnames
@property
def name(self):
"""Name of this package (the module without parent modules)."""

View File

@ -368,8 +368,12 @@ def patch_for_package(self, sha256, pkg):
"Couldn't find patch for package %s with sha256: %s"
% (pkg.fullname, sha256))
patch_dict = sha_index.get(pkg.fullname)
if not patch_dict:
# Find patches for this class or any class it inherits from
for fullname in pkg.fullnames:
patch_dict = sha_index.get(fullname)
if patch_dict:
break
else:
raise NoSuchPatchError(
"Couldn't find patch for package %s with sha256: %s"
% (pkg.fullname, sha256))