~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1162
1162
        transform.cancel_creation(parent)
1163
1163
        transform.finalize()
1164
1164
 
1165
 
    def test_case_insensitive_clash(self):
1166
 
        self.requireFeature(CaseInsensitiveFilesystemFeature)
 
1165
    def test_rollback_on_directory_clash(self):
1167
1166
        def tt_helper():
1168
1167
            wt = self.make_branch_and_tree('.')
1169
1168
            tt = TreeTransform(wt)  # TreeTransform obtains write lock
1170
1169
            try:
1171
 
                tt.new_file('foo', tt.root, 'bar')
1172
 
                tt.new_file('Foo', tt.root, 'spam')
 
1170
                foo = tt.new_directory('foo', tt.root)
 
1171
                tt.new_file('bar', foo, 'foobar')
 
1172
                baz = tt.new_directory('baz', tt.root)
 
1173
                tt.new_file('qux', baz, 'quux')
 
1174
                # Ask for a rename 'foo' -> 'baz'
 
1175
                tt.adjust_path('baz', tt.root, foo)
1173
1176
                # Lie to tt that we've already resolved all conflicts.
1174
1177
                tt.apply(no_conflicts=True)
1175
1178
            except:
1176
1179
                wt.unlock()
1177
1180
                raise
 
1181
        # The rename will fail because the target directory is not empty (but
 
1182
        # raises FileExists anyway).
1178
1183
        err = self.assertRaises(errors.FileExists, tt_helper)
1179
1184
        self.assertContainsRe(str(err),
1180
 
            "^File exists: .+/foo")
 
1185
            "^File exists: .+/baz")
1181
1186
 
1182
1187
    def test_two_directories_clash(self):
1183
1188
        def tt_helper():
1186
1191
            try:
1187
1192
                foo_1 = tt.new_directory('foo', tt.root)
1188
1193
                tt.new_directory('bar', foo_1)
 
1194
                # Adding the same directory with a different content
1189
1195
                foo_2 = tt.new_directory('foo', tt.root)
1190
1196
                tt.new_directory('baz', foo_2)
1191
1197
                # Lie to tt that we've already resolved all conflicts.
1204
1210
            try:
1205
1211
                foo_1 = tt.new_directory('foo', tt.root)
1206
1212
                tt.new_directory('bar', foo_1)
 
1213
                # Adding the same directory with a different content
1207
1214
                foo_2 = tt.new_directory('foo', tt.root)
1208
1215
                tt.new_directory('baz', foo_2)
1209
1216
                # Lie to tt that we've already resolved all conflicts.
2046
2053
                          (False, False))],
2047
2054
                          list(preview_tree.iter_changes(revision_tree)))
2048
2055
 
2049
 
    def test_wrong_tree_value_error(self):
2050
 
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
2051
 
        e = self.assertRaises(ValueError, preview_tree.iter_changes,
2052
 
                              preview_tree)
2053
 
        self.assertEqual('from_tree must be transform source tree.', str(e))
2054
 
 
2055
2056
    def test_include_unchanged_value_error(self):
2056
2057
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
2057
2058
        e = self.assertRaises(ValueError, preview_tree.iter_changes,
2452
2453
        expected = [(('', 'tree-root'),
2453
2454
                    [('a', 'a', 'file', None, 'a-id', 'file')])]
2454
2455
        self.assertEqual(expected, list(preview_tree.walkdirs()))
 
2456
 
 
2457
    def test_extras(self):
 
2458
        work_tree = self.make_branch_and_tree('tree')
 
2459
        self.build_tree(['tree/removed-file', 'tree/existing-file',
 
2460
                         'tree/not-removed-file'])
 
2461
        work_tree.add(['removed-file', 'not-removed-file'])
 
2462
        preview = TransformPreview(work_tree)
 
2463
        self.addCleanup(preview.finalize)
 
2464
        preview.new_file('new-file', preview.root, 'contents')
 
2465
        preview.new_file('new-versioned-file', preview.root, 'contents',
 
2466
                         'new-versioned-id')
 
2467
        tree = preview.get_preview_tree()
 
2468
        preview.unversion_file(preview.trans_id_tree_path('removed-file'))
 
2469
        self.assertEqual(set(['new-file', 'removed-file', 'existing-file']),
 
2470
                         set(tree.extras()))