Exemplo n.º 1
0
    def rename(self, name):
        old_name = self.name
        patch_names = self.patchorder.all
        super(Stack, self).rename(name)
        old_ref_root = 'refs/patches/%s' % old_name
        new_ref_root = 'refs/patches/%s' % name
        empty_id = '0' * 40
        ref_updates = ''
        for pn in patch_names:
            old_ref = '%s/%s' % (old_ref_root, pn)
            new_ref = '%s/%s' % (new_ref_root, pn)
            old_log_ref = old_ref + '.log'
            new_log_ref = new_ref + '.log'
            patch_commit_id = self.repository.refs.get(old_ref).sha1
            log_commit_id = self.repository.refs.get(old_log_ref).sha1

            ref_updates += 'update %s %s %s\n' % (new_ref, patch_commit_id,
                                                  empty_id)
            ref_updates += 'update %s %s %s\n' % (new_log_ref, log_commit_id,
                                                  empty_id)
            ref_updates += 'delete %s %s\n' % (old_ref, patch_commit_id)
            ref_updates += 'delete %s %s\n' % (old_log_ref, log_commit_id)
        self.repository.run(['git', 'update-ref', '--stdin'
                             ]).raw_input(ref_updates).discard_output()

        config.rename_section('branch.%s.stgit' % old_name,
                              'branch.%s.stgit' % name)

        utils.rename(
            os.path.join(self.repository.directory, self._repo_subdir),
            old_name, name)
Exemplo n.º 2
0
Arquivo: stack.py Projeto: snits/stgit
    def rename(self, to_name):
        """Renames a series
        """
        to_stack = Series(to_name)

        if to_stack.is_initialised():
            raise StackException('"%s" already exists' % to_stack.get_name())

        patches = self.get_applied() + self.get_unapplied()

        git.rename_branch(self.get_name(), to_name)

        for patch in patches:
            git.rename_ref('refs/patches/%s/%s' % (self.get_name(), patch),
                           'refs/patches/%s/%s' % (to_name, patch))
            git.rename_ref('refs/patches/%s/%s.log' % (self.get_name(), patch),
                           'refs/patches/%s/%s.log' % (to_name, patch))
        if os.path.isdir(self._dir()):
            rename(os.path.join(self._basedir(), 'patches'),
                   self.get_name(), to_stack.get_name())

        # Rename the config section
        for k in ['branch.%s', 'branch.%s.stgit']:
            config.rename_section(k % self.get_name(), k % to_name)

        self.__init__(to_name)
Exemplo n.º 3
0
    def rename(self, to_name):
        """Renames a series
        """
        to_stack = Series(to_name)

        if to_stack.is_initialised():
            raise StackException('"%s" already exists' % to_stack.get_name())

        patches = self.get_applied() + self.get_unapplied()

        git.rename_branch(self.get_name(), to_name)

        for patch in patches:
            git.rename_ref('refs/patches/%s/%s' % (self.get_name(), patch),
                           'refs/patches/%s/%s' % (to_name, patch))
            git.rename_ref('refs/patches/%s/%s.log' % (self.get_name(), patch),
                           'refs/patches/%s/%s.log' % (to_name, patch))
        if os.path.isdir(self._dir()):
            rename(os.path.join(self._basedir(), 'patches'),
                   self.get_name(), to_stack.get_name())

        # Rename the config section
        for k in ['branch.%s', 'branch.%s.stgit']:
            config.rename_section(k % self.get_name(), k % to_name)

        self.__init__(to_name)
Exemplo n.º 4
0
    def rename(self, new_name):
        old_name = self.name
        patch_names = self.patchorder.all
        super().rename(new_name)
        renames = []
        for pn in patch_names:
            renames.append((_patch_ref(old_name, pn), _patch_ref(new_name, pn)))
        renames.append((_stack_state_ref(old_name), _stack_state_ref(new_name)))

        self.repository.refs.rename('rename %s to %s' % (old_name, new_name), *renames)

        config.rename_section(
            'branch.%s.stgit' % old_name,
            'branch.%s.stgit' % new_name,
        )
Exemplo n.º 5
0
    def rename(self, to_name):
        """Renames a series
        """
        to_stack = Series(to_name)

        if to_stack.is_initialised():
            raise StackException, '"%s" already exists' % to_stack.get_name()

        git.rename_branch(self.get_name(), to_name)

        if os.path.isdir(self._dir()):
            rename(os.path.join(self._basedir(), 'patches'), self.get_name(),
                   to_stack.get_name())
        if os.path.exists(self.__refs_dir):
            rename(os.path.join(self._basedir(), 'refs', 'patches'),
                   self.get_name(), to_stack.get_name())

        # Rename the config section
        config.rename_section("branch.%s" % self.get_name(),
                              "branch.%s" % to_name)

        self.__init__(to_name)
Exemplo n.º 6
0
    def rename(self, new_name):
        old_name = self.name
        patch_names = self.patchorder.all
        super(Stack, self).rename(new_name)
        renames = []
        for pn in patch_names:
            renames.append((_patch_ref(old_name, pn), _patch_ref(new_name, pn)))
            renames.append((_patch_log_ref(old_name, pn), _patch_log_ref(new_name, pn)))
        renames.append((_stack_state_ref(old_name), _stack_state_ref(new_name)))

        self.repository.refs.rename('rename %s to %s' % (old_name, new_name), *renames)

        config.rename_section(
            'branch.%s.stgit' % old_name,
            'branch.%s.stgit' % new_name,
        )

        utils.rename(
            os.path.join(self.repository.directory, self._repo_subdir),
            old_name,
            new_name,
        )