/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-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

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