def create( cls, repository, name, create_at=None, parent_remote=None, parent_branch=None, switch_to=False, ): """Create and initialise a Git branch returning the L{Stack} object. @param repository: The L{Repository} where the L{Stack} will be created @param name: The name of the L{Stack} @param create_at: The Git id used as the base for the newly created Git branch @param parent_remote: The name of the remote Git branch @param parent_branch: The name of the parent Git branch """ branch = Branch.create(repository, name, create_at=create_at) try: stack = cls.initialise(repository, name, switch_to=switch_to) except (BranchException, StackException): branch.delete() raise stack.set_parents(parent_remote, parent_branch) return stack
def create( cls, repository, name, msg, create_at=None, parent_remote=None, parent_branch=None, switch_to=False, ): """Create and initialise a Git branch returning the :class:`Stack` object. :param repository: :class:`Repository` where the :class:`Stack` will be created :param name: name of the :class:`Stack` :param msg: message to use in newly created log :param create_at: Git id used as the base for the newly created Git branch :param parent_remote: name of the parent remote Git branch :param parent_branch: name of the parent Git branch """ branch = Branch.create(repository, name, create_at=create_at) try: stack = cls.initialise(repository, name, msg, switch_to=switch_to) except (BranchException, StackException): branch.delete() raise stack.set_parents(parent_remote, parent_branch) return stack