def _scheck_imports(importing_suite, imported_suite, suite_import, bookmark_imports, ignore_uncommitted):
importedVersion = imported_suite.version()
if imported_suite.isDirty() and not ignore_uncommitted:
msg = 'uncommitted changes in {}, please commit them and re-run scheckimports'.format(imported_suite.name)
if isinstance(imported_suite, SourceSuite) and imported_suite.vc and imported_suite.vc.kind == 'hg':
msg = '{}\nIf the only uncommitted change is an updated imported suite version, then you can run:\n\nhg -R {} commit -m "updated imported suite version"'.format(msg, imported_suite.vc_dir)
abort(msg)
if importedVersion != suite_import.version and suite_import.version is not None:
print 'imported version of {} in {} ({}) does not match parent ({})'.format(imported_suite.name, importing_suite.name, suite_import.version, importedVersion)
if exists(importing_suite.suite_py()) and ask_yes_no('Update ' + importing_suite.suite_py()):
with open(importing_suite.suite_py()) as fp:
contents = fp.read()
if contents.count(str(suite_import.version)) == 1:
newContents = contents.replace(suite_import.version, str(importedVersion))
if not update_file(importing_suite.suite_py(), newContents, showDiff=True):
abort("Updating {} failed: update didn't change anything".format(importing_suite.suite_py()))
suite_import.version = importedVersion
if bookmark_imports:
_sbookmark_visitor(importing_suite, suite_import)
else:
print 'Could not update as the substring {} does not appear exactly once in {}'.format(suite_import.version, importing_suite.suite_py())
评论列表
文章目录