/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/repofmt/knitrepo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-24 17:01:50 UTC
  • mfrom: (4178.3.7 lru_cache_linked_lst)
  • Revision ID: pqm@pqm.ubuntu.com-20090324170150-9wtdpv5w7192zdwy
(jam) Improvements to LRUCache structure, use a double-linked-list

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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
24
24
    lockdir,
25
25
    osutils,
26
26
    revision as _mod_revision,
27
 
    trace,
28
27
    transactions,
29
28
    versionedfile,
30
29
    xml5,
38
37
from bzrlib.decorators import needs_read_lock, needs_write_lock
39
38
from bzrlib.repository import (
40
39
    CommitBuilder,
41
 
    IsInWriteGroupError,
42
40
    MetaDirRepository,
43
41
    MetaDirRepositoryFormat,
44
42
    RepositoryFormat,
45
43
    RootCommitBuilder,
46
44
    )
 
45
from bzrlib.trace import mutter, mutter_callsite
47
46
 
48
47
 
49
48
class _KnitParentsProvider(object):
55
54
        return 'KnitParentsProvider(%r)' % self._knit
56
55
 
57
56
    def get_parent_map(self, keys):
58
 
        """See graph.StackedParentsProvider.get_parent_map"""
 
57
        """See graph._StackedParentsProvider.get_parent_map"""
59
58
        parent_map = {}
60
59
        for revision_id in keys:
61
60
            if revision_id is None:
86
85
        return 'KnitsParentsProvider(%r)' % self._knit
87
86
 
88
87
    def get_parent_map(self, keys):
89
 
        """See graph.StackedParentsProvider.get_parent_map"""
 
88
        """See graph._StackedParentsProvider.get_parent_map"""
90
89
        parent_map = self._knit.get_parent_map(
91
90
            [self._prefix + (key,) for key in keys])
92
91
        result = {}
211
210
    def _refresh_data(self):
212
211
        if not self.is_locked():
213
212
            return
214
 
        if self.is_in_write_group():
215
 
            raise IsInWriteGroupError(self)
216
213
        # Create a new transaction to force all knits to see the scope change.
217
214
        # This is safe because we're outside a write group.
218
215
        self.control_files._finish_transaction()
232
229
    def _make_parents_provider(self):
233
230
        return _KnitsParentsProvider(self.revisions)
234
231
 
235
 
    def _find_inconsistent_revision_parents(self, revisions_iterator=None):
 
232
    def _find_inconsistent_revision_parents(self):
236
233
        """Find revisions with different parent lists in the revision object
237
234
        and in the index graph.
238
235
 
239
 
        :param revisions_iterator: None, or an iterator of (revid,
240
 
            Revision-or-None). This iterator controls the revisions checked.
241
236
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
242
237
            parents-in-revision).
243
238
        """
244
239
        if not self.is_locked():
245
240
            raise AssertionError()
246
241
        vf = self.revisions
247
 
        if revisions_iterator is None:
248
 
            revisions_iterator = self._iter_revisions(None)
249
 
        for revid, revision in revisions_iterator:
250
 
            if revision is None:
251
 
                pass
252
 
            parent_map = vf.get_parent_map([(revid,)])
 
242
        for index_version in vf.keys():
 
243
            parent_map = vf.get_parent_map([index_version])
253
244
            parents_according_to_index = tuple(parent[-1] for parent in
254
 
                parent_map[(revid,)])
 
245
                parent_map[index_version])
 
246
            revision = self.get_revision(index_version[-1])
255
247
            parents_according_to_revision = tuple(revision.parent_ids)
256
248
            if parents_according_to_index != parents_according_to_revision:
257
 
                yield (revid, parents_according_to_index,
 
249
                yield (index_version[-1], parents_according_to_index,
258
250
                    parents_according_to_revision)
259
251
 
260
252
    def _check_for_inconsistent_revision_parents(self):
299
291
    supports_ghosts = True
300
292
    # External lookups are not supported in this format.
301
293
    supports_external_lookups = False
302
 
    # No CHK support.
303
 
    supports_chks = False
304
294
    _fetch_order = 'topological'
305
295
    _fetch_uses_deltas = True
306
296
    fast_deltas = False
345
335
        :param shared: If true the repository will be initialized as a shared
346
336
                       repository.
347
337
        """
348
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
338
        mutter('creating repository in %s.', a_bzrdir.transport.base)
349
339
        dirs = ['knits']
350
340
        files = []
351
341
        utf8_files = [('format', self.get_format_string())]
363
353
        result.revisions.get_parent_map([('A',)])
364
354
        result.signatures.get_parent_map([('A',)])
365
355
        result.unlock()
366
 
        self._run_post_repo_init_hooks(result, a_bzrdir, shared)
367
356
        return result
368
357
 
369
358
    def open(self, a_bzrdir, _found=False, _override_transport=None):
390
379
        repo.signatures = self._get_signatures(repo_transport, repo)
391
380
        repo.inventories = self._get_inventories(repo_transport, repo)
392
381
        repo.texts = self._get_texts(repo_transport, repo)
393
 
        repo.chk_bytes = None
394
382
        repo._transport = repo_transport
395
383
        return repo
396
384
 
428
416
        """See RepositoryFormat.get_format_description()."""
429
417
        return "Knit repository format 1"
430
418
 
 
419
    def check_conversion_target(self, target_format):
 
420
        pass
 
421
 
431
422
 
432
423
class RepositoryFormatKnit3(RepositoryFormatKnit):
433
424
    """Bzr repository knit format 3.
448
439
    repository_class = KnitRepository
449
440
    _commit_builder_class = RootCommitBuilder
450
441
    rich_root_data = True
451
 
    experimental = True
452
442
    supports_tree_reference = True
453
443
    @property
454
444
    def _serializer(self):
462
452
 
463
453
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
464
454
 
 
455
    def check_conversion_target(self, target_format):
 
456
        if not target_format.rich_root_data:
 
457
            raise errors.BadConversionTarget(
 
458
                'Does not support rich root data.', target_format)
 
459
        if not getattr(target_format, 'supports_tree_reference', False):
 
460
            raise errors.BadConversionTarget(
 
461
                'Does not support nested trees', target_format)
 
462
 
465
463
    def get_format_string(self):
466
464
        """See RepositoryFormat.get_format_string()."""
467
465
        return "Bazaar Knit Repository Format 3 (bzr 0.15)\n"
503
501
 
504
502
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
505
503
 
 
504
    def check_conversion_target(self, target_format):
 
505
        if not target_format.rich_root_data:
 
506
            raise errors.BadConversionTarget(
 
507
                'Does not support rich root data.', target_format)
 
508
 
506
509
    def get_format_string(self):
507
510
        """See RepositoryFormat.get_format_string()."""
508
511
        return 'Bazaar Knit Repository Format 4 (bzr 1.0)\n'