~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    revision as _mod_revision,
55
55
    )
56
56
 
57
 
from bzrlib.decorators import needs_write_lock
 
57
from bzrlib.decorators import needs_write_lock, only_raises
58
58
from bzrlib.btree_index import (
59
59
    BTreeGraphIndex,
60
60
    BTreeBuilder,
73
73
    )
74
74
from bzrlib.trace import (
75
75
    mutter,
 
76
    note,
76
77
    warning,
77
78
    )
78
79
 
224
225
        return self.index_name('text', name)
225
226
 
226
227
    def _replace_index_with_readonly(self, index_type):
 
228
        unlimited_cache = False
 
229
        if index_type == 'chk':
 
230
            unlimited_cache = True
227
231
        setattr(self, index_type + '_index',
228
232
            self.index_class(self.index_transport,
229
233
                self.index_name(index_type, self.name),
230
 
                self.index_sizes[self.index_offset(index_type)]))
 
234
                self.index_sizes[self.index_offset(index_type)],
 
235
                unlimited_cache=unlimited_cache))
231
236
 
232
237
 
233
238
class ExistingPack(Pack):
1674
1679
            txt_index = self._make_index(name, '.tix')
1675
1680
            sig_index = self._make_index(name, '.six')
1676
1681
            if self.chk_index is not None:
1677
 
                chk_index = self._make_index(name, '.cix')
 
1682
                chk_index = self._make_index(name, '.cix', unlimited_cache=True)
1678
1683
            else:
1679
1684
                chk_index = None
1680
1685
            result = ExistingPack(self._pack_transport, name, rev_index,
1699
1704
            txt_index = self._make_index(name, '.tix', resume=True)
1700
1705
            sig_index = self._make_index(name, '.six', resume=True)
1701
1706
            if self.chk_index is not None:
1702
 
                chk_index = self._make_index(name, '.cix', resume=True)
 
1707
                chk_index = self._make_index(name, '.cix', resume=True,
 
1708
                                             unlimited_cache=True)
1703
1709
            else:
1704
1710
                chk_index = None
1705
1711
            result = self.resumed_pack_factory(name, rev_index, inv_index,
1735
1741
        return self._index_class(self.transport, 'pack-names', None
1736
1742
                ).iter_all_entries()
1737
1743
 
1738
 
    def _make_index(self, name, suffix, resume=False):
 
1744
    def _make_index(self, name, suffix, resume=False, unlimited_cache=False):
1739
1745
        size_offset = self._suffix_offsets[suffix]
1740
1746
        index_name = name + suffix
1741
1747
        if resume:
1744
1750
        else:
1745
1751
            transport = self._index_transport
1746
1752
            index_size = self._names[name][size_offset]
1747
 
        return self._index_class(transport, index_name, index_size)
 
1753
        return self._index_class(transport, index_name, index_size,
 
1754
                                 unlimited_cache=unlimited_cache)
1748
1755
 
1749
1756
    def _max_pack_count(self, total_revisions):
1750
1757
        """Return the maximum number of packs to use for total revisions.
2082
2089
                ('signatures', self.repo.signatures),
2083
2090
                ):
2084
2091
            missing = versioned_file.get_missing_compression_parent_keys()
2085
 
            all_missing.update([(prefix,) + key for key in missing])
 
2092
            all_missing.update([(prefix,) + tuple(key) for key in missing])
2086
2093
        if all_missing:
2087
2094
            raise errors.BzrCheckError(
2088
2095
                "Repository %s has missing compression parent(s) %r "
2300
2307
        if self._write_lock_count == 1:
2301
2308
            self._transaction = transactions.WriteTransaction()
2302
2309
        if not locked:
 
2310
            if 'relock' in debug.debug_flags and self._prev_lock == 'w':
 
2311
                note('%r was write locked again', self)
 
2312
            self._prev_lock = 'w'
2303
2313
            for repo in self._fallback_repositories:
2304
2314
                # Writes don't affect fallback repos
2305
2315
                repo.lock_read()
2312
2322
        else:
2313
2323
            self.control_files.lock_read()
2314
2324
        if not locked:
 
2325
            if 'relock' in debug.debug_flags and self._prev_lock == 'r':
 
2326
                note('%r was read locked again', self)
 
2327
            self._prev_lock = 'r'
2315
2328
            for repo in self._fallback_repositories:
2316
2329
                repo.lock_read()
2317
2330
            self._refresh_data()
2345
2358
        packer = ReconcilePacker(collection, packs, extension, revs)
2346
2359
        return packer.pack(pb)
2347
2360
 
 
2361
    @only_raises(errors.LockNotHeld, errors.LockBroken)
2348
2362
    def unlock(self):
2349
2363
        if self._write_lock_count == 1 and self._write_group is not None:
2350
2364
            self.abort_write_group()