예제 #1
0
    def delete(self, force=False, cleanup=False):
        """Deletes an stgit series
        """
        if self.is_initialised():
            patches = (
                self.get_unapplied()
                + self.get_applied()
                + self.get_hidden()
            )
            if not force and patches:
                raise StackException(
                    'Cannot %s: the series still contains patches' %
                    ('delete', 'clean up')[cleanup])
            for p in patches:
                self.get_patch(p).delete()

            # remove the trash directory if any
            if os.path.exists(self.__trash_dir):
                for fname in os.listdir(self.__trash_dir):
                    os.remove(os.path.join(self.__trash_dir, fname))
                os.rmdir(self.__trash_dir)

            # FIXME: find a way to get rid of those manual removals
            # (move functionality to StgitObject ?)
            if os.path.exists(self.__applied_file):
                os.remove(self.__applied_file)
            if os.path.exists(self.__unapplied_file):
                os.remove(self.__unapplied_file)
            if os.path.exists(self.__hidden_file):
                os.remove(self.__hidden_file)
            if os.path.exists(self._dir() + '/orig-base'):
                os.remove(self._dir() + '/orig-base')

            if not os.listdir(self.__patch_dir):
                os.rmdir(self.__patch_dir)
            else:
                out.warn('Patch directory %s is not empty' % self.__patch_dir)

            try:
                os.removedirs(self._dir())
            except OSError:
                raise StackException('Series directory %s is not empty'
                                     % self._dir())

        if not cleanup:
            try:
                git.delete_branch(self.get_name())
            except git.GitException:
                out.warn('Could not delete branch "%s"' % self.get_name())
            config.remove_section('branch.%s' % self.get_name())

        config.remove_section('branch.%s.stgit' % self.get_name())
예제 #2
0
파일: stack.py 프로젝트: snits/stgit
    def delete(self, force = False, cleanup = False):
        """Deletes an stgit series
        """
        if self.is_initialised():
            patches = self.get_unapplied() + self.get_applied() + \
                    self.get_hidden()
            if not force and patches:
                raise StackException(
                    'Cannot %s: the series still contains patches' %
                    ('delete', 'clean up')[cleanup])
            for p in patches:
                self.get_patch(p).delete()

            # remove the trash directory if any
            if os.path.exists(self.__trash_dir):
                for fname in os.listdir(self.__trash_dir):
                    os.remove(os.path.join(self.__trash_dir, fname))
                os.rmdir(self.__trash_dir)

            # FIXME: find a way to get rid of those manual removals
            # (move functionality to StgitObject ?)
            if os.path.exists(self.__applied_file):
                os.remove(self.__applied_file)
            if os.path.exists(self.__unapplied_file):
                os.remove(self.__unapplied_file)
            if os.path.exists(self.__hidden_file):
                os.remove(self.__hidden_file)
            if os.path.exists(self._dir()+'/orig-base'):
                os.remove(self._dir()+'/orig-base')

            if not os.listdir(self.__patch_dir):
                os.rmdir(self.__patch_dir)
            else:
                out.warn('Patch directory %s is not empty' % self.__patch_dir)

            try:
                os.removedirs(self._dir())
            except OSError:
                raise StackException('Series directory %s is not empty'
                                     % self._dir())

        if not cleanup:
            try:
                git.delete_branch(self.get_name())
            except git.GitException:
                out.warn('Could not delete branch "%s"' % self.get_name())
            config.remove_section('branch.%s' % self.get_name())

        config.remove_section('branch.%s.stgit' % self.get_name())
예제 #3
0
파일: branch.py 프로젝트: c0ns0le/cygwin
def __delete_branch(doomed_name, force = False):
    doomed = stack.Series(doomed_name)

    if doomed.get_protected():
        raise CmdException, 'This branch is protected. Delete is not permitted'

    out.start('Deleting branch "%s"' % doomed_name)

    if __is_current_branch(doomed_name):
        check_local_changes()
        check_conflicts()
        check_head_top_equal()

        if doomed_name != 'master':
            git.switch_branch('master')

    doomed.delete(force)

    if doomed_name != 'master':
        git.delete_branch(doomed_name)

    out.done()
예제 #4
0
def __delete_branch(doomed_name, force=False):
    doomed = stack.Series(doomed_name)

    if doomed.get_protected():
        raise CmdException, 'This branch is protected. Delete is not permitted'

    out.start('Deleting branch "%s"' % doomed_name)

    if __is_current_branch(doomed_name):
        check_local_changes()
        check_conflicts()
        check_head_top_equal()

        if doomed_name != 'master':
            git.switch_branch('master')

    doomed.delete(force)

    if doomed_name != 'master':
        git.delete_branch(doomed_name)

    out.done()