~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
67
67
BZR_BRANCH_FORMAT_5 = "Bazaar-NG branch, format 5\n"
68
 
BZR_BRANCH_FORMAT_6 = "Bazaar-NG branch, format 6\n"
 
68
BZR_BRANCH_FORMAT_6 = "Bazaar Branch Format 6 (bzr 0.15)\n"
69
69
 
70
70
 
71
71
# TODO: Maybe include checks for common corruption of newlines, etc?
654
654
            format = bzrdir.BzrDirMetaFormat1()
655
655
            format.repository_format = weaverepo.RepositoryFormat7()
656
656
        else:
657
 
            format = self.repository.bzrdir.cloning_metadir()
 
657
            format = self.repository.bzrdir.checkout_metadir()
658
658
            format.branch_format = self._format
659
659
        return format
660
660
 
674
674
        except errors.FileExists:
675
675
            pass
676
676
        if lightweight:
677
 
            checkout = bzrdir.BzrDirMetaFormat1().initialize_on_transport(t)
 
677
            format = self._get_checkout_format()
 
678
            checkout = format.initialize_on_transport(t)
678
679
            BranchReferenceFormat().initialize(checkout, self)
679
680
        else:
680
681
            format = self._get_checkout_format()
685
686
            # pull up to the specified revision_id to set the initial 
686
687
            # branch tip correctly, and seed it with history.
687
688
            checkout_branch.pull(self, stop_revision=revision_id)
688
 
        return checkout.create_workingtree(revision_id)
 
689
        tree = checkout.create_workingtree(revision_id)
 
690
        basis_tree = tree.basis_tree()
 
691
        basis_tree.lock_read()
 
692
        try:
 
693
            for path, file_id in basis_tree.iter_references():
 
694
                reference_parent = self.reference_parent(file_id, path)
 
695
                reference_parent.create_checkout(tree.abspath(path),
 
696
                    basis_tree.get_reference_revision(file_id, path),
 
697
                    lightweight)
 
698
        finally:
 
699
            basis_tree.unlock()
 
700
        return tree
 
701
 
 
702
    def reference_parent(self, file_id, path):
 
703
        """Return the parent branch for a tree-reference file_id
 
704
        :param file_id: The file_id of the tree reference
 
705
        :param path: The path of the file_id in the tree
 
706
        :return: A branch associated with the file_id
 
707
        """
 
708
        # FIXME should provide multiple branches, based on config
 
709
        return Branch.open(self.bzrdir.root_transport.clone(path).base)
689
710
 
690
711
    def supports_tags(self):
691
712
        return self._format.supports_tags()
1003
1024
 
1004
1025
    def get_format_string(self):
1005
1026
        """See BranchFormat.get_format_string()."""
1006
 
        return "Bazaar-NG branch format 6\n"
 
1027
        return "Bazaar Branch Format 6 (bzr 0.15)\n"
1007
1028
 
1008
1029
    def get_format_description(self):
1009
1030
        """See BranchFormat.get_format_description()."""
1333
1354
        self.set_revision_history(history)
1334
1355
 
1335
1356
    def _gen_revision_history(self):
1336
 
        get_cached_utf8 = cache_utf8.get_cached_utf8
1337
 
        history = [get_cached_utf8(l.rstrip('\r\n')) for l in
1338
 
                self.control_files.get('revision-history').readlines()]
 
1357
        history = self.control_files.get('revision-history').read().split('\n')
 
1358
        if history[-1:] == ['']:
 
1359
            # There shouldn't be a trailing newline, but just in case.
 
1360
            history.pop()
1339
1361
        return history
1340
1362
 
1341
1363
    @needs_read_lock