~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-08-06 20:57:54 UTC
  • mfrom: (3590.3.5 bzr.dev.transform)
  • Revision ID: pqm@pqm.ubuntu.com-20080806205754-tyo3u7h84tgr0h9k
(James Westby) Make TreeTransform.apply() update the WT for kind
        changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1217
1217
                mover = _mover
1218
1218
            try:
1219
1219
                child_pb.update('Apply phase', 0, 2)
1220
 
                self._apply_removals(new_inventory_delta, mover)
 
1220
                kind_changes = self._apply_removals(new_inventory_delta, mover)
1221
1221
                child_pb.update('Apply phase', 1, 2)
1222
1222
                modified_paths = self._apply_insertions(new_inventory_delta,
1223
 
                                                        mover)
 
1223
                                                        mover, kind_changes)
1224
1224
            except:
1225
1225
                mover.rollback()
1226
1226
                raise
1244
1244
        """
1245
1245
        tree_paths = list(self._tree_path_ids.iteritems())
1246
1246
        tree_paths.sort(reverse=True)
 
1247
        kind_changes = set()
1247
1248
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1248
1249
        try:
1249
1250
            for num, data in enumerate(tree_paths):
1251
1252
                child_pb.update('removing file', num, len(tree_paths))
1252
1253
                full_path = self._tree.abspath(path)
1253
1254
                if trans_id in self._removed_contents:
 
1255
                    try:
 
1256
                        if (self.tree_kind(trans_id)
 
1257
                                != self.final_kind(trans_id)):
 
1258
                            kind_changes.add(trans_id)
 
1259
                    except NoSuchFile:
 
1260
                        pass
1254
1261
                    mover.pre_delete(full_path, os.path.join(self._deletiondir,
1255
1262
                                     trans_id))
1256
1263
                elif trans_id in self._new_name or trans_id in \
1274
1281
                    inventory_delta.append((path, None, file_id, None))
1275
1282
        finally:
1276
1283
            child_pb.finished()
 
1284
        return kind_changes
1277
1285
 
1278
 
    def _apply_insertions(self, inventory_delta, mover):
 
1286
    def _apply_insertions(self, inventory_delta, mover, kind_changes):
1279
1287
        """Perform tree operations that insert directory/inventory names.
1280
1288
 
1281
1289
        That is, create any files that need to be created, and restore from
1284
1292
 
1285
1293
        If inventory_delta is None, no inventory delta is calculated, and
1286
1294
        no list of modified paths is returned.
 
1295
 
 
1296
        kind_changes is a set of trans ids where the entry has changed
 
1297
        kind, and so an inventory delta entry should be created for them.
1287
1298
        """
1288
1299
        new_paths = self.new_paths(filesystem_only=(inventory_delta is None))
1289
1300
        modified_paths = []
1320
1331
                    if file_id is not None and (trans_id in self._new_id or
1321
1332
                        trans_id in self._new_name or
1322
1333
                        trans_id in self._new_parent
1323
 
                        or trans_id in self._new_executability):
 
1334
                        or trans_id in self._new_executability
 
1335
                        or trans_id in kind_changes):
1324
1336
                        try:
1325
1337
                            kind = self.final_kind(trans_id)
1326
1338
                        except NoSuchFile: