~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: 2010-11-08 13:45:51 UTC
  • mfrom: (5532.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20101108134551-sxvk77ehmegkrwmm
(vila) Fix news entry

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
import errno
18
17
import os
19
18
from StringIO import StringIO
20
19
import sys
53
52
    ImmortalPendingDeletion,
54
53
    LockError,
55
54
    MalformedTransform,
 
55
    NoSuchFile,
56
56
    ReusingTransform,
57
57
)
58
58
from bzrlib.osutils import (
64
64
    features,
65
65
    HardlinkFeature,
66
66
    SymlinkFeature,
 
67
    TestCase,
67
68
    TestCaseInTempDir,
68
69
    TestSkipped,
69
70
)
73
74
    cook_conflicts,
74
75
    _FileMover,
75
76
    FinalPaths,
 
77
    get_backup_name,
76
78
    resolve_conflicts,
77
79
    resolve_checkout,
78
80
    ROOT_PARENT,
898
900
        # On windows looks like:
899
901
        # "Failed to rename .../work/myfile to 
900
902
        # .../work/.bzr/checkout/limbo/new-1: [Errno 13] Permission denied"
901
 
        # This test isn't concerned with exactly what the error looks like,
902
 
        # and the strerror will vary across OS and locales, but the assert
903
 
        # that the exeception attributes are what we expect
904
 
        self.assertEqual(e.errno, errno.EACCES)
905
 
        if os.name == "posix":
906
 
            self.assertEndsWith(e.to_path, "/first-dir/newname")
907
 
        else:
908
 
            self.assertEqual(os.path.basename(e.from_path), "myfile")
 
903
        # The strerror will vary per OS and language so it's not checked here
 
904
        self.assertContainsRe(str(e),
 
905
            "Failed to rename .*(first-dir.newname:|myfile)")
909
906
 
910
907
    def test_set_executability_order(self):
911
908
        """Ensure that executability behaves the same, no matter what order.
2384
2381
                  ('TREE_ROOT', 'TREE_ROOT'), ('a', 'a'), ('file', 'file'),
2385
2382
                  (False, False))
2386
2383
ROOT_ENTRY = ('TREE_ROOT', ('', ''), False, (True, True), (None, None),
2387
 
              ('', ''), ('directory', 'directory'), (False, False))
 
2384
              ('', ''), ('directory', 'directory'), (False, None))
2388
2385
 
2389
2386
 
2390
2387
class TestTransformPreview(tests.TestCaseWithTransport):
2477
2474
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
2478
2475
        changes = preview_tree.iter_changes(revision_tree,
2479
2476
                                            specific_files=[''])
2480
 
        self.assertEqual([A_ENTRY], list(changes))
 
2477
        self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
2481
2478
 
2482
2479
    def test_want_unversioned(self):
2483
2480
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
2484
2481
        changes = preview_tree.iter_changes(revision_tree,
2485
2482
                                            want_unversioned=True)
2486
 
        self.assertEqual([A_ENTRY], list(changes))
 
2483
        self.assertEqual([ROOT_ENTRY, A_ENTRY], list(changes))
2487
2484
 
2488
2485
    def test_ignore_extra_trees_no_specific_files(self):
2489
2486
        # extra_trees is harmless without specific_files, so we'll silently
3275
3272
                                               policy)
3276
3273
 
3277
3274
    def _prepare_orphan(self, wt):
3278
 
        self.build_tree(['dir/', 'dir/file', 'dir/foo'])
3279
 
        wt.add(['dir', 'dir/file'], ['dir-id', 'file-id'])
3280
 
        wt.commit('add dir and file ignoring foo')
 
3275
        self.build_tree(['dir/', 'dir/foo'])
 
3276
        wt.add(['dir'], ['dir-id'])
 
3277
        wt.commit('add dir')
3281
3278
        tt = transform.TreeTransform(wt)
3282
3279
        self.addCleanup(tt.finalize)
3283
 
        # dir and bar are deleted
3284
3280
        dir_tid = tt.trans_id_tree_path('dir')
3285
 
        file_tid = tt.trans_id_tree_path('dir/file')
3286
3281
        orphan_tid = tt.trans_id_tree_path('dir/foo')
3287
 
        tt.delete_contents(file_tid)
3288
 
        tt.unversion_file(file_tid)
3289
3282
        tt.delete_contents(dir_tid)
3290
3283
        tt.unversion_file(dir_tid)
3291
 
        # There should be a conflict because dir still contain foo
3292
3284
        raw_conflicts = tt.find_conflicts()
3293
3285
        self.assertLength(1, raw_conflicts)
3294
3286
        self.assertEqual(('missing parent', 'new-1'), raw_conflicts[0])
3298
3290
        wt = self.make_branch_and_tree('.')
3299
3291
        self._set_orphan_policy(wt, 'move')
3300
3292
        tt, orphan_tid = self._prepare_orphan(wt)
3301
 
        warnings = []
3302
 
        def warning(*args):
3303
 
            warnings.append(args[0] % args[1:])
3304
 
        self.overrideAttr(trace, 'warning', warning)
3305
3293
        remaining_conflicts = resolve_conflicts(tt)
3306
 
        self.assertEquals(['dir/foo has been orphaned in bzr-orphans'],
3307
 
                          warnings)
3308
3294
        # Yeah for resolved conflicts !
3309
3295
        self.assertLength(0, remaining_conflicts)
3310
3296
        # We have a new orphan