Commit 24d07ff0 authored by ntome's avatar ntome

tools/stable_backport: force manual backports to be reimported

parent 30685e73
......@@ -147,6 +147,11 @@ class ImportErrorError(Error):
self.reimport_module(module)
class ManualBackport(Error):
def fixup(self):
self.reimport_module(self.message)
def replace_all(expr, dest):
system(r"""for file in $(git ls-files modules | grep '\.py$');
do
......@@ -195,6 +200,21 @@ class StableBackport(object):
dirnames[path.dirname(filename)].append(self.errors[error](filename, linenum, msg))
with log('Searching manual backports'):
for manual in MANUAL_PORTS:
r = check_output("grep -nEr '^from %s import ' modules" % manual, shell=True).strip().decode('utf-8')
for line in r.split('\n'):
m = re.match(r'([\w\./]+):(\d+):.*', line)
filename = m.group(1)
linenum = m.group(2)
target = dirnames[path.dirname(filename)]
for err in target:
if err.filename == filename and err.linenum == linenum:
# an error was already spot on this line
break
else:
target.append(ManualBackport(filename, linenum, manual))
for dirname, errors in sorted(dirnames.items()):
with log('Fixing up %s errors in %s' % (colored(str(len(errors)), 'magenta'),
colored(dirname, 'yellow'))):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment