/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-10-02 21:41:43 UTC
  • mto: (2100.3.5 by-reference-trees)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: abentley@panoramicfeedback.com-20061002214143-31a300ef43cfd8b8
Get extract working for standalone trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
import warnings
53
53
 
54
54
import bzrlib
55
 
from bzrlib import bzrdir, errors, ignores, osutils, urlutils
 
55
from bzrlib import bzrdir, errors, ignores, osutils, urlutils, repository
56
56
from bzrlib.atomicfile import AtomicFile
57
57
import bzrlib.branch
58
58
from bzrlib.conflicts import Conflict, ConflictList, CONFLICT_SUFFIXES
842
842
            other_tree.unlock()
843
843
        other_tree.bzrdir.destroy_workingtree_metadata()
844
844
 
 
845
    @needs_tree_write_lock
 
846
    def extract(self, file_id):
 
847
        """Extract a subtree from this tree.
 
848
        
 
849
        A new branch will be created, relative to the path for this tree.
 
850
        """
 
851
        sub_path = self.id2path(file_id)
 
852
        branch_transport = self.branch.bzrdir.root_transport.clone(sub_path)
 
853
        format = bzrdir.BzrDirMetaFormat1()
 
854
        format.repository_format = repository.RepositoryFormatKnit2()
 
855
        branch_bzrdir = format.initialize_on_transport(branch_transport)
 
856
        try:
 
857
            repo = branch_bzrdir.find_repository()
 
858
        except errors.NoRepositoryPresent:
 
859
            repo = branch_bzrdir.create_repository()
 
860
            assert repo.supports_rich_root()
 
861
        else:
 
862
            if not repo.supports_rich_root():
 
863
                raise 'Gah'
 
864
        new_branch = branch_bzrdir.create_branch()
 
865
        for parent_id in self.get_parent_ids():
 
866
            new_branch.fetch(self.branch, parent_id)
 
867
        tree_transport = self.bzrdir.root_transport.clone(sub_path)
 
868
        if tree_transport.base != branch_transport.base:
 
869
            tree_bzrdir = format.initialize_on_transport(tree_transport)
 
870
            # create branch reference
 
871
            pass
 
872
        else:
 
873
            tree_bzrdir = branch_bzrdir
 
874
        wt = tree_bzrdir.create_workingtree('null:')
 
875
        wt.set_parent_ids(self.get_parent_ids())
 
876
        my_inv = self.inventory
 
877
        child_inv = Inventory(root_id=None)
 
878
        new_root = my_inv[file_id]
 
879
        my_inv.remove_recursive_id(file_id)
 
880
        new_root.parent_id = None
 
881
        child_inv.add(new_root)
 
882
        self._write_inventory(my_inv)
 
883
        wt._write_inventory(child_inv)
 
884
        return wt
 
885
 
845
886
    @needs_read_lock
846
887
    def merge_modified(self):
847
888
        try: