OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 posixpath | 5 import posixpath |
6 | 6 |
7 from file_system import FileSystem, FileNotFoundError | 7 from file_system import FileSystem, FileNotFoundError |
8 from future import Future | 8 from future import Future |
9 from test_file_system import _List, _StatTracker, TestFileSystem | 9 from test_file_system import _List, _StatTracker, TestFileSystem |
10 from path_util import IsDirectory | 10 from path_util import IsDirectory |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 stat = self._file_system.Stat(path) | 78 stat = self._file_system.Stat(path) |
79 stat.version = stradd(stat.version, self._stat_tracker.GetVersion(path)) | 79 stat.version = stradd(stat.version, self._stat_tracker.GetVersion(path)) |
80 if stat.child_versions: | 80 if stat.child_versions: |
81 for child_path, child_version in stat.child_versions.iteritems(): | 81 for child_path, child_version in stat.child_versions.iteritems(): |
82 stat.child_versions[child_path] = stradd( | 82 stat.child_versions[child_path] = stradd( |
83 stat.child_versions[child_path], | 83 stat.child_versions[child_path], |
84 self._stat_tracker.GetVersion(posixpath.join(path, child_path))) | 84 self._stat_tracker.GetVersion(posixpath.join(path, child_path))) |
85 | 85 |
86 return stat | 86 return stat |
87 | 87 |
| 88 def GetCommitID(self): |
| 89 return Future(value=self._stat_tracker.GetVersion('')) |
| 90 |
| 91 def GetPreviousCommitID(self): |
| 92 return Future(value=self._stat_tracker.GetVersion('') - 1) |
| 93 |
88 def GetIdentity(self): | 94 def GetIdentity(self): |
89 return self._file_system.GetIdentity() | 95 return self._file_system.GetIdentity() |
90 | 96 |
91 def __str__(self): | 97 def __str__(self): |
92 return repr(self) | 98 return repr(self) |
93 | 99 |
94 def __repr__(self): | 100 def __repr__(self): |
95 return 'MockFileSystem(read_count=%s, stat_count=%s, updates=%s)' % ( | 101 return 'MockFileSystem(read_count=%s, stat_count=%s, updates=%s)' % ( |
96 self._read_count, self._stat_count, len(self._updates)) | 102 self._read_count, self._stat_count, len(self._updates)) |
97 | 103 |
(...skipping 25 matching lines...) Expand all Loading... |
123 self._read_resolve_count = 0 | 129 self._read_resolve_count = 0 |
124 self._stat_count = 0 | 130 self._stat_count = 0 |
125 | 131 |
126 def Update(self, update): | 132 def Update(self, update): |
127 self._updates.append(TestFileSystem(update)) | 133 self._updates.append(TestFileSystem(update)) |
128 for path in _List(update).iterkeys(): | 134 for path in _List(update).iterkeys(): |
129 # Any files (not directories) which changed are now at the version | 135 # Any files (not directories) which changed are now at the version |
130 # derived from |_updates|. | 136 # derived from |_updates|. |
131 if not IsDirectory(path): | 137 if not IsDirectory(path): |
132 self._stat_tracker.SetVersion(path, len(self._updates)) | 138 self._stat_tracker.SetVersion(path, len(self._updates)) |
OLD | NEW |