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 lib.gitiles import diff |
12 from common.blame import Blame | 12 from lib.gitiles.blame import Blame |
13 from common.blame import Region | 13 from lib.gitiles.blame import Region |
14 from common.cache_decorator import Cached | 14 from lib.gitiles.cache_decorator import Cached, CompressedMemCacher |
stgao
2016/10/28 18:21:00
cache_decorator should be in lib/ instead of lib/g
wrengr
2016/10/28 19:24:49
Since when? Last I looked only gitiles_repository.
| |
15 from common.cache_decorator import CompressedMemCacher | 15 from lib.gitiles.change_log import ChangeLog |
16 from common.change_log import ChangeLog | 16 from lib.gitiles.change_log import FileChangeInfo |
17 from common.change_log import FileChangeInfo | 17 from lib.gitiles.git_repository import GitRepository |
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 GitilesRepository(GitRepository): |
32 """Represents a git repository on https://chromium.googlesource.com.""" | 30 """Use Gitiles to access a repository on https://chromium.googlesource.com.""" |
33 | 31 |
34 def __init__(self, repo_url=None, http_client=None): | 32 def __init__(self, repo_url=None, http_client=None): |
35 super(GitRepository, self).__init__() | 33 super(GitilesRepository, self).__init__() |
36 if repo_url and repo_url.endswith('/'): | 34 if repo_url and repo_url.endswith('/'): |
37 self._repo_url = repo_url[:-1] | 35 self._repo_url = repo_url[:-1] |
38 else: | 36 else: |
39 self._repo_url = repo_url | 37 self._repo_url = repo_url |
40 | 38 |
41 self._http_client = http_client | 39 self._http_client = http_client |
42 | 40 |
43 @property | 41 @property |
44 def repo_url(self): | 42 def repo_url(self): |
45 return self._repo_url | 43 return self._repo_url |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 | 280 |
283 for log in data['log']: | 281 for log in data['log']: |
284 changelogs.append(self._ParseChangeLogFromLogData(log)) | 282 changelogs.append(self._ParseChangeLogFromLogData(log)) |
285 | 283 |
286 if 'next' in data: | 284 if 'next' in data: |
287 next_end_revision = data['next'] | 285 next_end_revision = data['next'] |
288 else: | 286 else: |
289 next_end_revision = None | 287 next_end_revision = None |
290 | 288 |
291 return changelogs | 289 return changelogs |
OLD | NEW |