def create(cls, repository, name, create_at=None, parent_remote=None, parent_branch=None): """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.create(repository, name, create_at=create_at) stack = cls.initialise(repository, name) stack.set_parents(parent_remote, parent_branch) return stack
def initialise(cls, repository, name=None): """Initialise a Git branch to handle patch series. @param repository: The L{Repository} where the L{Stack} will be created @param name: The name of the L{Stack} """ if not name: name = repository.current_branch_name # make sure that the corresponding Git branch exists Branch(repository, name) dir = os.path.join(repository.directory, cls._repo_subdir, name) compat_dir = os.path.join(dir, 'patches') if os.path.exists(dir): raise StackException('%s: branch already initialized' % name) # create the stack directory and files utils.create_dirs(dir) utils.create_dirs(compat_dir) PatchOrder.create(dir) config.set(stackupgrade.format_version_key(name), text(stackupgrade.FORMAT_VERSION)) return repository.get_stack(name)
def __init__(self, repository, name): Branch.__init__(self, repository, name) self.patchorder = PatchOrder(self) self.patches = Patches(self) if not stackupgrade.update_to_current_format_version(repository, name): raise StackException('%s: branch not initialized' % name)