~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Cleaner implementation of destroy_working_tree

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):
 
344
    def destroy_workingtree(self):
345
345
        """Destroy the working tree at this BzrDir.
346
346
 
347
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
348
        """
354
349
        raise NotImplementedError(self.destroy_workingtree)
355
350
 
 
351
    def destroy_workingtree_metadata(self):
 
352
        """Destroy the control files for the working tree at this BzrDir.
 
353
 
 
354
        The contents of working tree files are not affected.
 
355
        Formats that do not support this may raise UnsupportedOperation.
 
356
        """
 
357
        raise NotImplementedError(self.destroy_workingtree_metadata)
 
358
 
356
359
    def find_repository(self):
357
360
        """Find the repository that should be used for a_bzrdir.
358
361
 
745
748
                result.set_parent_ids([revision_id])
746
749
        return result
747
750
 
748
 
    def destroy_workingtree(self, keep_files=False):
 
751
    def destroy_workingtree(self):
749
752
        """See BzrDir.destroy_workingtree."""
750
753
        raise errors.UnsupportedOperation(self.destroy_workingtree, self)
751
754
 
 
755
    def destroy_workingtree_metadata(self):
 
756
        """See BzrDir.destroy_workingtree_metadata."""
 
757
        raise errors.UnsupportedOperation(self.destroy_workingtree_metadata, 
 
758
                                          self)
 
759
 
752
760
    def get_branch_transport(self, branch_format):
753
761
        """See BzrDir.get_branch_transport()."""
754
762
        if branch_format is None:
894
902
        from bzrlib.workingtree import WorkingTreeFormat
895
903
        return WorkingTreeFormat.get_default_format().initialize(self, revision_id)
896
904
 
897
 
    def destroy_workingtree(self, keep_files=False):
 
905
    def destroy_workingtree(self):
898
906
        """See BzrDir.destroy_workingtree."""
899
907
        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('.')
 
908
        repository = wt.branch.repository
 
909
        empty = repository.revision_tree(bzrlib.revision.NULL_REVISION)
 
910
        wt.revert([], old_tree=empty)
 
911
        self.destroy_workingtree_metadata()
 
912
 
 
913
    def destroy_workingtree_metadata(self):
 
914
        self.transport.delete_tree('checkout')
905
915
 
906
916
    def _get_mkdir_mode(self):
907
917
        """Figure out the mode to use when creating a bzrdir subdir."""