23
23
import bzrlib.bzrdir as bzrdir
24
24
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
25
25
from bzrlib.commit import commit
26
from bzrlib.delta import TreeDelta
26
27
import bzrlib.errors as errors
27
28
from bzrlib.errors import (FileExists,
101
102
tree = b2.repository.revision_tree('revision-1')
102
103
self.assertEqual(tree.get_file_text('foo-id'), 'hello')
105
def test_get_revision_delta(self):
106
tree_a = self.make_branch_and_tree('a')
107
self.build_tree(['a/foo'])
108
tree_a.add('foo', 'file1')
109
tree_a.commit('rev1', rev_id='rev1')
110
self.build_tree(['a/vla'])
111
tree_a.add('vla', 'file2')
112
tree_a.commit('rev2', rev_id='rev2')
114
delta = tree_a.branch.get_revision_delta(1)
115
self.assertIsInstance(delta, TreeDelta)
116
self.assertEqual([('foo', 'file1', 'file')], delta.added)
117
delta = tree_a.branch.get_revision_delta(2)
118
self.assertIsInstance(delta, TreeDelta)
119
self.assertEqual([('vla', 'file2', 'file')], delta.added)
104
121
def get_unbalanced_tree_pair(self):
105
122
"""Return two branches, a and b, with one file in a."""
106
123
get_transport(self.get_url()).mkdir('a')
316
333
text = tree.branch._format.get_format_description()
317
334
self.failUnless(len(text))
336
def test_check_branch_report_results(self):
337
"""Checking a branch produces results which can be printed"""
338
branch = self.make_branch('.')
339
result = branch.check()
340
# reports results through logging
341
result.report_results(verbose=True)
342
result.report_results(verbose=False)
344
def test_get_commit_builder(self):
345
self.assertIsInstance(self.make_branch(".").get_commit_builder([]),
346
bzrlib.repository.CommitBuilder)
320
349
class ChrootedTests(TestCaseWithBranch):
321
350
"""A support class that provides readonly urls outside the local namespace.
478
507
self.assertEqual(None, self.get_branch().get_push_location())
480
509
def test_get_push_location_exact(self):
481
from bzrlib.config import (branches_config_filename,
510
from bzrlib.config import (locations_config_filename,
482
511
ensure_config_dir_exists)
483
512
ensure_config_dir_exists()
484
fn = branches_config_filename()
513
fn = locations_config_filename()
485
514
print >> open(fn, 'wt'), ("[%s]\n"
486
515
"push_location=foo" %
487
516
self.get_branch().base[:-1])
488
517
self.assertEqual("foo", self.get_branch().get_push_location())
490
519
def test_set_push_location(self):
491
from bzrlib.config import (branches_config_filename,
520
from bzrlib.config import (locations_config_filename,
492
521
ensure_config_dir_exists)
493
522
ensure_config_dir_exists()
494
fn = branches_config_filename()
523
fn = locations_config_filename()
495
524
self.get_branch().set_push_location('foo')
496
525
self.assertFileEqual("[%s]\n"
497
526
"push_location = foo" % self.get_branch().base[:-1],