def main(self): force_bzr_to_use_urllib() set_default_timeout_function(lambda: 60.0) source_details = CodeImportSourceDetails.fromArguments(self.args) if source_details.rcstype == 'git': if source_details.target_rcstype == 'bzr': import_worker_cls = GitImportWorker else: import_worker_cls = GitToGitImportWorker elif source_details.rcstype == 'bzr-svn': import_worker_cls = BzrSvnImportWorker elif source_details.rcstype == 'bzr': import_worker_cls = BzrImportWorker elif source_details.rcstype == 'cvs': import_worker_cls = CSCVSImportWorker else: raise AssertionError('unknown rcstype %r' % source_details.rcstype) opener_policy = opener_policies[self.options.access_policy]( source_details.rcstype, source_details.target_rcstype) if source_details.target_rcstype == 'bzr': import_worker = import_worker_cls( source_details, get_transport(config.codeimport.foreign_tree_store), get_default_bazaar_branch_store(), self.logger, opener_policy) else: import_worker = import_worker_cls(source_details, self.logger, opener_policy) return import_worker.run()
def _getImportDataForJobID(self, job_id): job = self._getJob(job_id) arguments = CodeImportSourceDetails.fromCodeImport( job.code_import).asArguments() branch = job.code_import.branch branch_url = canonical_url(branch) log_file_name = '%s.log' % branch.unique_name[1:].replace('/', '-') return (arguments, branch_url, log_file_name)
def test_getImportDataForJobID(self): # getImportDataForJobID returns the worker arguments, branch url and # log file name for an import corresponding to a particular job. code_import_job = self.makeCodeImportJob(running=True) code_import = removeSecurityProxy(code_import_job).code_import code_import_arguments, branch_url, log_file_name = self.api.getImportDataForJobID(code_import_job.id) import_as_arguments = CodeImportSourceDetails.fromCodeImport(code_import).asArguments() expected_log_file_name = "%s.log" % (code_import.branch.unique_name[1:].replace("/", "-")) self.assertEqual( (import_as_arguments, canonical_url(code_import.branch), expected_log_file_name), (code_import_arguments, branch_url, log_file_name), )
def test_getImportDataForJobID(self): # getImportDataForJobID returns the worker arguments, branch url and # log file name for an import corresponding to a particular job. code_import_job = self.makeCodeImportJob(running=True) code_import = removeSecurityProxy(code_import_job).code_import code_import_arguments, branch_url, log_file_name = \ self.api.getImportDataForJobID(code_import_job.id) import_as_arguments = CodeImportSourceDetails.fromCodeImport( code_import).asArguments() expected_log_file_name = '%s.log' % ( code_import.branch.unique_name[1:].replace('/', '-')) self.assertEqual((import_as_arguments, canonical_url( code_import.branch), expected_log_file_name), (code_import_arguments, branch_url, log_file_name))
def getStartedJobForImport(self, code_import): """Get a started `CodeImportJob` for `code_import`. This method approves the import, creates a job, marks it started and returns the job. It also makes sure there are no branches or foreign trees in the default stores to interfere with processing this job. """ source_details = CodeImportSourceDetails.fromCodeImport(code_import) clean_up_default_stores_for_import(source_details) self.addCleanup(clean_up_default_stores_for_import, source_details) if code_import.review_status != CodeImportReviewStatus.REVIEWED: code_import.updateFromData( {'review_status': CodeImportReviewStatus.REVIEWED}, self.factory.makePerson()) job = getUtility(ICodeImportJobSet).getJobForMachine('machine', 10) self.assertEqual(code_import, job.code_import) return job
def main(self): force_bzr_to_use_urllib() source_details = CodeImportSourceDetails.fromArguments(self.args) if source_details.rcstype == 'git': import_worker_cls = GitImportWorker elif source_details.rcstype == 'bzr-svn': import_worker_cls = BzrSvnImportWorker elif source_details.rcstype == 'bzr': import_worker_cls = BzrImportWorker elif source_details.rcstype in ['cvs', 'svn']: import_worker_cls = CSCVSImportWorker else: raise AssertionError( 'unknown rcstype %r' % source_details.rcstype) import_worker = import_worker_cls( source_details, get_transport(config.codeimport.foreign_tree_store), get_default_bazaar_branch_store(), self.logger, opener_policies[self.options.access_policy]) return import_worker.run()