parameters: (repo, revspec)
return_statement: return commits
docstring: Returns the commits in |repo| covered by |revspec|.
docstring_summary: Returns the commits in |repo| covered by |revspec|.
docstring_tokens: Returns the commits in |repo| covered by |revspec| .
function: def Log(repo, revspec):
    """Returns the commits in |repo| covered by |revspec|."""
    # The commit message may not be valid UTF-8, so convert decode errors to
    # replacement characters.
    data = subprocess.check_output(['git', 'log', '--pretty=raw', revspec],
                                   cwd=repo, text=True, errors='replace')
    commits = []
    chunks = data.split('\n\n')
    if len(chunks) % 2 != 0:
      raise ValueError('Invalid log format')
    for i in range(0, len(chunks), 2):
      commit = {}
      # Parse commit properties.
      for line in chunks[i].split('\n'):
        name, value = line.split(' ', 1)
        commit[name] = value
      if 'commit' not in commit:
        raise ValueError('Missing commit line')
      # Parse commit message.
      message = ''
      lines = chunks[i+1].split('\n')
      # Removing the trailing empty entry.
      if lines and not lines[-1]:
        lines.pop()
      for line in lines:
        INDENT = '    '
        if not line.startswith(INDENT):
          raise ValueError('Missing indent')
        message += line[len(INDENT):] + '\n'
      commit['message'] = message
      commits.append(commit)
    return commits
function_tokens: def Log ( repo , revspec ) : # The commit message may not be valid UTF-8, so convert decode errors to # replacement characters. data = subprocess . check_output ( [ 'git' , 'log' , '--pretty=raw' , revspec ] , cwd = repo , text = True , errors = 'replace' ) commits = [ ] chunks = data . split ( '\n\n' ) if len ( chunks ) % 2 != 0 : raise ValueError ( 'Invalid log format' ) for i in range ( 0 , len ( chunks ) , 2 ) : commit = { } # Parse commit properties. for line in chunks [ i ] . split ( '\n' ) : name , value = line . split ( ' ' , 1 ) commit [ name ] = value if 'commit' not in commit : raise ValueError ( 'Missing commit line' ) # Parse commit message. message = '' lines = chunks [ i + 1 ] . split ( '\n' ) # Removing the trailing empty entry. if lines and not lines [ - 1 ] : lines . pop ( ) for line in lines : INDENT = '    ' if not line . startswith ( INDENT ) : raise ValueError ( 'Missing indent' ) message += line [ len ( INDENT ) : ] + '\n' commit [ 'message' ] = message commits . append ( commit ) return commits