parameters: (input_api, output_api, source_file_filter)
return_statement: return results
docstring: Runs checkdeps on #include statements added in this
    change. Breaking - rules is an error, breaking ! rules is a
    warning.
docstring_summary: Runs checkdeps on #include statements added in this
    change. Breaking - rules is an error, breaking ! rules is a
    warning.
docstring_tokens: Runs checkdeps on #include statements added in this change . Breaking - rules is an error breaking ! rules is a warning .
function: def CheckUnwantedDependencies(input_api, output_api, source_file_filter):
      """Runs checkdeps on #include statements added in this
    change. Breaking - rules is an error, breaking ! rules is a
    warning.
    """
      # Copied from Chromium's src/PRESUBMIT.py.
  
      # We need to wait until we have an input_api object and use this
      # roundabout construct to import checkdeps because this file is
      # eval-ed and thus doesn't have __file__.
      src_path = FindSrcDirPath(input_api.PresubmitLocalPath())
      checkdeps_path = input_api.os_path.join(src_path, 'buildtools',
                                              'checkdeps')
      if not os.path.exists(checkdeps_path):
          return [
              output_api.PresubmitError(
                  'Cannot find checkdeps at %s\nHave you run "gclient sync" to '
                  'download all the DEPS entries?' % checkdeps_path)
          ]
      with _AddToPath(checkdeps_path):
          import checkdeps
          from cpp_checker import CppChecker
          from rules import Rule
  
      added_includes = []
      for f in input_api.AffectedFiles(file_filter=source_file_filter):
          if not CppChecker.IsCppFile(f.LocalPath()):
              continue
  
          changed_lines = [line for _, line in f.ChangedContents()]
          added_includes.append([f.LocalPath(), changed_lines])
  
      deps_checker = checkdeps.DepsChecker(input_api.PresubmitLocalPath())
  
      error_descriptions = []
      warning_descriptions = []
      for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes(
              added_includes):
          description_with_path = '%s\n    %s' % (path, rule_description)
          if rule_type == Rule.DISALLOW:
              error_descriptions.append(description_with_path)
          else:
              warning_descriptions.append(description_with_path)
  
      results = []
      if error_descriptions:
          results.append(
              output_api.PresubmitError(
                  'You added one or more #includes that violate checkdeps rules.\n'
                  'Check that the DEPS files in these locations contain valid rules.\n'
                  'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for '
                  'more details about checkdeps.', error_descriptions))
      if warning_descriptions:
          results.append(
              output_api.PresubmitPromptOrNotify(
                  'You added one or more #includes of files that are temporarily\n'
                  'allowed but being removed. Can you avoid introducing the\n'
                  '#include? See relevant DEPS file(s) for details and contacts.\n'
                  'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for '
                  'more details about checkdeps.', warning_descriptions))
      return results
function_tokens: def CheckUnwantedDependencies ( input_api , output_api , source_file_filter ) : # Copied from Chromium's src/PRESUBMIT.py. # We need to wait until we have an input_api object and use this # roundabout construct to import checkdeps because this file is # eval-ed and thus doesn't have __file__. src_path = FindSrcDirPath ( input_api . PresubmitLocalPath ( ) ) checkdeps_path = input_api . os_path . join ( src_path , 'buildtools' , 'checkdeps' ) if not os . path . exists ( checkdeps_path ) : return [ output_api . PresubmitError ( 'Cannot find checkdeps at %s\nHave you run "gclient sync" to ' 'download all the DEPS entries?' % checkdeps_path ) ] with _AddToPath ( checkdeps_path ) : import checkdeps from cpp_checker import CppChecker from rules import Rule added_includes = [ ] for f in input_api . AffectedFiles ( file_filter = source_file_filter ) : if not CppChecker . IsCppFile ( f . LocalPath ( ) ) : continue changed_lines = [ line for _ , line in f . ChangedContents ( ) ] added_includes . append ( [ f . LocalPath ( ) , changed_lines ] ) deps_checker = checkdeps . DepsChecker ( input_api . PresubmitLocalPath ( ) ) error_descriptions = [ ] warning_descriptions = [ ] for path , rule_type , rule_description in deps_checker . CheckAddedCppIncludes ( added_includes ) : description_with_path = '%s\n    %s' % ( path , rule_description ) if rule_type == Rule . DISALLOW : error_descriptions . append ( description_with_path ) else : warning_descriptions . append ( description_with_path ) results = [ ] if error_descriptions : results . append ( output_api . PresubmitError ( 'You added one or more #includes that violate checkdeps rules.\n' 'Check that the DEPS files in these locations contain valid rules.\n' 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for ' 'more details about checkdeps.' , error_descriptions ) ) if warning_descriptions : results . append ( output_api . PresubmitPromptOrNotify ( 'You added one or more #includes of files that are temporarily\n' 'allowed but being removed. Can you avoid introducing the\n' '#include? See relevant DEPS file(s) for details and contacts.\n' 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for ' 'more details about checkdeps.' , warning_descriptions ) ) return results