/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

add inv-fulltext option and improve speed

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
                inv, present_parents)
64
64
        except errors.RevisionAlreadyPresent:
65
65
            pass
 
66
        repo = self.repo
66
67
        if signature is not None:
67
 
            self.repo.add_signature_text(rev.revision_id, signature)
68
 
        self.repo.add_revision(rev.revision_id, rev, inv)
 
68
            repo.add_signature_text(rev.revision_id, signature)
 
69
        # repo.add_revision(rev.revision_id, rev, inv)
 
70
        # There's no need to do everything repo.add_revision does and
 
71
        # doing so (since bzr.dev 3392) can be pretty slow for long
 
72
        # delta chains on inventories. Just do the essentials here ...
 
73
        _mod_revision.check_not_reserved_id(rev.revision_id)
 
74
        repo._revision_store.add_revision(rev, repo.get_transaction())
69
75
 
70
76
    def _load_texts(self, revision_id, entries, parent_invs, text_provider):
71
77
        """Load texts to a repository for inventory entries.
187
193
    it is an incubator for experimental code.
188
194
    """
189
195
 
190
 
    def __init__(self, repo, parent_texts_to_cache=1, fulltext_every=200):
 
196
    def __init__(self, repo, parent_texts_to_cache=1, fulltext_when=None):
191
197
        """See ImportRevisionLoader.__init__.
192
198
        
193
 
        :para fulltext_every: how often to store an inventory fulltext
 
199
        :para fulltext_when: if non None, a function to call to decide
 
200
          whether to fulltext the inventory or not. The revision count
 
201
          is passed as a parameter and the result is treated as a boolean.
194
202
        """
195
203
        ImportRevisionLoader.__init__(self, repo, parent_texts_to_cache)
196
204
        self.revision_count = 0
197
 
        self.fulltext_every = fulltext_every
 
205
        self.fulltext_when = fulltext_when
198
206
 
199
207
    def _inventory_add_lines(self, inv_vf, version_id, parents, lines,
200
208
            parent_texts):
201
209
        """See Repository._inventory_add_lines()."""
202
210
        # setup parameters used in original code but not this API
203
211
        self.revision_count += 1
204
 
        if self.revision_count % self.fulltext_every == 0:
205
 
            delta = False
 
212
        if self.fulltext_when is not None:
 
213
            delta = not self.fulltext_when(self.revision_count)
206
214
        else:
207
215
            delta = inv_vf.delta
208
216
        left_matching_blocks = None