/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 revisionloader.py

remove --inv-fulltext option

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
            ((version_id, options, access_memo, parents),),
333
333
            random_id=random_id)
334
334
        return digest, text_length, content
335
 
 
336
 
 
337
 
class ImportRevisionLoader2(RevisionLoader2):
338
 
    """A RevisionLoader (new Repository API) optimised for importing.
339
 
 
340
 
    This implementation caches serialised inventory texts.
341
 
    Fine-grained control over when inventories are stored as fulltexts
342
 
    IS PLANNED LATER.
343
 
    """
344
 
 
345
 
    def __init__(self, repo, parent_texts_to_cache=1, fulltext_when=None,
346
 
        random_ids=True):
347
 
        """See AbstractRevisionLoader.__init__.
348
 
 
349
 
        :param repository: the target repository
350
 
        :param parent_text_to_cache: the number of parent texts to cache
351
 
        :para fulltext_when: if non None, a function to call to decide
352
 
          whether to fulltext the inventory or not. The revision count
353
 
          is passed as a parameter and the result is treated as a boolean.
354
 
        """
355
 
        RevisionLoader2.__init__(self, repo)
356
 
        self.inv_parent_texts = lru_cache.LRUCache(parent_texts_to_cache)
357
 
        self.fulltext_when = fulltext_when
358
 
        self.random_ids = random_ids
359
 
        self.revision_count = 0
360
 
 
361
 
    def _add_inventory(self, revision_id, inv, parents):
362
 
        """See RevisionLoader._add_inventory."""
363
 
        # Code taken from bzrlib.repository.add_inventory
364
 
        repo = self.repo
365
 
        if not repo.is_in_write_group():
366
 
            raise AssertionError("%r not in write group" % (repo,))
367
 
        _mod_revision.check_not_reserved_id(revision_id)
368
 
        if not (inv.revision_id is None or inv.revision_id == revision_id):
369
 
            raise AssertionError(
370
 
                "Mismatch between inventory revision"
371
 
                " id and insertion revid (%r, %r)"
372
 
                % (inv.revision_id, revision_id))
373
 
        if inv.root is None:
374
 
            raise AssertionError()
375
 
        inv_lines = repo._serialise_inventory_to_lines(inv)
376
 
        parents = [(parent,) for parent in parents]
377
 
        sha1, num_bytes, parent_text = repo.inventories.add_lines(
378
 
            (revision_id,), parents, inv_lines, check_content=False)
379
 
        self.inv_parent_texts[revision_id] = parent_text
380
 
        return sha1