| 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 fnmatch import fnmatch | 5 from fnmatch import fnmatch |
| 6 import logging | 6 import logging |
| 7 from urlparse import urlparse | 7 from urlparse import urlparse |
| 8 | 8 |
| 9 from appengine_url_fetcher import AppEngineUrlFetcher | 9 from appengine_url_fetcher import AppEngineUrlFetcher |
| 10 from caching_rietveld_patcher import CachingRietveldPatcher | 10 from caching_rietveld_patcher import CachingRietveldPatcher |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 self._issue = issue | 27 self._issue = issue |
| 28 self._delegate = delegate | 28 self._delegate = delegate |
| 29 | 29 |
| 30 def CreateServerInstance(self): | 30 def CreateServerInstance(self): |
| 31 # start_empty=False because a patch can rely on files that are already in | 31 # start_empty=False because a patch can rely on files that are already in |
| 32 # SVN repository but not yet pulled into data store by cron jobs (a typical | 32 # SVN repository but not yet pulled into data store by cron jobs (a typical |
| 33 # example is to add documentation for an existing API). | 33 # example is to add documentation for an existing API). |
| 34 object_store_creator = ObjectStoreCreator(start_empty=False) | 34 object_store_creator = ObjectStoreCreator(start_empty=False) |
| 35 | 35 |
| 36 unpatched_file_system = self._delegate.CreateHostFileSystemProvider( | 36 unpatched_file_system = self._delegate.CreateHostFileSystemProvider( |
| 37 object_store_creator).GetTrunk() | 37 object_store_creator).GetMaster() |
| 38 | 38 |
| 39 rietveld_patcher = CachingRietveldPatcher( | 39 rietveld_patcher = CachingRietveldPatcher( |
| 40 RietveldPatcher(self._issue, | 40 RietveldPatcher(self._issue, |
| 41 AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)), | 41 AppEngineUrlFetcher(url_constants.CODEREVIEW_SERVER)), |
| 42 object_store_creator) | 42 object_store_creator) |
| 43 | 43 |
| 44 patched_file_system = PatchedFileSystem(unpatched_file_system, | 44 patched_file_system = PatchedFileSystem(unpatched_file_system, |
| 45 rietveld_patcher) | 45 rietveld_patcher) |
| 46 | 46 |
| 47 patched_host_file_system_provider = ( | 47 patched_host_file_system_provider = ( |
| 48 self._delegate.CreateHostFileSystemProvider( | 48 self._delegate.CreateHostFileSystemProvider( |
| 49 object_store_creator, | 49 object_store_creator, |
| 50 # The patched file system needs to be online otherwise it'd be | 50 # The patched file system needs to be online otherwise it'd be |
| 51 # impossible to add files in the patches. | 51 # impossible to add files in the patches. |
| 52 offline=False, | 52 offline=False, |
| 53 # The trunk file system for this creator should be the patched one. | 53 # The master file system for this creator should be the patched one. |
| 54 default_trunk_instance=patched_file_system)) | 54 default_master_instance=patched_file_system)) |
| 55 | 55 |
| 56 combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory( | 56 combined_compiled_fs_factory = ChainedCompiledFileSystem.Factory( |
| 57 [unpatched_file_system], object_store_creator) | 57 [unpatched_file_system], object_store_creator) |
| 58 | 58 |
| 59 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) | 59 branch_utility = self._delegate.CreateBranchUtility(object_store_creator) |
| 60 | 60 |
| 61 server_instance = ServerInstance( | 61 server_instance = ServerInstance( |
| 62 object_store_creator, | 62 object_store_creator, |
| 63 combined_compiled_fs_factory, | 63 combined_compiled_fs_factory, |
| 64 branch_utility, | 64 branch_utility, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 # Disable cache for patched content. | 109 # Disable cache for patched content. |
| 110 response.headers.pop('cache-control', None) | 110 response.headers.pop('cache-control', None) |
| 111 except RietveldPatcherError as e: | 111 except RietveldPatcherError as e: |
| 112 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) | 112 response = Response.NotFound(e.message, {'Content-Type': 'text/plain'}) |
| 113 | 113 |
| 114 redirect_url, permanent = response.GetRedirect() | 114 redirect_url, permanent = response.GetRedirect() |
| 115 if redirect_url is not None: | 115 if redirect_url is not None: |
| 116 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), | 116 response = Response.Redirect('/_patch/%s%s' % (issue, redirect_url), |
| 117 permanent) | 117 permanent) |
| 118 return response | 118 return response |
| OLD | NEW |