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 | 5 |
6 from base64 import b64decode | 6 from base64 import b64decode |
7 from itertools import izip | 7 from itertools import izip |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import posixpath | 10 import posixpath |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return stat_info | 226 return stat_info |
227 if filename not in stat_info.child_versions: | 227 if filename not in stat_info.child_versions: |
228 raise FileNotFoundError( | 228 raise FileNotFoundError( |
229 '%s from %s was not in child versions for Stat' % (filename, path)) | 229 '%s from %s was not in child versions for Stat' % (filename, path)) |
230 return StatInfo(stat_info.child_versions[filename]) | 230 return StatInfo(stat_info.child_versions[filename]) |
231 | 231 |
232 fetch_future = self._FetchAsync(ToDirectory(dir_) + _JSON_FORMAT) | 232 fetch_future = self._FetchAsync(ToDirectory(dir_) + _JSON_FORMAT) |
233 return self._ResolveFetchContent(path, fetch_future).Then(stat) | 233 return self._ResolveFetchContent(path, fetch_future).Then(stat) |
234 | 234 |
235 def GetIdentity(self): | 235 def GetIdentity(self): |
236 # NOTE: Do not use commit information to create the string identity. | 236 if self._branch == 'master': |
237 # Doing so will mess up caching. | 237 # A master FS always carries the same identity even if pinned to a commit. |
238 if self._commit is None and self._branch != 'master': | 238 str_id = 'master' |
239 str_id = '%s/%s/%s/%s' % ( | 239 elif self._commit is not None: |
240 GITILES_BASE, GITILES_SRC_ROOT, GITILES_BRANCHES_PATH, self._branch) | 240 str_id = self._commit |
241 else: | 241 else: |
242 str_id = '%s/%s' % (GITILES_BASE, GITILES_SRC_ROOT) | 242 str_id = '%s/%s' % (GITILES_BRANCHES_PATH, self._branch) |
243 return '@'.join((self.__class__.__name__, StringIdentity(str_id))) | 243 return '@'.join(self.__class__.__name__, StringIdentity( |
| 244 '%s/%s/%s' % (GITILES_BASE, GITILES_SRC_ROOT, str_id))) |
| 245 |
| 246 def GetVersion(self): |
| 247 return self._commit |
OLD | NEW |