~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Introduce BzrDir.destroy_workingtree

Show diffs side-by-side

added added

removed removed

Lines of Context:
341
341
        """
342
342
        raise NotImplementedError(self.create_workingtree)
343
343
 
 
344
    def destroy_workingtree(self, keep_files=False):
 
345
        """Destroy the working tree at this BzrDir.
 
346
 
 
347
        Formats that do not support this may raise UnsupportedOperation.
 
348
        if keep_files is False, locally-modified files are unversioned,
 
349
        and unmodified files are deleted, as per revert.
 
350
 
 
351
        :param keep_files: If true, delete only the checkout metadata, not
 
352
            the tree contents.
 
353
        """
 
354
        raise NotImplementedError(self.destroy_workingtree)
 
355
 
344
356
    def find_repository(self):
345
357
        """Find the repository that should be used for a_bzrdir.
346
358
 
733
745
                result.set_parent_ids([revision_id])
734
746
        return result
735
747
 
 
748
    def destroy_workingtree(self, keep_files=False):
 
749
        """See BzrDir.destroy_workingtree."""
 
750
        raise errors.UnsupportedOperation(self.destroy_workingtree, self)
 
751
 
736
752
    def get_branch_transport(self, branch_format):
737
753
        """See BzrDir.get_branch_transport()."""
738
754
        if branch_format is None:
878
894
        from bzrlib.workingtree import WorkingTreeFormat
879
895
        return WorkingTreeFormat.get_default_format().initialize(self, revision_id)
880
896
 
 
897
    def destroy_workingtree(self, keep_files=False):
 
898
        """See BzrDir.destroy_workingtree."""
 
899
        wt = self.open_workingtree()
 
900
        if keep_files is False:
 
901
            repository = wt.branch.repository
 
902
            empty = repository.revision_tree(bzrlib.revision.NULL_REVISION)
 
903
            wt.revert([], old_tree=empty)
 
904
        wt._control_files._transport.delete_tree('.')
 
905
 
881
906
    def _get_mkdir_mode(self):
882
907
        """Figure out the mode to use when creating a bzrdir subdir."""
883
908
        temp_control = LockableFiles(self.transport, '', TransportLock)