Ejemplo n.º 1
0
 def cleanup(self):
     assert not self.protected, 'attempt to delete protected stack'
     for pn in self.patchorder.all:
         patch = self.patches.get(pn)
         patch.delete()
     shutil.rmtree(self.directory)
     config.remove_section('branch.%s.stgit' % self.name)
Ejemplo n.º 2
0
 def cleanup(self):
     assert not self.protected, 'attempt to delete protected stack'
     for pn in self.patchorder.all:
         patch = self.patches.get(pn)
         patch.delete()
     self.repository.refs.delete(self.state_ref)
     config.remove_section('branch.%s.stgit' % self.name)
Ejemplo n.º 3
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())
Ejemplo n.º 4
0
Archivo: stack.py Proyecto: 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())