| 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 from copy import deepcopy | 5 from copy import deepcopy |
| 6 | 6 |
| 7 from file_system import FileSystem, StatInfo, FileNotFoundError | 7 from file_system import FileSystem, StatInfo, FileNotFoundError |
| 8 from future import Future | 8 from future import Future |
| 9 | 9 |
| 10 class _AsyncFetchFuture(object): | 10 class _AsyncFetchFuture(object): |
| 11 def __init__(self, | 11 def __init__(self, |
| 12 unpatched_files_future, | 12 unpatched_files_future, |
| 13 patched_files_future, | 13 patched_files_future, |
| 14 dirs_value, | 14 dirs_value, |
| 15 patched_file_system): | 15 patched_file_system): |
| 16 self._unpatched_files_future = unpatched_files_future | 16 self._unpatched_files_future = unpatched_files_future |
| 17 self._patched_files_future = patched_files_future | 17 self._patched_files_future = patched_files_future |
| 18 self._dirs_value = dirs_value | 18 self._dirs_value = dirs_value |
| 19 self._patched_file_system = patched_file_system | 19 self._patched_file_system = patched_file_system |
| 20 | 20 |
| 21 def Get(self): | 21 def Get(self): |
| 22 files = self._unpatched_files_future.Get() | 22 files = self._unpatched_files_future.Get() |
| 23 files.update(self._patched_files_future.Get()) | 23 files.update(self._patched_files_future.Get()) |
| 24 files.update({path: self._PatchDirectoryListing(path, | 24 files.update( |
| 25 self._dirs_value[path]) | 25 dict((path, self._PatchDirectoryListing(path, self._dirs_value[path])) |
| 26 for path in self._dirs_value}) | 26 for path in self._dirs_value)) |
| 27 return files | 27 return files |
| 28 | 28 |
| 29 def _PatchDirectoryListing(self, path, original_listing): | 29 def _PatchDirectoryListing(self, path, original_listing): |
| 30 added, deleted, modified = ( | 30 added, deleted, modified = ( |
| 31 self._patched_file_system._GetDirectoryListingFromPatch(path)) | 31 self._patched_file_system._GetDirectoryListingFromPatch(path)) |
| 32 if original_listing is None: | 32 if original_listing is None: |
| 33 if len(added) == 0: | 33 if len(added) == 0: |
| 34 raise FileNotFoundError('Directory %s not found in the patch.' % path) | 34 raise FileNotFoundError('Directory %s not found in the patch.' % path) |
| 35 return added | 35 return added |
| 36 return list((set(original_listing) | set(added)) - set(deleted)) | 36 return list((set(original_listing) | set(added)) - set(deleted)) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 # No changes are made in this directory. | 148 # No changes are made in this directory. |
| 149 return self._host_file_system.Stat(path) | 149 return self._host_file_system.Stat(path) |
| 150 | 150 |
| 151 if stat_info.child_versions is not None: | 151 if stat_info.child_versions is not None: |
| 152 if filename: | 152 if filename: |
| 153 if filename in stat_info.child_versions: | 153 if filename in stat_info.child_versions: |
| 154 stat_info = StatInfo(stat_info.child_versions[filename]) | 154 stat_info = StatInfo(stat_info.child_versions[filename]) |
| 155 else: | 155 else: |
| 156 raise FileNotFoundError('%s was not in child versions' % filename) | 156 raise FileNotFoundError('%s was not in child versions' % filename) |
| 157 return stat_info | 157 return stat_info |
| OLD | NEW |