| 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 import collections | 5 import collections |
| 6 import logging | 6 import logging |
| 7 import posixpath | 7 import posixpath |
| 8 import sys | 8 import sys |
| 9 import threading | 9 import threading |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 self._output = None | 95 self._output = None |
| 96 | 96 |
| 97 def run(self): | 97 def run(self): |
| 98 if not self.FAKE_THREADING: # pragma: no cover | 98 if not self.FAKE_THREADING: # pragma: no cover |
| 99 self._push() | 99 self._push() |
| 100 | 100 |
| 101 def get_result(self): | 101 def get_result(self): |
| 102 self.join() | 102 self.join() |
| 103 if self.FAKE_THREADING: # pragma: no cover | 103 if self.FAKE_THREADING: # pragma: no cover |
| 104 self._push() | 104 self._push() |
| 105 log = logging.info if self._success else logging.error | 105 log = LOGGER.info if self._success else LOGGER.error |
| 106 prefix = 'Completed' if self._success else 'FAILED' | 106 prefix = 'Completed' if self._success else 'FAILED' |
| 107 log('%s push for %r', prefix, self._name) | 107 log('%s push for %r', prefix, self._name) |
| 108 if self._output: | 108 if self._output: |
| 109 log(self._output) # pragma: no cover | 109 log(self._output) # pragma: no cover |
| 110 return self._success | 110 return self._success |
| 111 | 111 |
| 112 def _push(self): | 112 def _push(self): |
| 113 try: | 113 try: |
| 114 self._output = self._repo.fast_forward_push( | 114 self._output = self._repo.fast_forward_push( |
| 115 self._pushspec, include_err=True, timeout=PUSH_TIMEOUT) | 115 self._pushspec, include_err=True, timeout=PUSH_TIMEOUT) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 LOGGER.info('processing %s', ref) | 155 LOGGER.info('processing %s', ref) |
| 156 | 156 |
| 157 # The last thing that was pushed to the subtree_repo | 157 # The last thing that was pushed to the subtree_repo |
| 158 last_push = subtree_repo[ref.ref].commit | 158 last_push = subtree_repo[ref.ref].commit |
| 159 synth_parent = last_push | 159 synth_parent = last_push |
| 160 | 160 |
| 161 processed = INVALID | 161 processed = INVALID |
| 162 if synth_parent is not INVALID: | 162 if synth_parent is not INVALID: |
| 163 f = synth_parent.data.footers | 163 f = synth_parent.data.footers |
| 164 if MIRRORED_COMMIT not in f: | 164 if MIRRORED_COMMIT not in f: |
| 165 logging.warn('Getting data from extra_footers. This information is' | 165 LOGGER.warn('Getting data from extra_footers. This information is' |
| 166 'only as trustworthy as the ACLs.') | 166 'only as trustworthy as the ACLs.') |
| 167 f = synth_parent.extra_footers() | 167 f = synth_parent.extra_footers() |
| 168 if MIRRORED_COMMIT not in f: | 168 if MIRRORED_COMMIT not in f: |
| 169 success = False | 169 success = False |
| 170 logging.error('Could not find footers for synthesized commit %r', | 170 LOGGER.error('Could not find footers for synthesized commit %r', |
| 171 synth_parent.hsh) | 171 synth_parent.hsh) |
| 172 continue | 172 continue |
| 173 processed_commit = f[MIRRORED_COMMIT][0] | 173 processed_commit = f[MIRRORED_COMMIT][0] |
| 174 processed = origin_repo.get_commit(processed_commit) | 174 processed = origin_repo.get_commit(processed_commit) |
| 175 logging.info('got processed commit %s: %r', processed_commit, processed) | 175 LOGGER.info('got processed commit %s: %r', processed_commit, processed) |
| 176 | 176 |
| 177 if processed is INVALID: | 177 if processed is INVALID: |
| 178 success = False | 178 success = False |
| 179 logging.error('Subtree mirror commit %r claims to mirror commit %r, ' | 179 LOGGER.error('Subtree mirror commit %r claims to mirror commit %r, ' |
| 180 'which doesn\'t exist in the origin repo. Halting.', | 180 'which doesn\'t exist in the origin repo. Halting.', |
| 181 synth_parent.hsh, processed_commit) | 181 synth_parent.hsh, processed_commit) |
| 182 continue | 182 continue |
| 183 | 183 |
| 184 LOGGER.info('starting with tree %r', synth_parent.data.tree) | 184 LOGGER.info('starting with tree %r', synth_parent.data.tree) |
| 185 | 185 |
| 186 for commit in origin_repo[processed.hsh].to(ref, path, first_parent=True): | 186 for commit in origin_repo[processed.hsh].to(ref, path, first_parent=True): |
| 187 LOGGER.info('processing %s', commit) | 187 LOGGER.info('processing %s', commit) |
| 188 obj_name = '{.hsh}:{}'.format(commit, path) | 188 obj_name = '{.hsh}:{}'.format(commit, path) |
| 189 dir_tree = None | 189 dir_tree = None |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 success = False | 263 success = False |
| 264 | 264 |
| 265 for t in threads: | 265 for t in threads: |
| 266 rslt = t.get_result() | 266 rslt = t.get_result() |
| 267 if not rslt: # pragma: no cover | 267 if not rslt: # pragma: no cover |
| 268 success = False | 268 success = False |
| 269 | 269 |
| 270 origin_repo.push_queued_fast_forwards(timeout=PUSH_TIMEOUT) | 270 origin_repo.push_queued_fast_forwards(timeout=PUSH_TIMEOUT) |
| 271 | 271 |
| 272 return success, processed | 272 return success, processed |
| OLD | NEW |