/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 breezy/plugins/fastimport/revision_store.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
                if ie is None:
120
120
                    raise AssertionError('How is both old and new None?')
121
121
                    change = (file_id,
122
 
                        (old_path, new_path),
123
 
                        False,
124
 
                        (False, False),
125
 
                        (None, None),
126
 
                        (None, None),
127
 
                        (None, None),
128
 
                        (None, None),
129
 
                        )
 
122
                              (old_path, new_path),
 
123
                              False,
 
124
                              (False, False),
 
125
                              (None, None),
 
126
                              (None, None),
 
127
                              (None, None),
 
128
                              (None, None),
 
129
                              )
130
130
                change = (file_id,
131
 
                    (old_path, new_path),
132
 
                    True,
133
 
                    (False, True),
134
 
                    (None, ie.parent_id),
135
 
                    (None, ie.name),
136
 
                    (None, ie.kind),
137
 
                    (None, ie.executable),
138
 
                    )
 
131
                          (old_path, new_path),
 
132
                          True,
 
133
                          (False, True),
 
134
                          (None, ie.parent_id),
 
135
                          (None, ie.name),
 
136
                          (None, ie.kind),
 
137
                          (None, ie.executable),
 
138
                          )
139
139
            else:
140
140
                if ie is None:
141
141
                    change = (file_id,
142
 
                        (old_path, new_path),
143
 
                        True,
144
 
                        (True, False),
145
 
                        (old_ie.parent_id, None),
146
 
                        (old_ie.name, None),
147
 
                        (old_ie.kind, None),
148
 
                        (old_ie.executable, None),
149
 
                        )
 
142
                              (old_path, new_path),
 
143
                              True,
 
144
                              (True, False),
 
145
                              (old_ie.parent_id, None),
 
146
                              (old_ie.name, None),
 
147
                              (old_ie.kind, None),
 
148
                              (old_ie.executable, None),
 
149
                              )
150
150
                else:
151
 
                    content_modified = (ie.text_sha1 != old_ie.text_sha1
152
 
                                        or ie.text_size != old_ie.text_size)
 
151
                    content_modified = (ie.text_sha1 != old_ie.text_sha1 or
 
152
                                        ie.text_size != old_ie.text_size)
153
153
                    # TODO: ie.kind != old_ie.kind
154
154
                    # TODO: symlinks changing targets, content_modified?
155
155
                    change = (file_id,
156
 
                        (old_path, new_path),
157
 
                        content_modified,
158
 
                        (True, True),
159
 
                        (old_ie.parent_id, ie.parent_id),
160
 
                        (old_ie.name, ie.name),
161
 
                        (old_ie.kind, ie.kind),
162
 
                        (old_ie.executable, ie.executable),
163
 
                        )
 
156
                              (old_path, new_path),
 
157
                              content_modified,
 
158
                              (True, True),
 
159
                              (old_ie.parent_id, ie.parent_id),
 
160
                              (old_ie.name, ie.name),
 
161
                              (old_ie.kind, ie.kind),
 
162
                              (old_ie.executable, ie.executable),
 
163
                              )
164
164
            yield change
165
165
 
166
166
 
212
212
        inv.id_to_entry = chk_map.CHKMap(chk_store, None, search_key_func)
213
213
        inv.id_to_entry._root_node.set_maximum_size(maximum_size)
214
214
        inv.parent_id_basename_to_file_id = chk_map.CHKMap(chk_store,
215
 
            None, search_key_func)
 
215
                                                           None, search_key_func)
216
216
        inv.parent_id_basename_to_file_id._root_node.set_maximum_size(
217
217
            maximum_size)
218
218
        inv.parent_id_basename_to_file_id._root_node._key_width = 2
251
251
        # new write group. We want one write group around a batch of imports
252
252
        # where the default batch size is currently 10000. IGC 20090312
253
253
        self._commit_builder = self.repo._commit_builder_class(self.repo,
254
 
            parents, config, timestamp=revision.timestamp,
255
 
            timezone=revision.timezone, committer=revision.committer,
256
 
            revprops=revision.properties, revision_id=revision.revision_id)
 
254
                                                               parents, config, timestamp=revision.timestamp,
 
255
                                                               timezone=revision.timezone, committer=revision.committer,
 
256
                                                               revprops=revision.properties, revision_id=revision.revision_id)
257
257
 
258
258
    def get_parents_and_revision_for_entry(self, ie):
