244
245
revid = b.revision_history()[0]
245
246
self.log('first revision_id is {%s}' % revid)
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()))
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')
255
self.check_inventory_shape(wt.inventory,
255
self.check_tree_shape(wt,
256
256
['newdir/', 'newdir/sub/', 'newdir/sub/file'])
258
258
wt.rename_one('newdir/sub', 'newdir/newsub')
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'])
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()])
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)
1127
class TestWorthSavingLimit(TestCaseWithWorkingTree):
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'
1135
self.addCleanup(wt.unlock)
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)
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)
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())