/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-08 16:02:52 UTC
  • mfrom: (5837 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5838.
  • Revision ID: jelmer@samba.org-20110508160252-akovn3laoln5sfx9
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    TreeDirectory,
42
42
    TreeFile,
43
43
    TreeLink,
 
44
    InventoryWorkingTree,
44
45
    WorkingTree,
45
46
    )
46
47
from bzrlib.conflicts import ConflictList, TextConflict, ContentsConflict
244
245
        revid = b.revision_history()[0]
245
246
        self.log('first revision_id is {%s}' % revid)
246
247
 
247
 
        inv = b.repository.get_inventory(revid)
248
 
        self.log('contents of inventory: %r' % inv.entries())
 
248
        tree = b.repository.revision_tree(revid)
 
249
        self.log('contents of tree: %r' % list(tree.iter_entries_by_dir()))
249
250
 
250
 
        self.check_inventory_shape(inv,
251
 
                                   ['dir/', 'dir/sub/', 'dir/sub/file'])
 
251
        self.check_tree_shape(tree, ['dir/', 'dir/sub/', 'dir/sub/file'])
252
252
        wt.rename_one('dir', 'newdir')
253
253
 
254
254
        wt.lock_read()
255
 
        self.check_inventory_shape(wt.inventory,
 
255
        self.check_tree_shape(wt,
256
256
                                   ['newdir/', 'newdir/sub/', 'newdir/sub/file'])
257
257
        wt.unlock()
258
258
        wt.rename_one('newdir/sub', 'newdir/newsub')
259
259
        wt.lock_read()
260
 
        self.check_inventory_shape(wt.inventory,
261
 
                                   ['newdir/', 'newdir/newsub/',
 
260
        self.check_tree_shape(wt, ['newdir/', 'newdir/newsub/',
262
261
                                    'newdir/newsub/file'])
263
262
        wt.unlock()
264
263
 
775
774
            tree.lock_read()
776
775
            self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
777
776
                    [(path, ie.kind) for path,ie in
778
 
                                tree.inventory.iter_entries()])
 
777
                                tree.iter_entries_by_dir()])
779
778
            tree.unlock()
780
779
        finally:
781
780
            osutils.normalized_filename = orig
797
796
    def test__write_inventory(self):
798
797
        # The private interface _write_inventory is currently used by transform.
799
798
        tree = self.make_branch_and_tree('.')
 
799
        if not isinstance(tree, InventoryWorkingTree):
 
800
            raise TestNotApplicable("_write_inventory does not exist on "
 
801
                "non-inventory working trees")
800
802
        # if we write write an inventory then do a walkdirs we should get back
801
803
        # missing entries, and actual, and unknowns as appropriate.
802
804
        self.build_tree(['present', 'unknown'])
1120
1122
        # above the control dir but we might need to relax that?
1121
1123
        self.assertEqual(wt.control_url.find(wt.user_url), 0)
1122
1124
        self.assertEqual(wt.control_url, wt.control_transport.base)
 
1125
 
 
1126
 
 
1127
class TestWorthSavingLimit(TestCaseWithWorkingTree):
 
1128
 
 
1129
    def make_wt_with_worth_saving_limit(self):
 
1130
        wt = self.make_branch_and_tree('wt')
 
1131
        if getattr(wt, '_worth_saving_limit', None) is None:
 
1132
            raise tests.TestNotApplicable('no _worth_saving_limit for'
 
1133
                                          ' this tree type')
 
1134
        wt.lock_write()
 
1135
        self.addCleanup(wt.unlock)
 
1136
        return wt
 
1137
 
 
1138
    def test_not_set(self):
 
1139
        # Default should be 10
 
1140
        wt = self.make_wt_with_worth_saving_limit()
 
1141
        self.assertEqual(10, wt._worth_saving_limit())
 
1142
        ds = wt.current_dirstate()
 
1143
        self.assertEqual(10, ds._worth_saving_limit)
 
1144
 
 
1145
    def test_set_in_branch(self):
 
1146
        wt = self.make_wt_with_worth_saving_limit()
 
1147
        config = wt.branch.get_config()
 
1148
        config.set_user_option('bzr.workingtree.worth_saving_limit', '20')
 
1149
        self.assertEqual(20, wt._worth_saving_limit())
 
1150
        ds = wt.current_dirstate()
 
1151
        self.assertEqual(10, ds._worth_saving_limit)
 
1152
 
 
1153
    def test_invalid(self):
 
1154
        wt = self.make_wt_with_worth_saving_limit()
 
1155
        config = wt.branch.get_config()
 
1156
        config.set_user_option('bzr.workingtree.worth_saving_limit', 'a')
 
1157
        # If the config entry is invalid, default to 10
 
1158
        # TODO: This writes a warning to the user, trap it somehow
 
1159
        self.assertEqual(10, wt._worth_saving_limit())