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])
47
47
def id2path(self, file_id):
48
48
if file_id in self._new_info_by_id:
118
118
raise AssertionError('How is both old and new None?')
119
119
change = (file_id,
120
(old_path, new_path),
120
(old_path, new_path),
128
128
change = (file_id,
129
(old_path, new_path),
132
(None, ie.parent_id),
135
(None, ie.executable),
129
(old_path, new_path),
132
(None, ie.parent_id),
135
(None, ie.executable),
139
139
change = (file_id,
140
(old_path, new_path),
143
(old_ie.parent_id, None),
146
(old_ie.executable, None),
140
(old_path, new_path),
143
(old_ie.parent_id, None),
146
(old_ie.executable, None),
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),
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),
154
(old_path, new_path),
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),
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(
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)
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))
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))
279
279
for inv in self._rev_parent_invs:
296
296
if len(heads) > 1:
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):
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):
305
305
elif ie.kind == 'symlink':
306
306
if parent_entry.symlink_target != ie.symlink_target:
312
312
return tuple(heads), rev_id
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.
318
318
:param rev: the Revision
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(
345
345
self._use_known_graph = False
346
346
if self._graph is not None:
347
347
orig_heads = builder._heads
348
349
def thunked_heads(file_id, revision_ids):
349
350
# self._graph thinks in terms of keys, not ids, so translate
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)
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)],
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'))