~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-31 19:56:19 UTC
  • mto: This revision was merged to the branch mainline in revision 4592.
  • Revision ID: john@arbash-meinel.com-20090731195619-xabumey07q2w1fge
Change the Makefile to stage things into a build directory
rather than building inside the tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
from bzrlib.trace import (
78
78
    mutter,
79
79
    note,
80
 
    warning,
81
80
    )
82
81
 
83
82
from bzrlib import (
129
128
        return True
130
129
 
131
130
    def check_conversion_target(self, target_format):
132
 
        """Check that a bzrdir as a whole can be converted to a new format."""
133
 
        # The only current restriction is that the repository content can be 
134
 
        # fetched compatibly with the target.
135
131
        target_repo_format = target_format.repository_format
136
 
        try:
137
 
            self.open_repository()._format.check_conversion_target(
138
 
                target_repo_format)
139
 
        except errors.NoRepositoryPresent:
140
 
            # No repo, no problem.
141
 
            pass
 
132
        source_repo_format = self._format.repository_format
 
133
        source_repo_format.check_conversion_target(target_repo_format)
142
134
 
143
135
    @staticmethod
144
136
    def _check_supported(format, allow_unsupported,
584
576
            # permissions as the .bzr directory (probably a bug in copy_tree)
585
577
            old_path = self.root_transport.abspath('.bzr')
586
578
            new_path = self.root_transport.abspath('backup.bzr')
587
 
            ui.ui_factory.note('making backup of %s\n  to %s' % (old_path, new_path,))
 
579
            pb.note('making backup of %s' % (old_path,))
 
580
            pb.note('  to %s' % (new_path,))
588
581
            self.root_transport.copy_tree('.bzr', 'backup.bzr')
589
582
            return (old_path, new_path)
590
583
        finally:
1391
1384
        # that can do wonky stuff here, and that only
1392
1385
        # happens for creating checkouts, which cannot be
1393
1386
        # done on this format anyway. So - acceptable wart.
1394
 
        if hardlink:
1395
 
            warning("can't support hardlinked working trees in %r"
1396
 
                % (self,))
1397
1387
        try:
1398
1388
            result = self.open_workingtree(recommend_upgrade=False)
1399
1389
        except errors.NoSuchFile:
1536
1526
    This is a deprecated format and may be removed after sept 2006.
1537
1527
    """
1538
1528
 
1539
 
    def has_workingtree(self):
1540
 
        """See BzrDir.has_workingtree."""
1541
 
        return True
1542
 
    
1543
1529
    def open_repository(self):
1544
1530
        """See BzrDir.open_repository."""
1545
1531
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1561
1547
    This is a deprecated format and may be removed after sept 2006.
1562
1548
    """
1563
1549
 
1564
 
    def has_workingtree(self):
1565
 
        """See BzrDir.has_workingtree."""
1566
 
        return True
1567
 
    
1568
1550
    def open_repository(self):
1569
1551
        """See BzrDir.open_repository."""
1570
1552
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1648
1630
 
1649
1631
    def get_branch_transport(self, branch_format):
1650
1632
        """See BzrDir.get_branch_transport()."""
1651
 
        # XXX: this shouldn't implicitly create the directory if it's just
1652
 
        # promising to get a transport -- mbp 20090727
1653
1633
        if branch_format is None:
1654
1634
            return self.transport.clone('branch')
1655
1635
        try:
1690
1670
            pass
1691
1671
        return self.transport.clone('checkout')
1692
1672
 
1693
 
    def has_workingtree(self):
1694
 
        """Tell if this bzrdir contains a working tree.
1695
 
 
1696
 
        This will still raise an exception if the bzrdir has a workingtree that
1697
 
        is remote & inaccessible.
1698
 
 
1699
 
        Note: if you're going to open the working tree, you should just go
1700
 
        ahead and try, and not ask permission first.
1701
 
        """
1702
 
        from bzrlib.workingtree import WorkingTreeFormat
1703
 
        try:
1704
 
            WorkingTreeFormat.find_format(self)
1705
 
        except errors.NoWorkingTree:
1706
 
            return False
1707
 
        return True
1708
 
 
1709
1673
    def needs_format_conversion(self, format=None):
1710
1674
        """See BzrDir.needs_format_conversion()."""
1711
1675
        if format is None:
1827
1791
    def probe_transport(klass, transport):
1828
1792
        """Return the .bzrdir style format present in a directory."""
1829
1793
        try:
1830
 
            format_string = transport.get_bytes(".bzr/branch-format")
 
1794
            format_string = transport.get(".bzr/branch-format").read()
1831
1795
        except errors.NoSuchFile:
1832
1796
            raise errors.NotBranchError(path=transport.base)
1833
1797
 
2610
2574
        """See Converter.convert()."""
2611
2575
        self.bzrdir = to_convert
2612
2576
        self.pb = pb
2613
 
        ui.ui_factory.note('starting upgrade from format 4 to 5')
 
2577
        self.pb.note('starting upgrade from format 4 to 5')
2614
2578
        if isinstance(self.bzrdir.transport, local.LocalTransport):
2615
2579
            self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2616
2580
        self._convert_to_weaves()
2617
2581
        return BzrDir.open(self.bzrdir.root_transport.base)
2618
2582
 
2619
2583
    def _convert_to_weaves(self):
2620
 
        ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
 
2584
        self.pb.note('note: upgrade may be faster if all store files are ungzipped first')
2621
2585
        try:
2622
2586
            # TODO permissions
2623
2587
            stat = self.bzrdir.transport.stat('weaves')
2651
2615
        self.pb.clear()
2652
2616
        self._write_all_weaves()
2653
2617
        self._write_all_revs()
2654
 
        ui.ui_factory.note('upgraded to weaves:')
2655
 
        ui.ui_factory.note('  %6d revisions and inventories' % len(self.revisions))
2656
 
        ui.ui_factory.note('  %6d revisions not present' % len(self.absent_revisions))
2657
 
        ui.ui_factory.note('  %6d texts' % self.text_count)
 
2618
        self.pb.note('upgraded to weaves:')
 
2619
        self.pb.note('  %6d revisions and inventories', len(self.revisions))
 
2620
        self.pb.note('  %6d revisions not present', len(self.absent_revisions))
 
2621
        self.pb.note('  %6d texts', self.text_count)
2658
2622
        self._cleanup_spare_files_after_format4()
2659
2623
        self.branch._transport.put_bytes(
2660
2624
            'branch-format',
2728
2692
                       len(self.known_revisions))
2729
2693
        if not self.branch.repository.has_revision(rev_id):
2730
2694
            self.pb.clear()
2731
 
            ui.ui_factory.note('revision {%s} not present in branch; '
2732
 
                         'will be converted as a ghost' %
 
2695
            self.pb.note('revision {%s} not present in branch; '
 
2696
                         'will be converted as a ghost',
2733
2697
                         rev_id)
2734
2698
            self.absent_revisions.add(rev_id)
2735
2699
        else:
2862
2826
        """See Converter.convert()."""
2863
2827
        self.bzrdir = to_convert
2864
2828
        self.pb = pb
2865
 
        ui.ui_factory.note('starting upgrade from format 5 to 6')
 
2829
        self.pb.note('starting upgrade from format 5 to 6')
2866
2830
        self._convert_to_prefixed()
2867
2831
        return BzrDir.open(self.bzrdir.root_transport.base)
2868
2832
 
2870
2834
        from bzrlib.store import TransportStore
2871
2835
        self.bzrdir.transport.delete('branch-format')
2872
2836
        for store_name in ["weaves", "revision-store"]:
2873
 
            ui.ui_factory.note("adding prefixes to %s" % store_name)
 
2837
            self.pb.note("adding prefixes to %s" % store_name)
2874
2838
            store_transport = self.bzrdir.transport.clone(store_name)
2875
2839
            store = TransportStore(store_transport, prefixed=True)
2876
2840
            for urlfilename in store_transport.list_dir('.'):
2910
2874
        self.dir_mode = self.bzrdir._get_dir_mode()
2911
2875
        self.file_mode = self.bzrdir._get_file_mode()
2912
2876
 
2913
 
        ui.ui_factory.note('starting upgrade from format 6 to metadir')
 
2877
        self.pb.note('starting upgrade from format 6 to metadir')
2914
2878
        self.bzrdir.transport.put_bytes(
2915
2879
                'branch-format',
2916
2880
                "Converting to format 6",
2966
2930
        else:
2967
2931
            has_checkout = True
2968
2932
        if not has_checkout:
2969
 
            ui.ui_factory.note('No working tree.')
 
2933
            self.pb.note('No working tree.')
2970
2934
            # If some checkout files are there, we may as well get rid of them.
2971
2935
            for name, mandatory in checkout_files:
2972
2936
                if name in bzrcontents:
3041
3005
        else:
3042
3006
            if not isinstance(repo._format, self.target_format.repository_format.__class__):
3043
3007
                from bzrlib.repository import CopyConverter
3044
 
                ui.ui_factory.note('starting repository conversion')
 
3008
                self.pb.note('starting repository conversion')
3045
3009
                converter = CopyConverter(self.target_format.repository_format)
3046
3010
                converter.convert(repo, pb)
3047
3011
        try:
3069
3033
                      new is _mod_branch.BzrBranchFormat8):
3070
3034
                    branch_converter = _mod_branch.Converter7to8()
3071
3035
                else:
3072
 
                    raise errors.BadConversionTarget("No converter", new,
3073
 
                        branch._format)
 
3036
                    raise errors.BadConversionTarget("No converter", new)
3074
3037
                branch_converter.convert(branch)
3075
3038
                branch = self.bzrdir.open_branch()
3076
3039
                old = branch._format.__class__
3111
3074
        self._network_name = None
3112
3075
 
3113
3076
    def get_format_description(self):
3114
 
        if self._network_name:
3115
 
            real_format = network_format_registry.get(self._network_name)
3116
 
            return 'Remote: ' + real_format.get_format_description()
3117
3077
        return 'bzr remote bzrdir'
3118
3078
 
3119
3079
    def get_format_string(self):
3582
3542
            if self._require_stacking:
3583
3543
                raise
3584
3544
 
3585
 
    def requires_stacking(self):
3586
 
        """Return True if this policy requires stacking."""
3587
 
        return self._stack_on is not None and self._require_stacking
3588
 
 
3589
3545
    def _get_full_stack_on(self):
3590
3546
        """Get a fully-qualified URL for the stack_on location."""
3591
3547
        if self._stack_on is None:
3898
3854
# The following format should be an alias for the rich root equivalent 
3899
3855
# of the default format
3900
3856
format_registry.register_metadir('default-rich-root',
3901
 
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3902
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3903
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
 
3857
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
 
3858
    help='Default format, rich root variant. (needed for bzr-svn and bzr-git).',
 
3859
    branch_format='bzrlib.branch.BzrBranchFormat6',
 
3860
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3904
3861
    alias=True,
3905
 
    help='Same as 2a.')
3906
 
 
 
3862
    )
3907
3863
# The current format that is made on 'bzr init'.
3908
 
format_registry.set_default('2a')
 
3864
format_registry.set_default('pack-0.92')