~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_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:
1219
1219
        wt = self.make_branch_and_tree('.')
1220
1220
        self.build_tree(['foo'])
1221
1221
        wt.add(['foo'])
 
1222
        wt.commit("one")
1222
1223
        tt = TreeTransform(wt)
1223
1224
        self.addCleanup(tt.finalize)
1224
1225
        foo_trans_id = tt.trans_id_tree_path("foo")
1229
1230
        tt.version_file("bar-1", bar_trans_id)
1230
1231
        tt.apply()
1231
1232
        self.failUnlessExists("foo/bar")
 
1233
        wt.lock_read()
 
1234
        try:
 
1235
            self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
 
1236
                    "directory")
 
1237
        finally:
 
1238
            wt.unlock()
 
1239
        wt.commit("two")
 
1240
        changes = wt.changes_from(wt.basis_tree())
 
1241
        self.assertFalse(changes.has_changed(), changes)
 
1242
 
 
1243
    def test_file_to_symlink(self):
 
1244
        self.requireFeature(SymlinkFeature)
 
1245
        wt = self.make_branch_and_tree('.')
 
1246
        self.build_tree(['foo'])
 
1247
        wt.add(['foo'])
 
1248
        wt.commit("one")
 
1249
        tt = TreeTransform(wt)
 
1250
        self.addCleanup(tt.finalize)
 
1251
        foo_trans_id = tt.trans_id_tree_path("foo")
 
1252
        tt.delete_contents(foo_trans_id)
 
1253
        tt.create_symlink("bar", foo_trans_id)
 
1254
        tt.apply()
 
1255
        self.failUnlessExists("foo")
 
1256
        wt.lock_read()
 
1257
        self.addCleanup(wt.unlock)
 
1258
        self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
 
1259
                "symlink")
 
1260
 
 
1261
    def test_dir_to_file(self):
 
1262
        wt = self.make_branch_and_tree('.')
 
1263
        self.build_tree(['foo/', 'foo/bar'])
 
1264
        wt.add(['foo', 'foo/bar'])
 
1265
        wt.commit("one")
 
1266
        tt = TreeTransform(wt)
 
1267
        self.addCleanup(tt.finalize)
 
1268
        foo_trans_id = tt.trans_id_tree_path("foo")
 
1269
        bar_trans_id = tt.trans_id_tree_path("foo/bar")
 
1270
        tt.delete_contents(foo_trans_id)
 
1271
        tt.delete_versioned(bar_trans_id)
 
1272
        tt.create_file(["aa\n"], foo_trans_id)
 
1273
        tt.apply()
 
1274
        self.failUnlessExists("foo")
 
1275
        wt.lock_read()
 
1276
        self.addCleanup(wt.unlock)
 
1277
        self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
 
1278
                "file")
 
1279
 
 
1280
    def test_dir_to_hardlink(self):
 
1281
        self.requireFeature(HardlinkFeature)
 
1282
        wt = self.make_branch_and_tree('.')
 
1283
        self.build_tree(['foo/', 'foo/bar'])
 
1284
        wt.add(['foo', 'foo/bar'])
 
1285
        wt.commit("one")
 
1286
        tt = TreeTransform(wt)
 
1287
        self.addCleanup(tt.finalize)
 
1288
        foo_trans_id = tt.trans_id_tree_path("foo")
 
1289
        bar_trans_id = tt.trans_id_tree_path("foo/bar")
 
1290
        tt.delete_contents(foo_trans_id)
 
1291
        tt.delete_versioned(bar_trans_id)
 
1292
        self.build_tree(['baz'])
 
1293
        tt.create_hardlink("baz", foo_trans_id)
 
1294
        tt.apply()
 
1295
        self.failUnlessExists("foo")
 
1296
        self.failUnlessExists("baz")
 
1297
        wt.lock_read()
 
1298
        self.addCleanup(wt.unlock)
 
1299
        self.assertEqual(wt.inventory.get_file_kind(wt.path2id("foo")),
 
1300
                "file")
1232
1301
 
1233
1302
 
1234
1303
class TransformGroup(object):