def run(self): """See `IRosettaUploadJob`.""" with server(get_ro_server(), no_replace=True): # This is not called upon job creation because the branch would # neither have been mirrored nor scanned then. self._init_translation_file_lists() # Get the product series that are connected to this branch and # that want to upload translations. productseriesset = getUtility(IProductSeriesSet) productseries = productseriesset.findByTranslationsImportBranch( self.branch, self.force_translations_upload) translation_import_queue = getUtility(ITranslationImportQueue) for series in productseries: approver = TranslationBranchApprover(self.file_names, productseries=series) for iter_info in self._iter_lists_and_uploaders(series): file_names, changed_files, uploader = iter_info for upload_file_name, upload_file_content in changed_files: if len(upload_file_content) == 0: continue # Skip empty files entry = translation_import_queue.addOrUpdateEntry( upload_file_name, upload_file_content, True, uploader, productseries=series) approver.approve(entry)
def run(self): revision_set = getUtility(IRevisionSet) old_revision = revision_set.getByRevisionId(self.old_revision_id) new_revision = revision_set.getByRevisionId(self.new_revision_id) with server(get_ro_server(), no_replace=True): self.branch_merge_proposal.generateIncrementalDiff( old_revision, new_revision)
def run(self, _check_transaction=False): """See `IBranchUpgradeJob`.""" # Set up the new branch structure with server(get_rw_server(), no_replace=True): upgrade_branch_path = tempfile.mkdtemp() try: upgrade_transport = get_transport(upgrade_branch_path) upgrade_transport.mkdir('.bzr') source_branch_transport = get_transport( self.branch.getInternalBzrUrl()) source_branch_transport.clone('.bzr').copy_tree_to_transport( upgrade_transport.clone('.bzr')) transaction.commit() upgrade_branch = BzrBranch.open_from_transport( upgrade_transport) # No transactions are open so the DB connection won't be # killed. with TransactionFreeOperation(): # Perform the upgrade. upgrade(upgrade_branch.base) # Re-open the branch, since its format has changed. upgrade_branch = BzrBranch.open_from_transport( upgrade_transport) source_branch = BzrBranch.open_from_transport( source_branch_transport) source_branch.lock_write() upgrade_branch.pull(source_branch) upgrade_branch.fetch(source_branch) source_branch.unlock() # Move the branch in the old format to backup.bzr try: source_branch_transport.delete_tree('backup.bzr') except NoSuchFile: pass source_branch_transport.rename('.bzr', 'backup.bzr') source_branch_transport.mkdir('.bzr') upgrade_transport.clone('.bzr').copy_tree_to_transport( source_branch_transport.clone('.bzr')) # Re-open the source branch again. source_branch = BzrBranch.open_from_transport( source_branch_transport) formats = get_branch_formats(source_branch) self.branch.branchChanged( self.branch.stacked_on, self.branch.last_scanned_id, *formats) finally: shutil.rmtree(upgrade_branch_path)
def main(self): if len(self.args) < 1: raise LaunchpadScriptFailure('Please specify a target directory.') if len(self.args) > 1: raise LaunchpadScriptFailure('Too many arguments.') target_dir = self.args[0] with server(get_rw_server()): if self.options.finish: Upgrader.finish_all_upgrades(target_dir, self.logger) else: Upgrader.start_all_upgrades(target_dir, self.logger)
def run(self): """See `IBranchScanJob`.""" from lp.services.scripts import log with server(get_ro_server(), no_replace=True): try: with try_advisory_lock(LockType.BRANCH_SCAN, self.branch.id, Store.of(self.branch)): bzrsync = BzrSync(self.branch, log) bzrsync.syncBranchAndClose() except LostObjectError: log.warning('Skipping branch %s because it has been deleted.' % self._cached_branch_name)
def run(self): """See `IBranchScanJob`.""" from lp.services.scripts import log with server(get_ro_server(), no_replace=True): try: with try_advisory_lock( LockType.BRANCH_SCAN, self.branch.id, Store.of(self.branch)): bzrsync = BzrSync(self.branch, log) bzrsync.syncBranchAndClose() except LostObjectError: log.warning('Skipping branch %s because it has been deleted.' % self._cached_branch_name)
def run(self): """Send all the emails about all the added revisions.""" diff_levels = (BranchSubscriptionNotificationLevel.DIFFSONLY, BranchSubscriptionNotificationLevel.FULL) subscriptions = self.branch.getSubscriptionsByLevel(diff_levels) if not subscriptions: return with server(get_ro_server(), no_replace=True): with read_locked(self.bzr_branch): for revision, revno in self.iterAddedMainline(): assert revno is not None mailer = self.getMailerForRevision( revision, revno, self.generateDiffs()) mailer.sendAll()
def run(self): """See `IRunnableJob`.""" self.checkReady() if self.branch_merge_proposal.source_branch is not None: server_context = server(get_ro_server(), no_replace=True) else: # A no-op context manager. (This could be simplified with # contextlib.ExitStack from Python 3.3.) server_context = contextmanager(lambda: (None for _ in [None]))() # Update related bug links based on commits in the source branch. self.branch_merge_proposal.updateRelatedBugsFromSource() with server_context: with BranchMergeProposalDelta.monitor(self.branch_merge_proposal): PreviewDiff.fromBranchMergeProposal(self.branch_merge_proposal)
def run(self): revision_set = getUtility(IRevisionSet) old_revision = revision_set.getByRevisionId(self.old_revision_id) new_revision = revision_set.getByRevisionId(self.new_revision_id) with server(get_ro_server(), no_replace=True): self.branch_merge_proposal.generateIncrementalDiff(old_revision, new_revision)
def run(self): """See `IRunnableJob`.""" self.checkReady() with server(get_ro_server(), no_replace=True): with BranchMergeProposalDelta.monitor(self.branch_merge_proposal): PreviewDiff.fromBranchMergeProposal(self.branch_merge_proposal)