~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-10-07 13:17:20 UTC
  • mto: (2100.3.5 by-reference-trees)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20061007131720-b9a1a0387f949e2a
Support extracting with checkouts

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, repository
 
55
from bzrlib import (
 
56
    branch,
 
57
    bzrdir, 
 
58
    errors, 
 
59
    ignores, 
 
60
    osutils, 
 
61
    urlutils, 
 
62
    repository,
 
63
    )
56
64
from bzrlib.atomicfile import AtomicFile
57
65
import bzrlib.branch
58
66
from bzrlib.conflicts import Conflict, ConflictList, CONFLICT_SUFFIXES
843
851
        other_tree.bzrdir.destroy_workingtree_metadata()
844
852
 
845
853
    @needs_tree_write_lock
846
 
    def extract(self, file_id):
 
854
    def extract(self, file_id, format=None):
847
855
        """Extract a subtree from this tree.
848
856
        
849
857
        A new branch will be created, relative to the path for this tree.
850
858
        """
 
859
        def mkdirs(path):
 
860
            segments = osutils.splitpath(path)
 
861
            transport = self.branch.bzrdir.root_transport
 
862
            for name in segments:
 
863
                transport = transport.clone(name)
 
864
                try:
 
865
                    transport.mkdir('.')
 
866
                except errors.FileExists:
 
867
                    pass
 
868
            return transport
 
869
            
851
870
        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()
 
871
        branch_transport = mkdirs(sub_path)
 
872
        if format is None:
 
873
            format = bzrdir.BzrDirMetaFormat1()
 
874
            format.repository_format = repository.RepositoryFormatKnit2()
 
875
        try:
 
876
            branch_transport.mkdir('.')
 
877
        except errors.FileExists:
 
878
            pass
855
879
        branch_bzrdir = format.initialize_on_transport(branch_transport)
856
880
        try:
857
881
            repo = branch_bzrdir.find_repository()
867
891
        tree_transport = self.bzrdir.root_transport.clone(sub_path)
868
892
        if tree_transport.base != branch_transport.base:
869
893
            tree_bzrdir = format.initialize_on_transport(tree_transport)
870
 
            # create branch reference
871
 
            pass
 
894
            branch.BranchReferenceFormat().initialize(tree_bzrdir, new_branch)
872
895
        else:
873
896
            tree_bzrdir = branch_bzrdir
874
897
        wt = tree_bzrdir.create_workingtree('null:')