/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/bzrdir.py

  • Committer: Martin
  • Date: 2009-11-07 08:02:13 UTC
  • mfrom: (4789 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4809.
  • Revision ID: gzlist@googlemail.com-20091107080213-jad185091b3l69ih
Merge bzr.dev 4789 to resolve conflict from the disabling of plink auto-detection, and relocate NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
        return True
130
130
 
131
131
    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.
132
135
        target_repo_format = target_format.repository_format
133
 
        source_repo_format = self._format.repository_format
134
 
        source_repo_format.check_conversion_target(target_repo_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
135
142
 
136
143
    @staticmethod
137
144
    def _check_supported(format, allow_unsupported,
577
584
            # permissions as the .bzr directory (probably a bug in copy_tree)
578
585
            old_path = self.root_transport.abspath('.bzr')
579
586
            new_path = self.root_transport.abspath('backup.bzr')
580
 
            pb.note('making backup of %s' % (old_path,))
581
 
            pb.note('  to %s' % (new_path,))
 
587
            ui.ui_factory.note('making backup of %s\n  to %s' % (old_path, new_path,))
582
588
            self.root_transport.copy_tree('.bzr', 'backup.bzr')
583
589
            return (old_path, new_path)
584
590
        finally:
1530
1536
    This is a deprecated format and may be removed after sept 2006.
1531
1537
    """
1532
1538
 
 
1539
    def has_workingtree(self):
 
1540
        """See BzrDir.has_workingtree."""
 
1541
        return True
 
1542
    
1533
1543
    def open_repository(self):
1534
1544
        """See BzrDir.open_repository."""
1535
1545
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1551
1561
    This is a deprecated format and may be removed after sept 2006.
1552
1562
    """
1553
1563
 
 
1564
    def has_workingtree(self):
 
1565
        """See BzrDir.has_workingtree."""
 
1566
        return True
 
1567
    
1554
1568
    def open_repository(self):
1555
1569
        """See BzrDir.open_repository."""
1556
1570
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1676
1690
            pass
1677
1691
        return self.transport.clone('checkout')
1678
1692
 
 
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
 
1679
1709
    def needs_format_conversion(self, format=None):
1680
1710
        """See BzrDir.needs_format_conversion()."""
1681
1711
        if format is None:
2580
2610
        """See Converter.convert()."""
2581
2611
        self.bzrdir = to_convert
2582
2612
        self.pb = pb
2583
 
        self.pb.note('starting upgrade from format 4 to 5')
 
2613
        ui.ui_factory.note('starting upgrade from format 4 to 5')
2584
2614
        if isinstance(self.bzrdir.transport, local.LocalTransport):
2585
2615
            self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2586
2616
        self._convert_to_weaves()
2587
2617
        return BzrDir.open(self.bzrdir.root_transport.base)
2588
2618
 
2589
2619
    def _convert_to_weaves(self):
2590
 
        self.pb.note('note: upgrade may be faster if all store files are ungzipped first')
 
2620
        ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2591
2621
        try:
2592
2622
            # TODO permissions
2593
2623
            stat = self.bzrdir.transport.stat('weaves')
2621
2651
        self.pb.clear()
2622
2652
        self._write_all_weaves()
2623
2653
        self._write_all_revs()
2624
 
        self.pb.note('upgraded to weaves:')
2625
 
        self.pb.note('  %6d revisions and inventories', len(self.revisions))
2626
 
        self.pb.note('  %6d revisions not present', len(self.absent_revisions))
2627
 
        self.pb.note('  %6d texts', self.text_count)
 
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)
2628
2658
        self._cleanup_spare_files_after_format4()
2629
2659
        self.branch._transport.put_bytes(
2630
2660
            'branch-format',
2698
2728
                       len(self.known_revisions))
2699
2729
        if not self.branch.repository.has_revision(rev_id):
2700
2730
            self.pb.clear()
2701
 
            self.pb.note('revision {%s} not present in branch; '
2702
 
                         'will be converted as a ghost',
 
2731
            ui.ui_factory.note('revision {%s} not present in branch; '
 
2732
                         'will be converted as a ghost' %
2703
2733
                         rev_id)
2704
2734
            self.absent_revisions.add(rev_id)
2705
2735
        else:
2832
2862
        """See Converter.convert()."""
2833
2863
        self.bzrdir = to_convert
2834
2864
        self.pb = pb
2835
 
        self.pb.note('starting upgrade from format 5 to 6')
 
2865
        ui.ui_factory.note('starting upgrade from format 5 to 6')
2836
2866
        self._convert_to_prefixed()
2837
2867
        return BzrDir.open(self.bzrdir.root_transport.base)
2838
2868
 
2840
2870
        from bzrlib.store import TransportStore
2841
2871
        self.bzrdir.transport.delete('branch-format')
2842
2872
        for store_name in ["weaves", "revision-store"]:
2843
 
            self.pb.note("adding prefixes to %s" % store_name)
 
2873
            ui.ui_factory.note("adding prefixes to %s" % store_name)
2844
2874
            store_transport = self.bzrdir.transport.clone(store_name)
2845
2875
            store = TransportStore(store_transport, prefixed=True)
2846
2876
            for urlfilename in store_transport.list_dir('.'):
2880
2910
        self.dir_mode = self.bzrdir._get_dir_mode()
2881
2911
        self.file_mode = self.bzrdir._get_file_mode()
2882
2912
 
2883
 
        self.pb.note('starting upgrade from format 6 to metadir')
 
2913
        ui.ui_factory.note('starting upgrade from format 6 to metadir')
2884
2914
        self.bzrdir.transport.put_bytes(
2885
2915
                'branch-format',
2886
2916
                "Converting to format 6",
2936
2966
        else:
2937
2967
            has_checkout = True
2938
2968
        if not has_checkout:
2939
 
            self.pb.note('No working tree.')
 
2969
            ui.ui_factory.note('No working tree.')
2940
2970
            # If some checkout files are there, we may as well get rid of them.
2941
2971
            for name, mandatory in checkout_files:
2942
2972
                if name in bzrcontents:
3011
3041
        else:
3012
3042
            if not isinstance(repo._format, self.target_format.repository_format.__class__):
3013
3043
                from bzrlib.repository import CopyConverter
3014
 
                self.pb.note('starting repository conversion')
 
3044
                ui.ui_factory.note('starting repository conversion')
3015
3045
                converter = CopyConverter(self.target_format.repository_format)
3016
3046
                converter.convert(repo, pb)
3017
3047
        try:
3039
3069
                      new is _mod_branch.BzrBranchFormat8):
3040
3070
                    branch_converter = _mod_branch.Converter7to8()
3041
3071
                else:
3042
 
                    raise errors.BadConversionTarget("No converter", new)
 
3072
                    raise errors.BadConversionTarget("No converter", new,
 
3073
                        branch._format)
3043
3074
                branch_converter.convert(branch)
3044
3075
                branch = self.bzrdir.open_branch()
3045
3076
                old = branch._format.__class__
3548
3579
            if self._require_stacking:
3549
3580
                raise
3550
3581
 
 
3582
    def requires_stacking(self):
 
3583
        """Return True if this policy requires stacking."""
 
3584
        return self._stack_on is not None and self._require_stacking
 
3585
 
3551
3586
    def _get_full_stack_on(self):
3552
3587
        """Get a fully-qualified URL for the stack_on location."""
3553
3588
        if self._stack_on is None:
3860
3895
# The following format should be an alias for the rich root equivalent 
3861
3896
# of the default format
3862
3897
format_registry.register_metadir('default-rich-root',
3863
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3864
 
    help='Default format, rich root variant. (needed for bzr-svn and bzr-git).',
3865
 
    branch_format='bzrlib.branch.BzrBranchFormat6',
3866
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3898
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
 
3899
    branch_format='bzrlib.branch.BzrBranchFormat7',
 
3900
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3867
3901
    alias=True,
3868
 
    )
 
3902
    help='Same as 2a.')
 
3903
 
3869
3904
# The current format that is made on 'bzr init'.
3870
 
format_registry.set_default('pack-0.92')
 
3905
format_registry.set_default('2a')