Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2782)

Unified Diff: appengine/findit/lib/gitiles/change_log.py

Issue 2538373003: [Culprit-Finder] Merge lib/ to libs/. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/lib/gitiles/blame.py ('k') | appengine/findit/lib/gitiles/commit_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/lib/gitiles/change_log.py
diff --git a/appengine/findit/lib/gitiles/change_log.py b/appengine/findit/lib/gitiles/change_log.py
deleted file mode 100644
index 3f1686dfe2956c5e3f25445dddd7be55b3c2037e..0000000000000000000000000000000000000000
--- a/appengine/findit/lib/gitiles/change_log.py
+++ /dev/null
@@ -1,110 +0,0 @@
-# Copyright 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.
-
-from collections import namedtuple
-
-from lib.gitiles.diff import ChangeType
-
-# TODO(wrengr): it'd be better to have a class hierarchy here, so we can
-# avoid playing around with None, and so the change_type can be stored
-# once (in the class itself; rather than once per instance).
-# TODO(http://crbug/644476): better name for this class; i.e., without
-# the extraneous \"Info\" at the very least.
-# TODO(http://crbug.com/659346): coverage tests for the smart constructors.
-class FileChangeInfo(namedtuple('FileChangeInfo',
- ['change_type', 'old_path', 'new_path'])):
- """Represents a file change (add/delete/modify/rename/copy/etc)."""
- __slots__ = ()
-
- @classmethod
- def Modify(cls, path): # pragma: no cover
- return cls(ChangeType.MODIFY, path, path)
-
- @classmethod
- def Add(cls, path): # pragma: no cover
- # Stay the same as gitile.
- return cls(ChangeType.ADD, None, path)
-
- @classmethod
- def Delete(cls, path): # pragma: no cover
- return cls(ChangeType.DELETE, path, None)
-
- @classmethod
- def Rename(cls, old_path, new_path): # pragma: no cover
- return cls(ChangeType.RENAME, old_path, new_path)
-
- @classmethod
- def Copy(cls, old_path, new_path): # pragma: no cover
- return cls(ChangeType.COPY, old_path, new_path)
-
- @classmethod
- def FromDict(cls, info):
- return cls(info['change_type'].lower(), info['old_path'], info['new_path'])
-
- def ToDict(self):
- return {
- 'change_type': self.change_type,
- 'old_path': self.old_path,
- 'new_path': self.new_path
- }
-
-
-class ChangeLog(namedtuple('ChangeLog',
- ['author_name', 'author_email', 'author_time', 'committer_name',
- 'committer_email', 'committer_time', 'revision', 'commit_position',
- 'message', 'touched_files', 'commit_url', 'code_review_url',
- 'reverted_revision'])):
- """Represents the change log of a revision."""
- __slots__ = ()
-
- def __new__(cls, author_name, author_email, author_time, committer_name,
- committer_email, committer_time, revision, commit_position,
- message, touched_files, commit_url, code_review_url=None,
- reverted_revision=None):
- return super(cls, ChangeLog).__new__(cls,
- author_name, author_email, author_time, committer_name,
- committer_email, committer_time, revision, commit_position,
- message, touched_files, commit_url, code_review_url,
- reverted_revision)
-
- def ToDict(self):
- """Returns the change log as a JSON object."""
- json_data = {
- 'author_name': self.author_name,
- 'author_email': self.author_email,
- 'author_time': self.author_time,
- 'committer_name': self.committer_name,
- 'committer_email': self.committer_email,
- 'committer_time': self.committer_time,
- 'revision': self.revision,
- 'commit_position': self.commit_position,
- 'touched_files': [],
- 'message': self.message,
- 'commit_url': self.commit_url,
- 'code_review_url': self.code_review_url,
- 'reverted_revision': self.reverted_revision,
- }
- for touched_file in self.touched_files:
- json_data['touched_files'].append(touched_file.ToDict())
- return json_data
-
- @staticmethod
- def FromDict(info):
- """Returns a ChangeLog instance represented by the given JSON info."""
- touched_files = []
- for touched_file_info in info['touched_files']:
- if isinstance(touched_file_info, dict):
- touched_file_info = FileChangeInfo.FromDict(touched_file_info)
- if not isinstance(touched_file_info, FileChangeInfo): # pragma: no cover
- raise TypeError("expected FileChangeInfo but got %s"
- % touched_file_info.__class__.__name__)
- touched_files.append(touched_file_info)
-
- return ChangeLog(
- info['author_name'], info['author_email'], info['author_time'],
- info['committer_name'], info['committer_email'], info['committer_time'],
- info['revision'], info['commit_position'], info['message'],
- touched_files, info['commit_url'], info['code_review_url'],
- info['reverted_revision']
- )
« no previous file with comments | « appengine/findit/lib/gitiles/blame.py ('k') | appengine/findit/lib/gitiles/commit_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698