1169
def update_by_delta(self, delta):
1170
"""Apply an inventory delta to the dirstate for tree 0
1172
:param delta: An inventory delta. See Inventory.apply_delta for
1175
self._read_dirblocks_if_needed()
1178
for old_path, new_path, file_id, inv_entry in sorted(delta,
1180
assert file_id not in insertions
1181
assert file_id not in removals
1182
if old_path is not None:
1183
old_path = old_path.encode('utf-8')
1184
removals[file_id] = old_path
1185
if new_path is not None:
1186
new_path = new_path.encode('utf-8')
1187
dirname, basename = osutils.split(new_path)
1188
key = (dirname, basename, file_id)
1189
minikind = DirState._kind_to_minikind[inv_entry.kind]
1191
fingerprint = inv_entry.reference_revision
1194
insertions[file_id] = (key, minikind, inv_entry.executable,
1195
fingerprint, new_path)
1196
if None not in (old_path, new_path):
1197
for child in self._iter_child_entries(0, old_path):
1198
if child[0][2] in insertions or child[0][2] in removals:
1200
child_dirname = child[0][0]
1201
child_basename = child[0][1]
1202
minikind = child[1][0][0]
1203
fingerprint = child[1][0][4]
1204
executable = child[1][0][3]
1205
old_child_path = osutils.pathjoin(child[0][0],
1207
removals[child[0][2]] = old_child_path
1208
child_suffix = child_dirname[len(old_path):]
1209
new_child_dirname = (new_path + child_suffix)
1210
key = (new_child_dirname, child_basename, child[0][2])
1211
new_child_path = os.path.join(new_child_dirname,
1213
insertions[child[0][2]] = (key, minikind, executable,
1214
fingerprint, new_child_path)
1215
self._apply_removals(removals.values())
1216
self._apply_insertions(insertions.values())
1218
def _apply_removals(self, removals):
1219
for path in sorted(removals, reverse=True):
1220
dirname, basename = osutils.split(path)
1221
block_i, entry_i, d_present, f_present = \
1222
self._get_block_entry_index(dirname, basename, 0)
1223
entry = self._dirblocks[block_i][1][entry_i]
1224
self._make_absent(entry)
1226
def _apply_insertions(self, adds):
1227
for key, minikind, executable, fingerprint, path_utf8 in sorted(adds):
1228
self.update_minimal(key, minikind, executable, fingerprint,
1229
path_utf8=path_utf8)
1169
1231
def update_basis_by_delta(self, delta, new_revid):
1170
1232
"""Update the parents of this tree after a commit.