summaryrefslogtreecommitdiffstats
path: root/tools/findit/repository_parser_interface.py
blob: aca4c62b9c844f8888030fb8a53dc2f8cc537932 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (c) 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


class ParserInterface(object):
  """The interface for parsers."""

  def ParseChangelog(self, component_path, range_start, range_end):
    """Parses changelog from the URL stored in the parser object.

    Args:
      component_path: A string, path of the component. Path is used because
                      path is unique while component name is not.
      range_start: The start range of the regression.
      range_end: The end range of the regression.

    Returns:
      A tuple containing revision_map and file_to_revision_map,
      revision_map maps a CL number to a dictionary containing revision
      information such as author, commit message and the revision url.
      file_to_revision_map maps a name of a file to a tuple containing the CL
      number and path of the file that CL changes.
    """
    raise NotImplementedError()

  def ParseLineDiff(self, path, component, file_action, githash):
    """Parses the line diff of the given hash.

    Args:
      path: The path of the file.
      component: The component the file is from.
      file_action: Whether file is modified, deleted or added.
      githash: The git hashcode to check the line diff.

    Returns:
      url: The URL of the diff page, returns the changelog page for the
           file if the diff cannot be retrieved.
      changed_line_numbers: The list of the line numbers that has been
                            changed.
      changed_line_contents: The content of the changed lines.
    """
    raise NotImplementedError()

  def ParseBlameInfo(self, component, file_path, line, revision):
    """Parses blame information of the given file/line in revision.

    Args:
      component: The component this line is from.
      file_path: The path of the file.
      line: The line that caused the crash.
      revision: The revision to parse blame information for.

    Returns:
      The content of the line, the last changed revision of the line, author
      and the url of the revision.
    """
    raise NotImplementedError()