14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
from bzrlib.selftest import TestCaseInTempDir
20
class TestAppendRevisions(TestCaseInTempDir):
21
"""Test appending more than one revision"""
19
from bzrlib.branch import Branch, copy_stores, copy_branch
20
from bzrlib.commit import commit
21
from bzrlib.errors import NoSuchRevision, UnlistableBranch
23
class TestBranch(TestCaseInTempDir):
22
25
def test_append_revisions(self):
23
from bzrlib.branch import Branch
26
"""Test appending more than one revision"""
24
27
br = Branch.initialize(".")
25
28
br.append_revision("rev1")
26
29
self.assertEquals(br.revision_history(), ["rev1",])
27
30
br.append_revision("rev2", "rev3")
28
31
self.assertEquals(br.revision_history(), ["rev1", "rev2", "rev3"])
33
def test_copy_stores(self):
34
"""Copy the stores from one branch to another"""
36
br_a = Branch.initialize("a")
37
file('a/b', 'wb').write('b')
39
commit(br_a, "silly commit")
42
br_b = Branch.initialize("b")
43
self.assertRaises(NoSuchRevision, br_b.get_revision,
44
br_a.revision_history()[0])
45
copy_stores(br_a, br_b)
46
rev = br_b.get_revision(br_a.revision_history()[0])
47
tree = br_b.revision_tree(br_a.revision_history()[0])
49
if tree.inventory[file_id].kind == "file":
50
tree.get_file(file_id).read()
53
def test_copy_branch(self):
54
"""Copy the stores from one branch to another"""
55
br_a, br_b = self.test_copy_stores()
56
commit(br_b, "silly commit")
58
br_c = copy_branch(br_a, 'c', basis_branch=br_b)
59
self.assertEqual(br_a.revision_history(), br_c.revision_history())
60
assert br_b.last_patch() not in br_c.revision_history()
61
br_c.get_revision(br_b.last_patch())
31
62
# TODO: rewrite this as a regular unittest, without relying on the displayed output
32
63
# >>> from bzrlib.commit import commit
33
64
# >>> bzrlib.trace.silent = True