/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

Merge up bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
from bzrlib.symbol_versioning import (
81
81
    deprecated_function,
82
82
    deprecated_method,
83
 
    zero_ninetyone,
84
83
    )
85
84
 
86
85
 
434
433
        return result
435
434
 
436
435
    @staticmethod
437
 
    @deprecated_function(zero_ninetyone)
438
 
    def create_repository(base, shared=False, format=None):
439
 
        """Create a new BzrDir and Repository at the url 'base'.
440
 
 
441
 
        If no format is supplied, this will default to the current default
442
 
        BzrDirFormat by default, and use whatever repository format that that
443
 
        uses for bzrdirformat.create_repository.
444
 
 
445
 
        :param shared: Create a shared repository rather than a standalone
446
 
                       repository.
447
 
        The Repository object is returned.
448
 
 
449
 
        This must be overridden as an instance method in child classes, where
450
 
        it should take no parameters and construct whatever repository format
451
 
        that child class desires.
452
 
 
453
 
        This method is deprecated, please call create_repository on a bzrdir
454
 
        instance instead.
455
 
        """
456
 
        bzrdir = BzrDir.create(base, format)
457
 
        return bzrdir.create_repository(shared)
458
 
 
459
 
    @staticmethod
460
436
    def create_standalone_workingtree(base, format=None):
461
437
        """Create a new BzrDir, WorkingTree, Branch and Repository at 'base'.
462
438
 
1039
1015
    def __init__(self, _transport, _format):
1040
1016
        """See BzrDir.__init__."""
1041
1017
        super(BzrDirPreSplitOut, self).__init__(_transport, _format)
1042
 
        assert self._format._lock_class == lockable_files.TransportLock
1043
 
        assert self._format._lock_file_name == 'branch-lock'
1044
1018
        self._control_files = lockable_files.LockableFiles(
1045
1019
                                            self.get_branch_transport(None),
1046
1020
                                            self._format._lock_file_name,
1632
1606
        klass._control_server_formats.append(format)
1633
1607
 
1634
1608
    @classmethod
1635
 
    @symbol_versioning.deprecated_method(symbol_versioning.zero_fourteen)
1636
 
    def set_default_format(klass, format):
1637
 
        klass._set_default_format(format)
1638
 
 
1639
 
    @classmethod
1640
1609
    def _set_default_format(klass, format):
1641
1610
        """Set default format (for testing behavior of defaults only)"""
1642
1611
        klass._default_format = format
1647
1616
 
1648
1617
    @classmethod
1649
1618
    def unregister_format(klass, format):
1650
 
        assert klass._formats[format.get_format_string()] is format
1651
1619
        del klass._formats[format.get_format_string()]
1652
1620
 
1653
1621
    @classmethod
2077
2045
            self.revisions[rev_id] = rev
2078
2046
 
2079
2047
    def _load_old_inventory(self, rev_id):
2080
 
        assert rev_id not in self.converted_revs
2081
2048
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
2082
2049
        inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2083
2050
        inv.revision_id = rev_id
2084
2051
        rev = self.revisions[rev_id]
2085
 
        if rev.inventory_sha1:
2086
 
            assert rev.inventory_sha1 == sha_string(old_inv_xml), \
2087
 
                'inventory sha mismatch for {%s}' % rev_id
2088
2052
        return inv
2089
2053
 
2090
2054
    def _load_updated_inventory(self, rev_id):
2091
 
        assert rev_id in self.converted_revs
2092
2055
        inv_xml = self.inv_weave.get_text(rev_id)
2093
2056
        inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id)
2094
2057
        return inv
2104
2067
        self.converted_revs.add(rev_id)
2105
2068
 
2106
2069
    def _store_new_inv(self, rev, inv, present_parents):
2107
 
        # the XML is now updated with text versions
2108
 
        if __debug__:
2109
 
            entries = inv.iter_entries()
2110
 
            entries.next()
2111
 
            for path, ie in entries:
2112
 
                assert getattr(ie, 'revision', None) is not None, \
2113
 
                    'no revision on {%s} in {%s}' % \
2114
 
                    (file_id, rev.revision_id)
2115
2070
        new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv)
2116
2071
        new_inv_sha1 = sha_string(new_inv_xml)
2117
2072
        self.inv_weave.add_lines(rev.revision_id,
2146
2101
            self.text_weaves[file_id] = w
2147
2102
        text_changed = False
2148
2103
        parent_candiate_entries = ie.parent_candidates(parent_invs)
2149
 
        for old_revision in parent_candiate_entries.keys():
2150
 
            # if this fails, its a ghost ?
2151
 
            assert old_revision in self.converted_revs, \
2152
 
                "Revision {%s} not in converted_revs" % old_revision
2153
2104
        heads = graph.Graph(self).heads(parent_candiate_entries.keys())
2154
2105
        # XXX: Note that this is unordered - and this is tolerable because 
2155
2106
        # the previous code was also unordered.
2157
2108
            in heads)
2158
2109
        self.snapshot_ie(previous_entries, ie, w, rev_id)
2159
2110
        del ie.text_id
2160
 
        assert getattr(ie, 'revision', None) is not None
2161
2111
 
2162
2112
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
2163
2113
    def get_parents(self, revision_ids):
2186
2136
        if ie.has_text():
2187
2137
            text = self.branch.repository.weave_store.get(ie.text_id)
2188
2138
            file_lines = text.readlines()
2189
 
            assert sha_strings(file_lines) == ie.text_sha1
2190
 
            assert sum(map(len, file_lines)) == ie.text_size
2191
2139
            w.add_lines(rev_id, previous_revisions, file_lines)
2192
2140
            self.text_count += 1
2193
2141
        else:
2467
2415
        client = _SmartClient(client_medium, transport.base)
2468
2416
        path = client.remote_path_from_transport(transport)
2469
2417
        response = client.call('BzrDirFormat.initialize', path)
2470
 
        assert response[0] in ('ok', ), 'unexpected response code %s' % (response,)
 
2418
        if response[0] != 'ok':
 
2419
            raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2471
2420
        return remote.RemoteBzrDir(transport)
2472
2421
 
2473
2422
    def _open(self, transport):
2595
2544
            self.remove('default')
2596
2545
        self.set_default(key)
2597
2546
        format = self.get('default')()
2598
 
        assert isinstance(format, BzrDirMetaFormat1)
2599
2547
 
2600
2548
    def make_bzrdir(self, key):
2601
2549
        return self.get(key)()