示例#1
0
 def fromCodeImport(cls, code_import):
     """Convert a `CodeImport` to an instance."""
     branch = code_import.branch
     if branch.stacked_on is not None and not branch.stacked_on.private:
         stacked_path = branch_id_alias(branch.stacked_on)
         stacked_on_url = compose_public_url('http', stacked_path)
     else:
         stacked_on_url = None
     if code_import.rcs_type == RevisionControlSystems.SVN:
         return cls(
             branch.id, 'svn', str(code_import.url),
             stacked_on_url=stacked_on_url)
     elif code_import.rcs_type == RevisionControlSystems.BZR_SVN:
         return cls(
             branch.id, 'bzr-svn', str(code_import.url),
             stacked_on_url=stacked_on_url)
     elif code_import.rcs_type == RevisionControlSystems.CVS:
         return cls(
             branch.id, 'cvs',
             cvs_root=str(code_import.cvs_root),
             cvs_module=str(code_import.cvs_module))
     elif code_import.rcs_type == RevisionControlSystems.GIT:
         return cls(
             branch.id, 'git', str(code_import.url),
             stacked_on_url=stacked_on_url)
     elif code_import.rcs_type == RevisionControlSystems.BZR:
         return cls(
             branch.id, 'bzr', str(code_import.url),
             stacked_on_url=stacked_on_url)
     else:
         raise AssertionError("Unknown rcstype %r." % code_import.rcs_type)
 def test_getByUrl_with_alias(self):
     """getByUrl works with +branch aliases."""
     product = make_product_with_branch(self.factory)
     branch = product.development_focus.branch
     path = BRANCH_ALIAS_PREFIX + '/' + product.name
     url = compose_public_url('bzr+ssh', path)
     branch_lookup = getUtility(IBranchLookup)
     self.assertEqual(branch, branch_lookup.getByUrl(url))
 def test_getByUrl_with_alias(self):
     """getByUrl works with +branch aliases."""
     product = make_product_with_branch(self.factory)
     branch = product.development_focus.branch
     path = BRANCH_ALIAS_PREFIX + '/' + product.name
     url = compose_public_url('bzr+ssh', path)
     branch_lookup = getUtility(IBranchLookup)
     self.assertEqual(branch, branch_lookup.getByUrl(url))
 def test_getByUrl_with_id_alias(self):
     """getByUrl works with +branch-id aliases."""
     branch = self.factory.makeAnyBranch()
     url = compose_public_url('bzr+ssh', branch_id_alias(branch))
     branch_lookup = getUtility(IBranchLookup)
     self.assertEqual(branch, branch_lookup.getByUrl(url))
 def test_getByUrl_with_id_alias(self):
     """getByUrl works with +branch-id aliases."""
     branch = self.factory.makeAnyBranch()
     url = compose_public_url('bzr+ssh', branch_id_alias(branch))
     branch_lookup = getUtility(IBranchLookup)
     self.assertEqual(branch, branch_lookup.getByUrl(url))
示例#6
0
 def _compose_bzr_ssh_url(unique_name, path, suffix):
     if not path.startswith('~'):
         path = '%s/%s' % (BRANCH_ALIAS_PREFIX, path)
     return compose_public_url('bzr+ssh', path, suffix)
示例#7
0
 def _compose_http_url(unique_name, path, suffix):
     return compose_public_url('http', unique_name, suffix)
示例#8
0
 def _compose_bzr_ssh_url(unique_name, path, suffix):
     if not path.startswith("~"):
         path = "%s/%s" % (BRANCH_ALIAS_PREFIX, path)
     return compose_public_url("bzr+ssh", path, suffix)
示例#9
0
 def _compose_http_url(unique_name, path, suffix):
     return compose_public_url("http", unique_name, suffix)