203
205
os.unlink('hello.txt')
204
206
tree.remove('hello.txt')
205
207
tree.revert(['hello.txt'])
206
self.failUnlessExists('hello.txt')
208
self.assertPathExists('hello.txt')
208
210
def test_versioned_files_not_unknown(self):
209
211
tree = self.make_branch_and_tree('.')
244
246
revid = b.revision_history()[0]
245
247
self.log('first revision_id is {%s}' % revid)
247
inv = b.repository.get_inventory(revid)
248
self.log('contents of inventory: %r' % inv.entries())
249
tree = b.repository.revision_tree(revid)
250
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'])
252
self.check_tree_shape(tree, ['dir/', 'dir/sub/', 'dir/sub/file'])
252
253
wt.rename_one('dir', 'newdir')
255
self.check_inventory_shape(wt.inventory,
256
self.check_tree_shape(wt,
256
257
['newdir/', 'newdir/sub/', 'newdir/sub/file'])
258
259
wt.rename_one('newdir/sub', 'newdir/newsub')
260
self.check_inventory_shape(wt.inventory,
261
['newdir/', 'newdir/newsub/',
261
self.check_tree_shape(wt, ['newdir/', 'newdir/newsub/',
262
262
'newdir/newsub/file'])
327
327
# because some formats mutate the branch to set it on the tree
328
328
# we need to alter the branch to let this pass.
330
wt.branch.set_revision_history(['A', 'B'])
330
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
331
wt.branch.set_revision_history, ['A', 'B'])
331
332
except errors.NoSuchRevision, e:
332
333
self.assertEqual('B', e.revision)
333
334
raise TestSkipped("Branch format does not permit arbitrary"
398
399
wt.set_parent_ids(['B'])
399
400
tree = wt.basis_tree()
401
self.failUnless(tree.has_filename('bar'))
402
self.assertTrue(tree.has_filename('bar'))
403
404
wt.set_parent_ids(['A'])
404
405
tree = wt.basis_tree()
406
self.failUnless(tree.has_filename('foo'))
407
self.assertTrue(tree.has_filename('foo'))
409
410
def test_clone_tree_revision(self):
464
465
wt.commit('A', rev_id='A')
465
466
# and update old_tree
466
467
self.assertEqual(0, old_tree.update())
467
self.failUnlessExists('checkout/file')
468
self.assertPathExists('checkout/file')
468
469
self.assertEqual(['A'], old_tree.get_parent_ids())
470
471
def test_update_sets_root_id(self):
485
486
wt.commit('A', rev_id='A')
486
487
# and update checkout
487
488
self.assertEqual(0, checkout.update())
488
self.failUnlessExists('checkout/file')
489
self.assertPathExists('checkout/file')
489
490
self.assertEqual(wt.get_root_id(), checkout.get_root_id())
490
491
self.assertNotEqual(None, wt.get_root_id())
568
569
self.assertFileEqual('a test\n', 'b1/a')
569
self.failUnlessExists('b1/b.~1~')
570
self.failIfExists('b1/c')
571
self.failIfExists('b1/a.~1~')
572
self.failUnlessExists('b1/d')
570
self.assertPathExists('b1/b.~1~')
571
self.assertPathDoesNotExist('b1/c')
572
self.assertPathDoesNotExist('b1/a.~1~')
573
self.assertPathExists('b1/d')
574
575
def test_update_updates_bound_branch_no_local_commits(self):
575
576
# doing an update in a tree updates the branch its bound to too.
738
739
def test_format_description(self):
739
740
tree = self.make_branch_and_tree('tree')
740
741
text = tree._format.get_format_description()
741
self.failUnless(len(text))
742
self.assertTrue(len(text))
743
744
def test_branch_attribute_is_not_settable(self):
744
745
# the branch attribute is an aspect of the working tree, not a
776
777
self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
777
778
[(path, ie.kind) for path,ie in
778
tree.inventory.iter_entries()])
779
tree.iter_entries_by_dir()])
781
782
osutils.normalized_filename = orig
797
798
def test__write_inventory(self):
798
799
# The private interface _write_inventory is currently used by transform.
799
800
tree = self.make_branch_and_tree('.')
801
if not isinstance(tree, InventoryWorkingTree):
802
raise TestNotApplicable("_write_inventory does not exist on "
803
"non-inventory working trees")
800
804
# if we write write an inventory then do a walkdirs we should get back
801
805
# missing entries, and actual, and unknowns as appropriate.
802
806
self.build_tree(['present', 'unknown'])
1070
1074
self.assertEqual(0, wt.update(revision='1'))
1071
1075
self.assertEqual('1', wt.last_revision())
1072
1076
self.assertEqual(tip, wt.branch.last_revision())
1073
self.failUnlessExists('checkout/file1')
1074
self.failIfExists('checkout/file4')
1075
self.failIfExists('checkout/file5')
1077
self.assertPathExists('checkout/file1')
1078
self.assertPathDoesNotExist('checkout/file4')
1079
self.assertPathDoesNotExist('checkout/file5')
1078
1082
class TestIllegalPaths(TestCaseWithWorkingTree):
1120
1124
# above the control dir but we might need to relax that?
1121
1125
self.assertEqual(wt.control_url.find(wt.user_url), 0)
1122
1126
self.assertEqual(wt.control_url, wt.control_transport.base)
1129
class TestWorthSavingLimit(TestCaseWithWorkingTree):
1131
def make_wt_with_worth_saving_limit(self):
1132
wt = self.make_branch_and_tree('wt')
1133
if getattr(wt, '_worth_saving_limit', None) is None:
1134
raise tests.TestNotApplicable('no _worth_saving_limit for'
1137
self.addCleanup(wt.unlock)
1140
def test_not_set(self):
1141
# Default should be 10
1142
wt = self.make_wt_with_worth_saving_limit()
1143
self.assertEqual(10, wt._worth_saving_limit())
1144
ds = wt.current_dirstate()
1145
self.assertEqual(10, ds._worth_saving_limit)
1147
def test_set_in_branch(self):
1148
wt = self.make_wt_with_worth_saving_limit()
1149
config = wt.branch.get_config()
1150
config.set_user_option('bzr.workingtree.worth_saving_limit', '20')
1151
self.assertEqual(20, wt._worth_saving_limit())
1152
ds = wt.current_dirstate()
1153
self.assertEqual(10, ds._worth_saving_limit)
1155
def test_invalid(self):
1156
wt = self.make_wt_with_worth_saving_limit()
1157
config = wt.branch.get_config()
1158
config.set_user_option('bzr.workingtree.worth_saving_limit', 'a')
1159
# If the config entry is invalid, default to 10
1160
# TODO: This writes a warning to the user, trap it somehow
1161
self.assertEqual(10, wt._worth_saving_limit())