/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: Canonical.com Patch Queue Manager
  • Date: 2010-01-14 00:01:32 UTC
  • mfrom: (4957.1.1 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100114000132-3p3rabnonjw3gzqb
(jam) Merge bzr.stable, bringing in bug fixes #175839, #504390

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
584
584
            # permissions as the .bzr directory (probably a bug in copy_tree)
585
585
            old_path = self.root_transport.abspath('.bzr')
586
586
            new_path = self.root_transport.abspath('backup.bzr')
587
 
            pb.note('making backup of %s' % (old_path,))
588
 
            pb.note('  to %s' % (new_path,))
 
587
            ui.ui_factory.note('making backup of %s\n  to %s' % (old_path, new_path,))
589
588
            self.root_transport.copy_tree('.bzr', 'backup.bzr')
590
589
            return (old_path, new_path)
591
590
        finally:
1537
1536
    This is a deprecated format and may be removed after sept 2006.
1538
1537
    """
1539
1538
 
 
1539
    def has_workingtree(self):
 
1540
        """See BzrDir.has_workingtree."""
 
1541
        return True
 
1542
    
1540
1543
    def open_repository(self):
1541
1544
        """See BzrDir.open_repository."""
1542
1545
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1558
1561
    This is a deprecated format and may be removed after sept 2006.
1559
1562
    """
1560
1563
 
 
1564
    def has_workingtree(self):
 
1565
        """See BzrDir.has_workingtree."""
 
1566
        return True
 
1567
    
1561
1568
    def open_repository(self):
1562
1569
        """See BzrDir.open_repository."""
1563
1570
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1683
1690
            pass
1684
1691
        return self.transport.clone('checkout')
1685
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
 
1686
1709
    def needs_format_conversion(self, format=None):
1687
1710
        """See BzrDir.needs_format_conversion()."""
1688
1711
        if format is None:
1804
1827
    def probe_transport(klass, transport):
1805
1828
        """Return the .bzrdir style format present in a directory."""
1806
1829
        try:
1807
 
            format_string = transport.get(".bzr/branch-format").read()
 
1830
            format_string = transport.get_bytes(".bzr/branch-format")
1808
1831
        except errors.NoSuchFile:
1809
1832
            raise errors.NotBranchError(path=transport.base)
1810
1833
 
2587
2610
        """See Converter.convert()."""
2588
2611
        self.bzrdir = to_convert
2589
2612
        self.pb = pb
2590
 
        self.pb.note('starting upgrade from format 4 to 5')
 
2613
        ui.ui_factory.note('starting upgrade from format 4 to 5')
2591
2614
        if isinstance(self.bzrdir.transport, local.LocalTransport):
2592
2615
            self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2593
2616
        self._convert_to_weaves()
2594
2617
        return BzrDir.open(self.bzrdir.root_transport.base)
2595
2618
 
2596
2619
    def _convert_to_weaves(self):
2597
 
        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')
2598
2621
        try:
2599
2622
            # TODO permissions
2600
2623
            stat = self.bzrdir.transport.stat('weaves')
2628
2651
        self.pb.clear()
2629
2652
        self._write_all_weaves()
2630
2653
        self._write_all_revs()
2631
 
        self.pb.note('upgraded to weaves:')
2632
 
        self.pb.note('  %6d revisions and inventories', len(self.revisions))
2633
 
        self.pb.note('  %6d revisions not present', len(self.absent_revisions))
2634
 
        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)
2635
2658
        self._cleanup_spare_files_after_format4()
2636
2659
        self.branch._transport.put_bytes(
2637
2660
            'branch-format',
2705
2728
                       len(self.known_revisions))
2706
2729
        if not self.branch.repository.has_revision(rev_id):
2707
2730
            self.pb.clear()
