OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import base64 | 5 import base64 |
6 from datetime import datetime | 6 from datetime import datetime |
7 from datetime import timedelta | 7 from datetime import timedelta |
8 import json | 8 import json |
9 import re | 9 import re |
10 | 10 |
11 from common import diff | 11 from gitiles.blame import Blame, Region |
12 from common.blame import Blame | 12 from gitiles.change_log import ChangeLog, FileChangeInfo |
13 from common.blame import Region | 13 from gitiles import diff |
14 from common.cache_decorator import Cached | 14 # TODO(wrengr): can we remove this dependency on cache_decorator (and |
15 from common.cache_decorator import CompressedMemCacher | 15 # hence on appengine) by pushing that off into a subclass defined outside |
16 from common.change_log import ChangeLog | 16 # of the gitiles directory? |
17 from common.change_log import FileChangeInfo | 17 from gitiles.cache_decorator import Cached, CompressedMemCacher |
18 from common.repository import Repository | |
19 | |
20 | 18 |
21 COMMIT_POSITION_PATTERN = re.compile( | 19 COMMIT_POSITION_PATTERN = re.compile( |
22 '^Cr-Commit-Position: refs/heads/master@{#(\d+)}$', re.IGNORECASE) | 20 '^Cr-Commit-Position: refs/heads/master@{#(\d+)}$', re.IGNORECASE) |
23 CODE_REVIEW_URL_PATTERN = re.compile( | 21 CODE_REVIEW_URL_PATTERN = re.compile( |
24 '^(?:Review URL|Review-Url): (.*\d+).*$', re.IGNORECASE) | 22 '^(?:Review URL|Review-Url): (.*\d+).*$', re.IGNORECASE) |
25 REVERTED_REVISION_PATTERN = re.compile( | 23 REVERTED_REVISION_PATTERN = re.compile( |
26 '^> Committed: https://.+/([0-9a-fA-F]{40})$', re.IGNORECASE) | 24 '^> Committed: https://.+/([0-9a-fA-F]{40})$', re.IGNORECASE) |
27 TIMEZONE_PATTERN = re.compile('[-+]\d{4}$') | 25 TIMEZONE_PATTERN = re.compile('[-+]\d{4}$') |
28 CACHE_EXPIRE_TIME_SECONDS = 24 * 60 * 60 | 26 CACHE_EXPIRE_TIME_SECONDS = 24 * 60 * 60 |
29 | 27 |
30 | 28 |
31 class GitRepository(Repository): | 29 class GitRepository(object): |
32 """Represents a git repository on https://chromium.googlesource.com.""" | 30 """Represents a git repository on https://chromium.googlesource.com.""" |
33 | 31 |
34 def __init__(self, repo_url, http_client): | 32 def __init__(self, repo_url, http_client): |
35 super(GitRepository, self).__init__() | |
36 self.repo_url = repo_url | 33 self.repo_url = repo_url |
37 if self.repo_url.endswith('/'): | 34 if self.repo_url.endswith('/'): |
38 self.repo_url = self.repo_url[:-1] | 35 self.repo_url = self.repo_url[:-1] |
39 self.http_client = http_client | 36 self.http_client = http_client |
40 | 37 |
41 @property | 38 @property |
42 def identifier(self): | 39 def identifier(self): |
43 return self.repo_url | 40 return self.repo_url |
44 | 41 |
45 @Cached(namespace='Gitiles-json-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, | 42 @Cached(namespace='Gitiles-json-view', expire_time=CACHE_EXPIRE_TIME_SECONDS, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 268 |
272 for log in data['log']: | 269 for log in data['log']: |
273 changelogs.append(self._ParseChangeLogFromLogData(log)) | 270 changelogs.append(self._ParseChangeLogFromLogData(log)) |
274 | 271 |
275 if 'next' in data: | 272 if 'next' in data: |
276 next_end_revision = data['next'] | 273 next_end_revision = data['next'] |
277 else: | 274 else: |
278 next_end_revision = None | 275 next_end_revision = None |
279 | 276 |
280 return changelogs | 277 return changelogs |
OLD | NEW |