| 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 from base64 import b64decode | 5 from base64 import b64decode |
| 6 from itertools import izip | 6 from itertools import izip |
| 7 import json | 7 import json |
| 8 import posixpath | 8 import posixpath |
| 9 import traceback | 9 import traceback |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 # { | 150 # { |
| 151 # "commit": "8fd578e1a7b142cd10a4387861f05fb9459b69e2", # Commit ID. | 151 # "commit": "8fd578e1a7b142cd10a4387861f05fb9459b69e2", # Commit ID. |
| 152 # "tree": "3ade65d8a91eadd009a6c9feea8f87db2c528a53", # Tree ID. | 152 # "tree": "3ade65d8a91eadd009a6c9feea8f87db2c528a53", # Tree ID. |
| 153 # "author": {...}, | 153 # "author": {...}, |
| 154 # "committer": {...}, | 154 # "committer": {...}, |
| 155 # "message": <codereview message>, | 155 # "message": <codereview message>, |
| 156 # ... | 156 # ... |
| 157 # } | 157 # } |
| 158 return content_future.Then(lambda json: _ParseGitilesJson(json)['commit']) | 158 return content_future.Then(lambda json: _ParseGitilesJson(json)['commit']) |
| 159 | 159 |
| 160 def Stat(self, path): | |
| 161 return self.StatAsync(path).Get() | |
| 162 | |
| 163 def StatAsync(self, path): | 160 def StatAsync(self, path): |
| 164 dir_, filename = posixpath.split(path) | 161 dir_, filename = posixpath.split(path) |
| 165 def stat(content): | 162 def stat(content): |
| 166 stat_info = _CreateStatInfo(content) | 163 stat_info = _CreateStatInfo(content) |
| 167 if stat_info.version is None: | 164 if stat_info.version is None: |
| 168 raise FileSystemError('Failed to find version of dir %s' % dir_) | 165 raise FileSystemError('Failed to find version of dir %s' % dir_) |
| 169 if IsDirectory(path): | 166 if IsDirectory(path): |
| 170 return stat_info | 167 return stat_info |
| 171 if filename not in stat_info.child_versions: | 168 if filename not in stat_info.child_versions: |
| 172 raise FileNotFoundError( | 169 raise FileNotFoundError( |
| 173 '%s from %s was not in child versions for Stat' % (filename, path)) | 170 '%s from %s was not in child versions for Stat' % (filename, path)) |
| 174 return StatInfo(stat_info.child_versions[filename]) | 171 return StatInfo(stat_info.child_versions[filename]) |
| 175 fetch_future = self._FetchAsync(ToDirectory(dir_) + _JSON_FORMAT) | 172 fetch_future = self._FetchAsync(ToDirectory(dir_) + _JSON_FORMAT) |
| 176 return self._ResolveFetchContent(path, fetch_future).Then(stat) | 173 return self._ResolveFetchContent(path, fetch_future).Then(stat) |
| 177 | 174 |
| 178 def GetIdentity(self): | 175 def GetIdentity(self): |
| 179 return '@'.join((self.__class__.__name__, | 176 return '@'.join((self.__class__.__name__, |
| 180 StringIdentity(self._commit or self._branch))) | 177 StringIdentity(self._commit or self._branch))) |
| OLD | NEW |