| 257 | self._p4('reopen', ['-c', self._cl] + paths) |
| 258 | |
| 259 | def submit(self, paths, success): |
| 260 | if self._action == 'none': |
| 261 | return |
| 262 | if self._action == 'revert': |
| 263 | self._revert(paths) |
| 264 | else: |
| 265 | try: |
| 266 | action_verb = 'Submitting' if self._action == 'submit' else 'Saving' |
| 267 | logging.info(f'{action_verb} {len(paths)} files to Perforce') |
| 268 | logging.debug('Adding new files to Perforce') |
| 269 | self._p4('add', ['-tbinary+m'] + paths) |
| 270 | logging.debug(f'Moving new files to CL {self._cl}') |
| 271 | self._p4('reopen', ['-c', self._cl] + paths) |
| 272 | if self._action == 'submit': |
| 273 | if not success: |
| 274 | logging.debug(f'Reverting unchanged files in CL {self._cl}') |
| 275 | self._p4('revert', ['-a', '-c', self._cl]) |
| 276 | logging.debug(f'Submitting CL {self._cl}') |
| 277 | self._p4('submit', ['-c', self._cl]) |
| 278 | except subprocess.CalledProcessError: |
| 279 | logging.exception(f'Failed to {self._action} compiled files') |
| 280 | self._revert(paths) |
| 281 | |
| 282 | def _revert(self, paths): |
| 283 | logging.info(f'Reverting {len(paths)} files in Perforce') |