2184
2184
if self._new_revision_id is None:
2185
2185
self._new_revision_id = self._gen_revision_id()
2187
def record_entry_contents(self, ie, parent_invs, path, tree):
2188
"""Record the content of ie from tree into the commit if needed.
2190
Side effect: sets ie.revision when unchanged
2192
:param ie: An inventory entry present in the commit.
2187
def _check_root(self, ie, parent_invs, tree):
2188
"""Helper for record_entry_contents.
2190
:param ie: An entry being added.
2193
2191
:param parent_invs: The inventories of the parent revisions of the
2195
:param path: The path the entry is at in the tree.
2196
:param tree: The tree which contains this entry and should be used to
2193
:param tree: The tree that is being committed.
2199
if self.new_inventory.root is None and ie.parent_id is not None:
2195
if ie.parent_id is not None:
2196
# if ie is not root, add a root automatically.
2200
2197
symbol_versioning.warn('Root entry should be supplied to'
2201
2198
' record_entry_contents, as of bzr 0.10.',
2202
2199
DeprecationWarning, stacklevel=2)
2203
2200
self.record_entry_contents(tree.inventory.root.copy(), parent_invs,
2205
self.new_inventory.add(ie)
2207
# ie.revision is always None if the InventoryEntry is considered
2208
# for committing. ie.snapshot will record the correct revision
2209
# which may be the sole parent if it is untouched.
2210
if ie.revision is not None:
2213
# In this revision format, root entries have no knit or weave
2214
if ie is self.new_inventory.root:
2215
# When serializing out to disk and back in
2216
# root.revision is always _new_revision_id
2203
# In this revision format, root entries have no knit or weave When
2204
# serializing out to disk and back in root.revision is always
2217
2206
ie.revision = self._new_revision_id
2208
def record_entry_contents(self, ie, parent_invs, path, tree):
2209
"""Record the content of ie from tree into the commit if needed.
2211
Side effect: sets ie.revision when unchanged
2213
:param ie: An inventory entry present in the commit.
2214
:param parent_invs: The inventories of the parent revisions of the
2216
:param path: The path the entry is at in the tree.
2217
:param tree: The tree which contains this entry and should be used to
2220
if self.new_inventory.root is None:
2221
self._check_root(ie, parent_invs, tree)
2222
self.new_inventory.add(ie)
2224
# ie.revision is always None if the InventoryEntry is considered
2225
# for committing. ie.snapshot will record the correct revision
2226
# which may be the sole parent if it is untouched.
2227
if ie.revision is not None:
2219
previous_entries = ie.find_previous_heads(
2221
self.repository.weave_store,
2222
self.repository.get_transaction())
2223
# we are creating a new revision for ie in the history store
2230
parent_candiate_entries = ie.parent_candidates(parent_invs)
2231
heads = self.repository.get_graph().heads(parent_candiate_entries.keys())
2232
# XXX: Note that this is unordered - and this is tolerable because
2233
# the previous code was also unordered.
2234
previous_entries = dict((head, parent_candiate_entries[head]) for head
2236
# we are creating a new revision for ie in the history store and
2225
2238
ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
2227
2240
def modified_directory(self, file_id, file_parents):
2304
2317
record_root_entry = True
2306
def record_entry_contents(self, ie, parent_invs, path, tree):
2307
"""Record the content of ie from tree into the commit if needed.
2309
Side effect: sets ie.revision when unchanged
2311
:param ie: An inventory entry present in the commit.
2319
def _check_root(self, ie, parent_invs, tree):
2320
"""Helper for record_entry_contents.
2322
:param ie: An entry being added.
2312
2323
:param parent_invs: The inventories of the parent revisions of the
2314
:param path: The path the entry is at in the tree.
2315
:param tree: The tree which contains this entry and should be used to
2325
:param tree: The tree that is being committed.
2318
assert self.new_inventory.root is not None or ie.parent_id is None
2319
self.new_inventory.add(ie)
2321
# ie.revision is always None if the InventoryEntry is considered
2322
# for committing. ie.snapshot will record the correct revision
2323
# which may be the sole parent if it is untouched.
2324
if ie.revision is not None:
2327
previous_entries = ie.find_previous_heads(
2329
self.repository.weave_store,
2330
self.repository.get_transaction())
2331
# we are creating a new revision for ie in the history store
2333
ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
2327
# ie must be root for this builder
2328
assert ie.parent_id is None
2336
2331
_unescape_map = {