def _getBranchNamespaceExtras(self, path, requester): """Get the branch namespace, branch name and callback for the path. If the path defines a full branch path including the owner and branch name, then the namespace that is returned is the namespace for the owner and the branch target specified. If the path uses an lp short name, then we only allow the requester to create a branch if they have permission to link the newly created branch to the short name target. If there is an existing branch already linked, then BranchExists is raised. The branch name that is used is determined by the namespace as the first unused name starting with 'trunk'. """ if path.startswith(BRANCH_ALIAS_PREFIX + '/'): path = path[len(BRANCH_ALIAS_PREFIX) + 1:] if not path.startswith('~'): context = getUtility(ILinkedBranchTraverser).traverse(path) target = IBranchTarget(context) namespace = target.getNamespace(requester) branch_name = namespace.findUnusedName('trunk') def link_func(new_branch): link = ICanHasLinkedBranch(context) link.setBranch(new_branch, requester) return namespace, branch_name, link_func, path namespace_name, branch_name = split_unique_name(path) namespace = lookup_branch_namespace(namespace_name) return namespace, branch_name, None, path
def _serializeControlDirectory(self, requester, lookup): try: namespace = lookup_branch_namespace(lookup['control_name']) except (InvalidNamespace, NotFoundError): return trailing_path = lookup['trailing'].lstrip('/') if not ('.bzr' == trailing_path or trailing_path.startswith('.bzr/')): # '.bzr' is OK, '.bzr/foo' is OK, '.bzrfoo' is not. return default_branch = namespace.target.default_stacked_on_branch if default_branch is None: return try: path = branch_id_alias(default_branch) except Unauthorized: return return (CONTROL_TRANSPORT, { 'default_stack_on': escape(path) }, escape(trailing_path))
def _serializeControlDirectory(self, requester, lookup): try: namespace = lookup_branch_namespace(lookup['control_name']) except (InvalidNamespace, NotFoundError): return trailing_path = lookup['trailing'].lstrip('/') if not ('.bzr' == trailing_path or trailing_path.startswith('.bzr/')): # '.bzr' is OK, '.bzr/foo' is OK, '.bzrfoo' is not. return default_branch = namespace.target.default_stacked_on_branch if default_branch is None: return try: path = branch_id_alias(default_branch) except Unauthorized: return return ( CONTROL_TRANSPORT, {'default_stack_on': escape(path)}, escape(trailing_path))