tools/symsrc/source_index.py
def IndexFilesFromRepo(
    local_filename, file_list, output_lines, follow_junctions):
  """Checks if a given file is a part of a Git repository  and index all the
  files from this repository if it's the case.

  Args:
    local_filename: The filename of the current file.
    file_list: The list of files that should be indexed.
    output_lines: The source indexing lines that will be appended to the PDB.
    follow_junctions: Indicates if we should try to index the files in a
        junction.

  Returns the number of indexed files.
  """
  indexed_files = 0
  patch_root = None
  # Try to extract the revision info for the current file.
  info = ExtractGitInfo(local_filename)

  # If we haven't been able to find information for this file it might be
  # because its path contains a junction to another directory. It can be the
  # case if you do a Git checkout in C:/real_a/ and you're adding a junction to
  # one of the subdirectories (lets say 'b') of this checkout in another
  # project (e.g. 'C:/a'), so you'll end up with a partial Git checkout in a
  # junction, and any Git command in the path of the junction won't work (or
  # it'll return information related to 'C:/a' instead of 'C:/real_a').
  if not info and follow_junctions:
    real_filename, patch_root, patch_leaf = CheckForJunction(local_filename)
    if real_filename:
      info = ExtractGitInfo(real_filename)

  # Don't try to index the internal sources.
  if not info or ('internal.googlesource.com' in info.repo):
    return 0

  repo = info.repo
  rev = info.rev
  files = info.files
  if patch_root:
    files = [x for x in files if x.startswith(patch_leaf)]
    root_path = patch_root.lower()
  else:
    root_path = info.root_path.lower()

  # Checks if we should index this file and if the source that we'll retrieve
  # will be base64 encoded.
  should_index = False
  base_64 = False
  if repo in REPO_MAP:
    should_index = True
    base_64 = REPO_MAP[repo].get('base64')
  else:
    repo = None

  # Iterates over the files from this repo and index them if needed.
  for file_iter in files:
    current_filename = file_iter.lower()
    full_file_path = os.path.normpath(os.path.join(root_path, current_filename))
    # Checks if the file is in the list of files to be indexed.
    if full_file_path in file_list:
      if should_index:
        source_url = ''
        current_file = file_iter
        # Prefix the filename with the prefix for this repository if needed.
        if info.path_prefix:
          current_file = os.path.join(info.path_prefix, current_file)
        source_url = REPO_MAP[repo].get('url').format(revision=rev,
            file_path=os.path.normpath(current_file).replace('\\', '/'))
        output_lines.append('%s*%s*%s*%s*%s' % (full_file_path, current_file,
            rev, source_url, 'base64.b64decode' if base_64 else ''))
        indexed_files += 1
        file_list.remove(full_file_path)

  # The input file should have been removed from the list of files to index.
  if indexed_files and local_filename in file_list:
    print('%s shouldn\'t be in the list of files to index anymore.' % \
        local_filename)
    # TODO(sebmarchand): Turn this into an exception once I've confirmed that
    #     this doesn't happen on the official builder.
    file_list.remove(local_filename)

  return indexed_files
Checks if a given file is a part of a Git repository  and index all the
  files from this repository if it's the case.

  Args:
    local_filename: The filename of the current file.
    file_list: The list of files that should be indexed.
    output_lines: The source indexing lines that will be appended to the PDB.
    follow_junctions: Indicates if we should try to index the files in a
        junction.

  Returns the number of indexed files.
  
Checks if a given file is a part of a Git repository  and index all the
files from this repository if it's the case.
Checks if a given file is a part of a Git repository and index all the files from this repository if it ' s the case .
def IndexFilesFromRepo(
    local_filename, file_list, output_lines, follow_junctions):
  indexed_files = 0
  patch_root = None
  info = ExtractGitInfo(local_filename)
  if not info and follow_junctions:
    real_filename, patch_root, patch_leaf = CheckForJunction(local_filename)
    if real_filename:
      info = ExtractGitInfo(real_filename)
  if not info or ('internal.googlesource.com' in info.repo):
    return 0
  repo = info.repo
  rev = info.rev
  files = info.files
  if patch_root:
    files = [x for x in files if x.startswith(patch_leaf)]
    root_path = patch_root.lower()
  else:
    root_path = info.root_path.lower()
  should_index = False
  base_64 = False
  if repo in REPO_MAP:
    should_index = True
    base_64 = REPO_MAP[repo].get('base64')
  else:
    repo = None
  for file_iter in files:
    current_filename = file_iter.lower()
    full_file_path = os.path.normpath(os.path.join(root_path, current_filename))
    if full_file_path in file_list:
      if should_index:
        source_url = ''
        current_file = file_iter
        if info.path_prefix:
          current_file = os.path.join(info.path_prefix, current_file)
        source_url = REPO_MAP[repo].get('url').format(revision=rev,
            file_path=os.path.normpath(current_file).replace('\\', '/'))
        output_lines.append('%s*%s*%s*%s*%s' % (full_file_path, current_file,
            rev, source_url, 'base64.b64decode' if base_64 else ''))
        indexed_files += 1
        file_list.remove(full_file_path)
  if indexed_files and local_filename in file_list:
    print('%s shouldn\'t be in the list of files to index anymore.' % \
        local_filename)
    file_list.remove(local_filename)
  return indexed_files
