2372
2372
if self._new_revision_id is None:
2373
2373
self._new_revision_id = self._gen_revision_id()
2375
def record_entry_contents(self, ie, parent_invs, path, tree):
2376
"""Record the content of ie from tree into the commit if needed.
2378
Side effect: sets ie.revision when unchanged
2380
:param ie: An inventory entry present in the commit.
2375
def _check_root(self, ie, parent_invs, tree):
2376
"""Helper for record_entry_contents.
2378
:param ie: An entry being added.
2381
2379
:param parent_invs: The inventories of the parent revisions of the
2383
:param path: The path the entry is at in the tree.
2384
:param tree: The tree which contains this entry and should be used to
2381
:param tree: The tree that is being committed.
2387
if self.new_inventory.root is None and ie.parent_id is not None:
2383
if ie.parent_id is not None:
2384
# if ie is not root, add a root automatically.
2388
2385
symbol_versioning.warn('Root entry should be supplied to'
2389
2386
' record_entry_contents, as of bzr 0.10.',
2390
2387
DeprecationWarning, stacklevel=2)
2391
2388
self.record_entry_contents(tree.inventory.root.copy(), parent_invs,
2393
self.new_inventory.add(ie)
2395
# ie.revision is always None if the InventoryEntry is considered
2396
# for committing. ie.snapshot will record the correct revision
2397
# which may be the sole parent if it is untouched.
2398
if ie.revision is not None:
2401
# In this revision format, root entries have no knit or weave
2402
if ie is self.new_inventory.root:
2403
# When serializing out to disk and back in
2404
# root.revision is always _new_revision_id
2391
# In this revision format, root entries have no knit or weave When
2392
# serializing out to disk and back in root.revision is always
2405
2394
ie.revision = self._new_revision_id
2396
def record_entry_contents(self, ie, parent_invs, path, tree):
2397
"""Record the content of ie from tree into the commit if needed.
2399
Side effect: sets ie.revision when unchanged
2401
:param ie: An inventory entry present in the commit.
2402
:param parent_invs: The inventories of the parent revisions of the
2404
:param path: The path the entry is at in the tree.
2405
:param tree: The tree which contains this entry and should be used to
2408
if self.new_inventory.root is None:
2409
self._check_root(ie, parent_invs, tree)
2410
self.new_inventory.add(ie)
2412
# ie.revision is always None if the InventoryEntry is considered
2413
# for committing. ie.snapshot will record the correct revision
2414
# which may be the sole parent if it is untouched.
2415
if ie.revision is not None:
2407
previous_entries = ie.find_previous_heads(
2409
self.repository.weave_store,
2410
self.repository.get_transaction())
2411
# we are creating a new revision for ie in the history store
2418
parent_candiate_entries = ie.parent_candidates(parent_invs)
2419
heads = self.repository.get_graph().heads(parent_candiate_entries.keys())
2420
# XXX: Note that this is unordered - and this is tolerable because
2421
# the previous code was also unordered.
2422
previous_entries = dict((head, parent_candiate_entries[head]) for head
2424
# we are creating a new revision for ie in the history store and
2413
2426
ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
2415
2428
def modified_directory(self, file_id, file_parents):
2491
2504
record_root_entry = True
2493
def record_entry_contents(self, ie, parent_invs, path, tree):
2494
"""Record the content of ie from tree into the commit if needed.
2496
Side effect: sets ie.revision when unchanged
2498
:param ie: An inventory entry present in the commit.
2506
def _check_root(self, ie, parent_invs, tree):
2507
"""Helper for record_entry_contents.
2509
:param ie: An entry being added.
2499
2510
:param parent_invs: The inventories of the parent revisions of the
2501
:param path: The path the entry is at in the tree.
2502
:param tree: The tree which contains this entry and should be used to
2512
:param tree: The tree that is being committed.
2505
assert self.new_inventory.root is not None or ie.parent_id is None
2506
self.new_inventory.add(ie)
2508
# ie.revision is always None if the InventoryEntry is considered
2509
# for committing. ie.snapshot will record the correct revision
2510
# which may be the sole parent if it is untouched.
2511
if ie.revision is not None:
2514
previous_entries = ie.find_previous_heads(
2516
self.repository.weave_store,
2517
self.repository.get_transaction())
2518
# we are creating a new revision for ie in the history store
2520
ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
2514
# ie must be root for this builder
2515
assert ie.parent_id is None
2523
2518
_unescape_map = {