/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: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    lockable_files,
31
31
    lockdir,
32
32
    osutils,
 
33
    symbol_versioning,
33
34
    transactions,
34
35
    xml5,
 
36
    xml6,
35
37
    xml7,
36
38
    )
37
39
 
57
59
    def __repr__(self):
58
60
        return 'KnitParentsProvider(%r)' % self._knit
59
61
 
 
62
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
60
63
    def get_parents(self, revision_ids):
61
 
        parents_list = []
62
 
        for revision_id in revision_ids:
 
64
        """See graph._StackedParentsProvider.get_parents"""
 
65
        parent_map = self.get_parent_map(revision_ids)
 
66
        return [parent_map.get(r, None) for r in revision_ids]
 
67
 
 
68
    def get_parent_map(self, keys):
 
69
        """See graph._StackedParentsProvider.get_parent_map"""
 
70
        parent_map = {}
 
71
        for revision_id in keys:
63
72
            if revision_id == _mod_revision.NULL_REVISION:
64
 
                parents = []
 
73
                parent_map[revision_id] = ()
65
74
            else:
66
75
                try:
67
 
                    parents = self._knit.get_parents_with_ghosts(revision_id)
 
76
                    parents = tuple(
 
77
                        self._knit.get_parents_with_ghosts(revision_id))
68
78
                except errors.RevisionNotPresent:
69
 
                    parents = None
 
79
                    continue
70
80
                else:
71
81
                    if len(parents) == 0:
72
 
                        parents = [_mod_revision.NULL_REVISION]
73
 
            parents_list.append(parents)
74
 
        return parents_list
 
82
                        parents = (_mod_revision.NULL_REVISION,)
 
83
                parent_map[revision_id] = parents
 
84
        return parent_map
75
85
 
76
86
 
77
87
class KnitRepository(MetaDirRepository):
147
157
        except errors.RevisionNotPresent:
148
158
            raise errors.NoSuchRevision(self, revision_id)
149
159
 
 
160
    @symbol_versioning.deprecated_method(symbol_versioning.one_two)
150
161
    @needs_read_lock
151
162
    def get_data_stream(self, revision_ids):
152
 
        """See Repository.get_data_stream."""
153
 
        item_keys = self.item_keys_introduced_by(revision_ids)
 
163
        """See Repository.get_data_stream.
 
164
        
 
165
        Deprecated in 1.2 for get_data_stream_for_search.
 
166
        """
 
167
        search_result = self.revision_ids_to_search_result(set(revision_ids))
 
168
        return self.get_data_stream_for_search(search_result)
 
169
 
 
170
    @needs_read_lock
 
171
    def get_data_stream_for_search(self, search):
 
172
        """See Repository.get_data_stream_for_search."""
 
173
        item_keys = self.item_keys_introduced_by(search.get_keys())
154
174
        for knit_kind, file_id, versions in item_keys:
155
175
            name = (knit_kind,)
156
176
            if knit_kind == 'file':
255
275
        """
256
276
        return self._get_revision_vf()
257
277
 
 
278
    def has_revisions(self, revision_ids):
 
279
        """See Repository.has_revisions()."""
 
280
        result = set()
 
281
        transaction = self.get_transaction()
 
282
        for revision_id in revision_ids:
 
283
            if self._revision_store.has_revision_id(revision_id, transaction):
 
284
                result.add(revision_id)
 
285
        return result
 
286
 
258
287
    @needs_write_lock
259
288
    def reconcile(self, other=None, thorough=False):
260
289
        """Reconcile this repository."""
457
486
 
458
487
 
459
488
class RepositoryFormatKnit3(RepositoryFormatKnit):
460
 
    """Bzr repository knit format 2.
 
489
    """Bzr repository knit format 3.
461
490
 
462
491
    This repository format has:
463
492
     - knits for file texts and inventory
503
532
        return "Knit repository format 3"
504
533
 
505
534
 
 
535
class RepositoryFormatKnit4(RepositoryFormatKnit):
 
536
    """Bzr repository knit format 4.
 
537
 
 
538
    This repository format has everything in format 3, except for
 
539
    tree-references:
 
540
     - knits for file texts and inventory
 
541
     - hash subdirectory based stores.
 
542
     - knits for revisions and signatures
 
543
     - TextStores for revisions and signatures.
 
544
     - a format marker of its own
 
545
     - an optional 'shared-storage' flag
 
546
     - an optional 'no-working-trees' flag
 
547
     - a LockDir lock
 
548
     - support for recording full info about the tree root
 
549
    """
 
550
 
 
551
    repository_class = KnitRepository
 
552
    _commit_builder_class = RootCommitBuilder
 
553
    rich_root_data = True
 
554
    supports_tree_reference = False
 
555
    _serializer = xml6.serializer_v6
 
556
 
 
557
    def _get_matching_bzrdir(self):
 
558
        return bzrdir.format_registry.make_bzrdir('rich-root')
 
559
 
 
560
    def _ignore_setting_bzrdir(self, format):
 
561
        pass
 
562
 
 
563
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
564
 
 
565
    def check_conversion_target(self, target_format):
 
566
        if not target_format.rich_root_data:
 
567
            raise errors.BadConversionTarget(
 
568
                'Does not support rich root data.', target_format)
 
569
 
 
570
    def get_format_string(self):
 
571
        """See RepositoryFormat.get_format_string()."""
 
572
        return 'Bazaar Knit Repository Format 4 (bzr 1.0)\n'
 
573
 
 
574
    def get_format_description(self):
 
575
        """See RepositoryFormat.get_format_description()."""
 
576
        return "Knit repository format 4"
 
577
 
 
578
 
506
579
def _get_stream_as_bytes(knit, required_versions):
507
580
    """Generate a serialised data stream.
508
581