~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Merge destroy_tree from bzr.ab

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
 
738
750
                result.set_parent_ids([revision_id])
739
751
        return result
740
752
 
 
753
    def destroy_workingtree(self, keep_files=False):
 
754
        """See BzrDir.destroy_workingtree."""
 
755
        raise errors.UnsupportedOperation(self.destroy_workingtree, self)
 
756
 
741
757
    def get_branch_transport(self, branch_format):
742
758
        """See BzrDir.get_branch_transport()."""
743
759
        if branch_format is None:
883
899
        from bzrlib.workingtree import WorkingTreeFormat
884
900
        return WorkingTreeFormat.get_default_format().initialize(self, revision_id)
885
901
 
 
902
    def destroy_workingtree(self, keep_files=False):
 
903
        """See BzrDir.destroy_workingtree."""
 
904
        wt = self.open_workingtree()
 
905
        if keep_files is False:
 
906
            repository = wt.branch.repository
 
907
            empty = repository.revision_tree(bzrlib.revision.NULL_REVISION)
 
908
            wt.revert([], old_tree=empty)
 
909
        wt._control_files._transport.delete_tree('.')
 
910
 
886
911
    def _get_mkdir_mode(self):
887
912
        """Figure out the mode to use when creating a bzrdir subdir."""
888
913
        temp_control = LockableFiles(self.transport, '', TransportLock)