def initialise(cls, repository, name=None, switch_to=False): """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 = Branch(repository, name) dir = os.path.join(repository.directory, cls._repo_subdir, name) if os.path.exists(dir): raise StackException('%s: branch already initialized' % name) if switch_to: branch.switch_to() # create the stack directory and files utils.create_dirs(dir) compat_dir = os.path.join(dir, 'patches') utils.create_dirs(compat_dir) PatchOrder.create(dir) config.set(stackupgrade.format_version_key(name), str(stackupgrade.FORMAT_VERSION)) return repository.get_stack(name)
def initialise(cls, repository, name=None, msg='initialise', switch_to=False): """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 = Branch(repository, name) stack_state_ref = _stack_state_ref(name) if repository.refs.exists(stack_state_ref): raise StackException('%s: stack already initialized' % name) dir = os.path.join(repository.directory, cls._repo_subdir, name) if os.path.exists(dir): raise StackException('%s: branch already initialized' % name) if switch_to: branch.switch_to() # create the stack directory and files utils.create_dirs(dir) compat_dir = os.path.join(dir, 'patches') utils.create_dirs(compat_dir) PatchOrder.create(dir) config.set( stackupgrade.format_version_key(name), str(stackupgrade.FORMAT_VERSION) ) state_commit = log.StackState( repository, prev=None, head=branch.head, applied=[], unapplied=[], hidden=[], patches={}, message=msg, ).commit_state() repository.refs.set(stack_state_ref, state_commit, msg) return repository.get_stack(name)
def init(self, create_at=False, parent_remote=None, parent_branch=None): """Initialises the stgit series """ if self.is_initialised(): raise StackException, "%s already initialized" % self.get_name() for d in [self._dir()]: if os.path.exists(d): raise StackException, "%s already exists" % d if create_at != False: git.create_branch(self.get_name(), create_at) os.makedirs(self.__patch_dir) self.set_parent(parent_remote, parent_branch) self.create_empty_field("applied") self.create_empty_field("unapplied") config.set(stackupgrade.format_version_key(self.get_name()), str(stackupgrade.FORMAT_VERSION))
def init(self, create_at=False, parent_remote=None, parent_branch=None): """Initialises the stgit series """ if self.is_initialised(): raise StackException('%s already initialized' % self.get_name()) for d in [self._dir()]: if os.path.exists(d): raise StackException('%s already exists' % d) if create_at is not False: git.create_branch(self.get_name(), create_at) os.makedirs(self.__patch_dir) self.set_parent(parent_remote, parent_branch) self.create_empty_field('applied') self.create_empty_field('unapplied') config.set(stackupgrade.format_version_key(self.get_name()), text(stackupgrade.FORMAT_VERSION))
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 git.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 is_initialised(self): """Checks if series is already initialised """ return config.get(stackupgrade.format_version_key(self.get_name()) ) is not None