2708
 
            self.pb.note('revision {%s} not present in branch; '
2709
 
                         'will be converted as a ghost',
 
2731
            ui.ui_factory.note('revision {%s} not present in branch; '
 
2732
                         'will be converted as a ghost' %
2710
2733
                         rev_id)
2711
2734
            self.absent_revisions.add(rev_id)
2712
2735
        else:
2839
2862
        """See Converter.convert()."""
2840
2863
        self.bzrdir = to_convert
2841
2864
        self.pb = pb
2842
 
        self.pb.note('starting upgrade from format 5 to 6')
 
2865
        ui.ui_factory.note('starting upgrade from format 5 to 6')
2843
2866
        self._convert_to_prefixed()
2844
2867
        return BzrDir.open(self.bzrdir.root_transport.base)
2845
2868
 
2847
2870
        from bzrlib.store import TransportStore
2848
2871
        self.bzrdir.transport.delete('branch-format')
2849
2872
        for store_name in ["weaves", "revision-store"]:
2850
 
            self.pb.note("adding prefixes to %s" % store_name)
 
2873
            ui.ui_factory.note("adding prefixes to %s" % store_name)
2851
2874
            store_transport = self.bzrdir.transport.clone(store_name)
2852
2875
            store = TransportStore(store_transport, prefixed=True)
2853
2876
            for urlfilename in store_transport.list_dir('.'):
2887
2910
        self.dir_mode = self.bzrdir._get_dir_mode()
2888
2911
        self.file_mode = self.bzrdir._get_file_mode()
2889
2912
 
2890
 
        self.pb.note('starting upgrade from format 6 to metadir')
 
2913
        ui.ui_factory.note('starting upgrade from format 6 to metadir')
2891
2914
        self.bzrdir.transport.put_bytes(
2892
2915
                'branch-format',
2893
2916
                "Converting to format 6",
2943
2966
        else:
2944
2967
            has_checkout = True
2945
2968
        if not has_checkout:
2946
 
            self.pb.note('No working tree.')
 
2969
            ui.ui_factory.note('No working tree.')
2947
2970
            # If some checkout files are there, we may as well get rid of them.
2948
2971
            for name, mandatory in checkout_files:
2949
2972
                if name in bzrcontents:
3018
3041
        else:
3019
3042
            if not isinstance(repo._format, self.target_format.repository_format.__class__):
3020
3043
                from bzrlib.repository import CopyConverter
3021
 
                self.pb.note('starting repository conversion')
 
3044
                ui.ui_factory.note('starting repository conversion')
3022
3045
                converter = CopyConverter(self.target_format.repository_format)
3023
3046
                converter.convert(repo, pb)
3024
3047
        try:
3085
3108
 
3086
3109
    def __init__(self):
3087
3110
        BzrDirMetaFormat1.__init__(self)
 
3111
        # XXX: It's a bit ugly that the network name is here, because we'd
 
3112
        # like to believe that format objects are stateless or at least
 
3113
        # immutable,  However, we do at least avoid mutating the name after
 
3114
        # it's returned.  See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
3088
3115
        self._network_name = None
3089
3116
 
 
3117
    def __repr__(self):
 
3118
        return "%s(_network_name=%r)" % (self.__class__.__name__,
 
3119
            self._network_name)
 
3120
 
3090
3121
    def get_format_description(self):
 
3122
        if self._network_name:
 
3123
            real_format = network_format_registry.get(self._network_name)
 
3124
            return 'Remote: ' + real_format.get_format_description()
3091
3125
        return 'bzr remote bzrdir'
3092
3126
 
3093
3127
    def get_format_string(self):
3226
3260
        args.append(self._serialize_NoneString(repo_format_name))
3227
3261
        args.append(self._serialize_NoneTrueFalse(make_working_trees))
3228
3262
        args.append(self._serialize_NoneTrueFalse(shared_repo))
3229
 
        if self._network_name is None:
3230
 
            self._network_name = \
 
3263
        request_network_name = self._network_name or \
3231
3264
            BzrDirFormat.get_default_format().network_name()
3232
3265
        try:
3233
3266
            response = client.call('BzrDirFormat.initialize_ex_1.16',
3234
 
                self.network_name(), path, *args)
 
3267
                request_network_name, path, *args)
3235
3268
        except errors.UnknownSmartMethod:
3236
3269
            client._medium._remember_remote_is_before((1,16))
3237
3270
            local_dir_format = BzrDirMetaFormat1()
3487
3520
                experimental_pairs.append((key, help))
3488
3521
            else:
3489
3522
                output += wrapped(key, help, info)
3490
 
        output += "\nSee ``bzr help formats`` for more about storage formats."
 
3523
        output += "\nSee :doc:`formats-help` for more about storage formats."
3491
3524
        other_output = ""
3492
3525
        if len(experimental_pairs) > 0:
3493
3526
            other_output += "Experimental formats are shown below.\n\n"
3506
3539
            other_output += \
3507
3540
                "\nNo deprecated formats are available.\n\n"
3508
3541
        other_output += \
3509
 
            "\nSee ``bzr help formats`` for more about storage formats."
 
3542
                "\nSee :doc:`formats-help` for more about storage formats."
3510
3543
 
3511
3544
        if topic == 'other-formats':
3512
3545
            return other_output