def IndexFilesFromRepo ( local_filename , file_list , output_lines , follow_junctions ) : indexed_files = 0 patch_root = None info = ExtractGitInfo ( local_filename ) if not info and follow_junctions : real_filename , patch_root , patch_leaf = CheckForJunction ( local_filename ) if real_filename : info = ExtractGitInfo ( real_filename ) if not info or ( 'internal.googlesource.com' in info . repo ) : return 0 repo = info . repo rev = info . rev files = info . files if patch_root : files = [ x for x in files if x . startswith ( patch_leaf ) ] root_path = patch_root . lower ( ) else : root_path = info . root_path . lower ( ) should_index = False base_64 = False if repo in REPO_MAP : should_index = True base_64 = REPO_MAP [ repo ] . get ( 'base64' ) else : repo = None for file_iter in files : current_filename = file_iter . lower ( ) full_file_path = os . path . normpath ( os . path . join ( root_path , current_filename ) ) if full_file_path in file_list : if should_index : source_url = '' current_file = file_iter if info . path_prefix : current_file = os . path . join ( info . path_prefix , current_file ) source_url = REPO_MAP [ repo ] . get ( 'url' ) . format ( revision = rev , file_path = os . path . normpath ( current_file ) . replace ( '\\' , '/' ) ) output_lines . append ( '%s*%s*%s*%s*%s' % ( full_file_path , current_file , rev , source_url , 'base64.b64decode' if base_64 else '' ) ) indexed_files += 1 file_list . remove ( full_file_path ) if indexed_files and local_filename in file_list : print ( '%s shouldn\'t be in the list of files to index anymore.' % local_filename ) file_list . remove ( local_filename ) return indexed_files
Checks if a given file is a part of a Git repository  and index all the
files from this repository if it's the case.
Checks if a given file is a part of a Git repository and index all the files from this repository if it ' s the case .
"""Checks if a given file is a part of a Git repository  and index all the
  files from this repository if it's the case.

  Args:
    local_filename: The filename of the current file.
    file_list: The list of files that should be indexed.
    output_lines: The source indexing lines that will be appended to the PDB.
    follow_junctions: Indicates if we should try to index the files in a
        junction.

  Returns the number of indexed files.
  """ # Try to extract the revision info for the current file. # If we haven't been able to find information for this file it might be # because its path contains a junction to another directory. It can be the # case if you do a Git checkout in C:/real_a/ and you're adding a junction to # one of the subdirectories (lets say 'b') of this checkout in another # project (e.g. 'C:/a'), so you'll end up with a partial Git checkout in a # junction, and any Git command in the path of the junction won't work (or # it'll return information related to 'C:/a' instead of 'C:/real_a'). # Don't try to index the internal sources. # Checks if we should index this file and if the source that we'll retrieve # will be base64 encoded. # Iterates over the files from this repo and index them if needed. # Checks if the file is in the list of files to be indexed. # Prefix the filename with the prefix for this repository if needed. # The input file should have been removed from the list of files to index. # TODO(sebmarchand): Turn this into an exception once I've confirmed that #     this doesn't happen on the official builder.
local_filename
The filename of the current file.
The filename of the current file .
file_list
The list of files that should be indexed.
The list of files that should be indexed .
output_lines
The source indexing lines that will be appended to the PDB.
The source indexing lines that will be appended to the PDB .
follow_junctions
Indicates if we should try to index the files in a
junction.
Indicates if we should try to index the files in a junction .