253
def test_add_missing(self):
254
# adding a msising file -> NoSuchFile
255
wt = self.make_branch_and_tree('.')
256
self.assertRaises(errors.NoSuchFile, wt.add, 'fpp')
252
258
def test_remove_verbose(self):
253
259
#FIXME the remove api should not print or otherwise depend on the
254
260
# text UI - RBC 20060124
265
271
self.assertEqual('? hello\n', stdout.getvalue())
266
272
self.assertEqual('', stderr.getvalue())
274
def test_clone_trivial(self):
275
wt = self.make_branch_and_tree('source')
276
cloned = wt.clone('target')
277
self.assertEqual(cloned.last_revision(), wt.last_revision())
279
def test_last_revision(self):
280
wt = self.make_branch_and_tree('source')
281
self.assertEqual(None, wt.last_revision())
282
wt.commit('A', allow_pointless=True, rev_id='A')
283
self.assertEqual('A', wt.last_revision())
285
def test_set_last_revision(self):
286
wt = self.make_branch_and_tree('source')
287
self.assertEqual(None, wt.last_revision())
288
# cannot set the last revision to one not in the branch
289
self.assertRaises(errors.NoSuchRevision, wt.set_last_revision, 'A')
290
wt.commit('A', allow_pointless=True, rev_id='A')
291
self.assertEqual('A', wt.last_revision())
292
# None is aways in the branch
293
wt.set_last_revision(None)
294
self.assertEqual(None, wt.last_revision())
295
# and now we can set it to 'A'
296
# because the current format mutates the branch to set it,
297
# we need to alter the branch to let this pass.
298
wt.branch.set_revision_history(['A', 'B'])
299
wt.set_last_revision('A')
300
self.assertEqual('A', wt.last_revision())
302
def test_clone_and_commit_preserves_last_revision(self):
303
wt = self.make_branch_and_tree('source')
304
cloned = wt.clone('target')
305
wt.commit('A', allow_pointless=True, rev_id='A')
306
self.assertNotEqual(cloned.last_revision(), wt.last_revision())
308
def test_basis_tree_returns_last_revision(self):
309
wt = self.make_branch_and_tree('.')
310
self.build_tree(['foo'])
311
wt.add('foo', 'foo-id')
312
wt.commit('A', rev_id='A')
313
wt.rename_one('foo', 'bar')
314
wt.commit('B', rev_id='B')
315
wt.set_last_revision('B')
316
tree = wt.basis_tree()
317
self.failUnless(tree.has_filename('bar'))
318
wt.set_last_revision('A')
319
tree = wt.basis_tree()
320
self.failUnless(tree.has_filename('foo'))