18
18
from StringIO import StringIO
20
from bzrlib.bzrdir import BzrDir
21
from bzrlib.status import show_pending_merges
22
from bzrlib.tests import TestCaseInTempDir
25
class TestStatus(TestCaseInTempDir):
20
from bzrlib.revisionspec import RevisionSpec
21
from bzrlib.status import show_pending_merges, show_tree_status
22
from bzrlib.tests import TestCaseWithTransport
25
class TestStatus(TestCaseWithTransport):
27
27
def test_pending_none(self):
28
28
# Test whether show_pending_merges works in a tree with no commits
29
tree = BzrDir.create_standalone_workingtree('a')
29
tree = self.make_branch_and_tree('a')
30
30
tree.commit('empty commit')
31
tree2 = BzrDir.create_standalone_workingtree('b')
32
tree2.branch.fetch(tree.branch)
33
tree2.set_pending_merges([tree.last_revision()])
31
tree2 = self.make_branch_and_tree('b')
32
# set a left most parent that is not a present commit
33
tree2.add_parent_tree_id('some-ghost', allow_leftmost_as_ghost=True)
35
tree2.merge_from_branch(tree.branch)
34
36
output = StringIO()
35
37
show_pending_merges(tree2, output)
36
38
self.assertContainsRe(output.getvalue(), 'empty commit')
40
def tests_revision_to_revision(self):
41
"""doing a status between two revision trees should work."""
42
tree = self.make_branch_and_tree('.')
43
r1_id = tree.commit('one', allow_pointless=True)
44
r2_id = tree.commit('two', allow_pointless=True)
45
r2_tree = tree.branch.repository.revision_tree(r2_id)
47
show_tree_status(tree, to_file=output,
48
revision=[RevisionSpec.from_string("revid:%s" % r1_id),
49
RevisionSpec.from_string("revid:%s" % r2_id)])
50
# return does not matter as long as it did not raise.