Chromium Code Reviews| Index: tools/findit/git_repository_parser.py |
| diff --git a/tools/findit/git_repository_parser.py b/tools/findit/git_repository_parser.py |
| index 8053f1cd669523475855398d05fb0e519f8a0cbe..cc1d18f39de8f0cfcc8a4a6532aa5bac83804b4d 100644 |
| --- a/tools/findit/git_repository_parser.py |
| +++ b/tools/findit/git_repository_parser.py |
| @@ -1,10 +1,9 @@ |
| -# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# 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. |
| import base64 |
| import logging |
| -import os |
| import xml.dom.minidom as minidom |
| from xml.parsers.expat import ExpatError |
| @@ -93,22 +92,21 @@ class GitParser(ParserInterface): |
| for li in lis: |
| # Retrieve path and action of the changed file |
| file_path = li.getElementsByTagName('a')[0].firstChild.nodeValue |
| - file_action = li.getElementsByTagName('span')[0].getAttribute('class') |
| + file_change_type = li.getElementsByTagName('span')[ |
| + 0].getAttribute('class') |
| # Normalize file action so that it is same as SVN parser. |
| - if file_action == 'add': |
| - file_action = 'A' |
| - elif file_action == 'delete': |
| - file_action = 'D' |
| - elif file_action == 'modify': |
| - file_action = 'M' |
| + if file_change_type == 'add': |
|
Martin Barbella
2014/08/22 02:24:14
Define a map to handle this and use it in both pla
jeun
2014/08/22 22:58:43
Done.
|
| + file_change_type = 'A' |
| + elif file_change_type == 'delete': |
| + file_change_type = 'D' |
| + elif file_change_type == 'modify': |
| + file_change_type = 'M' |
| # Add the changed file to the map. |
| - changed_file = os.path.basename(file_path) |
| - if changed_file not in file_to_revision_map: |
| - file_to_revision_map[changed_file] = [] |
| - file_to_revision_map[changed_file].append((githash, file_action, |
| - file_path)) |
| + if file_path not in file_to_revision_map: |
| + file_to_revision_map[file_path] = [] |
| + file_to_revision_map[file_path].append((githash, file_change_type)) |
| # Add this revision object to the map. |
| revision_map[githash] = revision |
| @@ -186,36 +184,34 @@ class GitParser(ParserInterface): |
| # Iterate through the changed files. |
| for diff in json_revision['tree_diff']: |
| file_path = diff['new_path'] |
| - file_action = diff['type'] |
| + file_change_type = diff['type'] |
| # Normalize file action so that it fits with svn_repository_parser. |
| - if file_action == 'add': |
| - file_action = 'A' |
| - elif file_action == 'delete': |
| - file_action = 'D' |
| - elif file_action == 'modify': |
| - file_action = 'M' |
| + if file_change_type == 'add': |
| + file_change_type = 'A' |
| + elif file_change_type == 'delete': |
| + file_change_type = 'D' |
| + elif file_change_type == 'modify': |
| + file_change_type = 'M' |
| # Add the file to the map. |
| - changed_file = os.path.basename(file_path) |
| - if changed_file not in file_to_revision_map: |
| - file_to_revision_map[changed_file] = [] |
| - file_to_revision_map[changed_file].append( |
| - (githash, file_action, file_path)) |
| + if file_path not in file_to_revision_map: |
| + file_to_revision_map[file_path] = [] |
| + file_to_revision_map[file_path].append((githash, file_change_type)) |
| # Add this CL to the map. |
| revision_map[githash] = revision |
| return |
| - def ParseLineDiff(self, path, component, file_action, githash): |
| + def ParseLineDiff(self, path, component, file_change_type, githash): |
| changed_line_numbers = [] |
| changed_line_contents = [] |
| base_url = self.component_to_url_map[component]['repository'] |
| backup_url = (base_url + self.url_parts_map['revision_url']) % githash |
| # If the file is added (not modified), treat it as if it is not changed. |
| - if file_action == 'A': |
| + if file_change_type == 'A': |
| return (backup_url, changed_line_numbers, changed_line_contents) |
| # Retrieves the diff data from URL, and if it fails, return emptry lines. |
| @@ -289,7 +285,9 @@ class GitParser(ParserInterface): |
| # TODO(jeun): Add a way to get content from JSON object. |
| content = None |
| - return (content, revision, author, revision_url) |
| + (revision_info, _) = self.ParseChangelog(component, revision, revision) |
| + message = revision_info[revision]['message'] |
| + return (content, revision, author, revision_url, message) |
| # Return none if the region does not exist. |
| return None |