210
210
:param path: The path the entry is at in the tree.
211
211
:param tree: The tree which contains this entry and should be used to
213
:return: True if a new version of the entry has been recorded.
214
(Committing a merge where a file was only changed on the other side
215
will not return True.)
213
:return: A tuple (change_delta, version_recorded). change_delta is
214
an inventory_delta change for this entry against the basis tree of
215
the commit, or None if no change occured against the basis tree.
216
version_recorded is True if a new version of the entry has been
217
recorded. For instance, committing a merge where a file was only
218
changed on the other side will return (delta, False).
217
220
if self.new_inventory.root is None:
218
221
if ie.parent_id is not None:
220
223
self._check_root(ie, parent_invs, tree)
221
224
self.new_inventory.add(ie)
226
# TODO: slow, take it out of the inner loop.
228
basis_inv = parent_invs[0]
230
basis_inv = Inventory(root_id=None)
223
232
# ie.revision is always None if the InventoryEntry is considered
224
233
# for committing. ie.snapshot will record the correct revision
225
234
# which may be the sole parent if it is untouched.
226
235
if ie.revision is not None:
227
return ie.revision == self._new_revision_id and (path != '' or
236
if self._versioned_root or path != '':
237
# not considered for commit
240
# repositories that do not version the root set the root's
241
# revision to the new commit even when no change occurs, and
242
# this masks when a change may have occurred against the basis,
243
# so calculate if one happened.
244
if ie.file_id not in basis_inv:
246
delta = (None, path, ie.file_id, ie)
248
basis_id = basis_inv[ie.file_id]
249
if basis_id.name != '':
251
delta = (basis_inv.id2path(ie.file_id), path,
256
# not considered for commit, OR, for non-rich-root
257
return delta, ie.revision == self._new_revision_id and (path != '' or
228
258
self._versioned_root)
230
260
parent_candiate_entries = ie.parent_candidates(parent_invs)
236
266
# we are creating a new revision for ie in the history store and
238
268
ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
239
return ie.revision == self._new_revision_id and (path != '' or
269
if ie.file_id not in basis_inv:
271
delta = (None, path, ie.file_id, ie)
272
elif ie != basis_inv[ie.file_id]:
274
delta = (basis_inv.id2path(ie.file_id), path, ie.file_id,
279
return delta, ie.revision == self._new_revision_id and (path != '' or
240
280
self._versioned_root)
242
282
def modified_directory(self, file_id, file_parents):