259
259
        """Get the parents and revision for an inventory entry.
266
266
        # Check for correct API usage
267
267
        if self._current_rev_id is None:
268
268
            raise AssertionError("start_new_revision() must be called"
269
 
                " before get_parents_and_revision_for_entry()")
 
269
                                 " before get_parents_and_revision_for_entry()")
270
270
        if ie.revision != self._current_rev_id:
271
271
            raise AssertionError("start_new_revision() registered a different"
272
 
                " revision (%s) to that in the inventory entry (%s)" %
273
 
                (self._current_rev_id, ie.revision))
 
272
                                 " revision (%s) to that in the inventory entry (%s)" %
 
273
                                 (self._current_rev_id, ie.revision))
274
274
 
275
275
        # Find the heads. This code is lifted from
276
276
        # repository.CommitBuilder.record_entry_contents().
277
277
        parent_candidate_entries = ie.parent_candidates(self._rev_parent_invs)
278
278
        head_set = self._commit_builder._heads(ie.file_id,
279
 
            list(parent_candidate_entries))
 
279
                                               list(parent_candidate_entries))
280
280
        heads = []
281
281
        for inv in self._rev_parent_invs:
282
282
            try:
297
297
        changed = False
298
298
        if len(heads) > 1:
299
299
            changed = True
300
 
        elif (parent_entry.name != ie.name or parent_entry.kind != ie.kind or
301
 
            parent_entry.parent_id != ie.parent_id):
 
300
        elif (parent_entry.name != ie.name or parent_entry.kind != ie.kind
 
301
              or parent_entry.parent_id != ie.parent_id):
302
302
            changed = True
303
303
        elif ie.kind == 'file':
304
 
            if (parent_entry.text_sha1 != ie.text_sha1 or
305
 
                parent_entry.executable != ie.executable):
 
304
            if (parent_entry.text_sha1 != ie.text_sha1
 
305
                    or parent_entry.executable != ie.executable):
306
306
                changed = True
307
307
        elif ie.kind == 'symlink':
308
308
            if parent_entry.symlink_target != ie.symlink_target:
314
314
        return tuple(heads), rev_id
315
315
 
316
316
    def load_using_delta(self, rev, basis_inv, inv_delta, signature,
317
 
        text_provider, parents_provider, inventories_provider=None):
 
317
                         text_provider, parents_provider, inventories_provider=None):
318
318
        """Load a revision by applying a delta to a (CHK)Inventory.
319
319
 
320
320
        :param rev: the Revision
334
334
        """
335
335
        # TODO: set revision_id = rev.revision_id
336
336
        builder = self.repo._commit_builder_class(self.repo,
337
 
            parents=rev.parent_ids, config=None, timestamp=rev.timestamp,
338
 
            timezone=rev.timezone, committer=rev.committer,
339
 
            revprops=rev.properties, revision_id=rev.revision_id)
 
337
                                                  parents=rev.parent_ids, config=None, timestamp=rev.timestamp,
 
338
                                                  timezone=rev.timezone, committer=rev.committer,
 
339
                                                  revprops=rev.properties, revision_id=rev.revision_id)
340
340
        if self._graph is None and self._use_known_graph:
341
 
            if (getattr(_mod_graph, 'GraphThunkIdsToKeys', None) and
342
 
                getattr(_mod_graph.GraphThunkIdsToKeys, "add_node", None) and
343
 
                getattr(self.repo, "get_known_graph_ancestry", None)):
 
341
            if (getattr(_mod_graph, 'GraphThunkIdsToKeys', None)
 
342
                and getattr(_mod_graph.GraphThunkIdsToKeys, "add_node", None)
 
343
                    and getattr(self.repo, "get_known_graph_ancestry", None)):
344
344
                self._graph = self.repo.get_known_graph_ancestry(
345
345
                    rev.parent_ids)
346
346
            else:
347
347
                self._use_known_graph = False
348
348
        if self._graph is not None:
349
349
            orig_heads = builder._heads
 
350
 
350
351
            def thunked_heads(file_id, revision_ids):
351
352
                # self._graph thinks in terms of keys, not ids, so translate
352
353
                # them
383
384
        rev.inv_sha1 = builder.inv_sha1
384
385
        config = builder._config_stack
385
386
        builder.repository.add_revision(builder._new_revision_id, rev,
386
 
            builder.revision_tree().root_inventory)
 
387
                                        builder.revision_tree().root_inventory)
387
388
        if self._graph is not None:
388
389
            # TODO: Use StaticTuple and .intern() for these things
389
390
            self._graph.add_node(builder._new_revision_id, rev.parent_ids)
395
396
 
396
397
    def get_file_lines(self, revision_id, file_id):
397
398
        record = next(self.repo.texts.get_record_stream([(file_id, revision_id)],
398
 
            'unordered', True))
 
399
                                                        'unordered', True))
399
400
        if record.storage_kind == 'absent':
400
401
            raise errors.RevisionNotPresent(record.key, self.repo)
401
402
        return osutils.split_lines(record.get_bytes_as('fulltext'))