def test_get_revid_branch_info(self): builder = self.make_branch_builder('trunk') builder.start_series() builder.build_snapshot('rev-a', None, [ ('add', ('', 'TREE_ROOT', 'directory', '')), ]) builder.build_snapshot('rev-branch', ['rev-a'], []) builder.build_snapshot('rev-trunk', ['rev-a'], []) builder.finish_series() # ○ branch # │ # ○ │ trunk # ├─╯ # ○ rev-a trunk = builder.get_branch() #trunk.set_last_revision('rev-trunk') branch = trunk.bzrdir.sprout('../branch', revision_id='rev-branch').open_branch() trunk_bi = loggraphviz.BranchInfo('trunk', None, trunk) branch_bi = loggraphviz.BranchInfo('branch', None, branch) gv = loggraphviz.GraphVizLoader([trunk_bi, branch_bi], trunk_bi, False) gv.load() self.assertEqual(trunk_bi, gv.get_revid_branch_info('rev-trunk')) self.assertEqual(branch_bi, gv.get_revid_branch_info('rev-branch')) # may return either self.assertIn(gv.get_revid_branch_info('rev-a'), (branch_bi, trunk_bi))
def test_branch_tips_date_sorted(self): trunk, old, new = self.make_banches_for_tips_date_sorted() trunk_bi = loggraphviz.BranchInfo('trunk', None, trunk) gv = loggraphviz.GraphVizLoader([ trunk_bi, loggraphviz.BranchInfo('old', None, old), loggraphviz.BranchInfo('new', None, new), ], trunk_bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ ('rev-new', 2, None, [(2, 2, 0, True)]), # ○ # │ ('rev-old', 1, None, [(1, 1, 0, True), (2, 2, 0, True)]), # ○ │ # │ │ ( 'rev-trunk', 0, None, [ (0, 0, 0, True), (1, 0, 0, True), # ○ │ │ (2, 0, 0, True) ]), # ├─╯─╯ ('rev-a', 0, None, []) ], # ○ computed)
def test_branch_tips_date_sorted_with_working_tree_provider(self): trunk, old, new = self.make_banches_for_tips_date_sorted() trunk_tree = trunk.bzrdir.create_workingtree() old_tree = old.bzrdir.open_workingtree() new_tree = new.bzrdir.open_workingtree() trunk_bi = loggraphviz.BranchInfo('trunk', trunk_tree, trunk) gv = loggraphviz.WithWorkingTreeGraphVizLoader([ trunk_bi, loggraphviz.BranchInfo('old', old_tree, old), loggraphviz.BranchInfo('new', new_tree, new), ], trunk_bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ (gv.tree_revid(new_tree), 2, None, [(2, 2, 3, True) ]), # ○ # │ ('rev-new', 2, None, [(2, 2, 0, True)]), # ○ # │ ( gv.tree_revid(old_tree), 1, None, [ (1, 1, 2, True), # ○ │ (2, 2, 0, True) ]), # │ │ ('rev-old', 1, None, [(1, 1, 0, True), (2, 2, 0, True)]), # ○ │ # │ │ ( gv.tree_revid(trunk_tree), 0, None, [ # ○ │ │ (0, 0, 0, True), (1, 1, 0, True), (2, 2, 0, True) ]), # │ │ │ ( 'rev-trunk', 0, None, [ (0, 0, 0, True), (1, 0, 0, True), # ○ │ │ (2, 0, 0, True) ]), # ├─╯─╯ ('rev-a', 0, None, []) ], # ○ computed)
def test_with_working_tree_provider_out_of_date_wt(self): tree = self.make_tree_not_up_to_date('branch') bi = loggraphviz.BranchInfo('branch', tree, tree.branch) gv = loggraphviz.WithWorkingTreeGraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ ( u'current:%s' % tree.basedir, 1, None, [(1, 1, 0, True)], # ○ ['branch - Working Tree']), # │ ( 'rev-b', 0, None, [(0, 0, 0, True), (1, 0, 0, True)], # ○ │ ['branch']), # ├─╯ ('rev-a', 0, None, [], []) ], # ○ computed, branch_labels=True)
def test_with_working_tree_provider(self): tree = self.make_tree_with_pending_merge('branch') bi = loggraphviz.BranchInfo('branch', tree, tree.branch) gv = loggraphviz.WithWorkingTreeGraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ ( u'current:%s' % tree.basedir, 0, True, # ⊖ [(0, 0, 0, True), (0, 1, 2, True)], # ├─╮ ['branch - Working Tree']), # │ │ ( 'rev-b', 1, None, [(0, 0, 0, True), (1, 0, 0, True)], # │ ○ ['branch - Pending Merge']), # ├─╯ ('rev-a', 0, None, [], ['branch']) ], # ○ computed, branch_labels=True)
def test_no_commits(self): br = self.make_branch('.') bi = loggraphviz.BranchInfo('', None, br) gv = loggraphviz.GraphVizLoader([bi], bi, False) gv.load() self.assertEqual(len(gv.revisions), 0) state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertEqual(len(computed.revisions), 0)
def test_pending_merges_provider(self): tree = self.make_tree_with_pending_merge('branch') bi = loggraphviz.BranchInfo(None, tree, tree.branch) gv = loggraphviz.PendingMergesGraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ ('rev-b', 1, None, [(1, 0, 0, True)]), # ○ # ╭─╯ ('root:', 0, None, []) ], # ○ computed)
def test_out_of_date_wt(self): tree = self.make_tree_not_up_to_date('branch') bi = loggraphviz.BranchInfo(None, tree, tree.branch) gv = loggraphviz.GraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ ('rev-b', 0, None, [(0, 0, 0, True)], [None]), # ○ # │ ('rev-a', 0, None, [], ['Working Tree']) ], # ○ computed, branch_labels=True)
def test_get_revid_branch_info_with_ghost(self): tree = self.make_branch_and_tree('tree') tree.commit('a', rev_id='rev-a') tree.add_parent_tree_id('rev-b') tree.commit('c', rev_id='rev-c') # rev-b is a ghost. We think he is there, but he dose not exist. Boo! # c # ├─╮ # │ b # │ # a bi = loggraphviz.BranchInfo(None, tree, tree.branch) gv = loggraphviz.GraphVizLoader([bi], bi, False) gv.load() self.assertRaises(loggraphviz.GhostRevisionError, gv.get_revid_branch_info, 'rev-b')
def test_with_ghost_mainline(self): tree = self.make_branch_and_tree('tree') tree.add_parent_tree_id('rev-a', allow_leftmost_as_ghost=True) tree.commit('b', rev_id='rev-b') bi = loggraphviz.BranchInfo(None, tree, tree.branch) gv = loggraphviz.GraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) computed = gv.compute_viz(state) self.assertComputed( [ ('rev-b', 0, None, [(0, 0, 0, True)]), # ○ # │ ('rev-a', 0, None, []) ], # ○ computed)
def test_with_working_tree_provider_filtered(self): # This test makes sure that lable for a Working Tree shows for on it's # nearest visble unique ansestor when the working tree node is # filtered. builder = self.make_branch_builder('branch') builder.start_series() builder.build_snapshot('rev-a', None, [ ('add', ('', 'TREE_ROOT', 'directory', '')), ]) builder.build_snapshot('rev-b', ['rev-a'], []) builder.build_snapshot('rev-c', ['rev-a'], []) builder.finish_series() branch = builder.get_branch() tree = branch.bzrdir.create_workingtree() tree.update(revision='rev-b') bi = loggraphviz.BranchInfo('branch', tree, tree.branch) gv = loggraphviz.WithWorkingTreeGraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) state.filters.append( BasicFilterer( set(['current:%s' % tree.basedir.encode('unicode-escape')]))) computed = gv.compute_viz(state) self.assertComputed( [ ('rev-b', 1, None, [(1, 1, 0, True) ], ['branch - Working Tree']), # ○ # │ ('rev-c', 0, None, [(0, 0, 0, True), (1, 0, 0, True)], ['branch']), # ○ │ # ├─╯ ('rev-a', 0, None, [], []) ], # ○ computed, branch_labels=True)
def test_with_ghost(self): tree = self.make_branch_and_tree('tree') tree.commit('a', rev_id='rev-a') tree.add_parent_tree_id('rev-b') tree.commit('c', rev_id='rev-c') # rev-b is a ghost. We think he is there, but he dose not exist. Boo! bi = loggraphviz.BranchInfo(None, tree, tree.branch) gv = loggraphviz.GraphVizLoader([bi], bi, False) gv.load() state = loggraphviz.GraphVizFilterState(gv) state.expand_all_branch_lines() computed = gv.compute_viz(state) self.assertComputed( [ ('rev-c', 0, True, [(0, 0, 0, True), (0, 1, 1, True)]), # ⊖ # ├─╮ ('rev-b', 1, None, [(0, 0, 0, True)]), # │ ○ # │ ('rev-a', 0, None, []) ], # ○ computed)
def __init__(self, heads, graph_dict, no_graph=False): self.heads = heads self.graph_dict = graph_dict bi = loggraphviz.BranchInfo(None, None, None) loggraphviz.GraphVizLoader.__init__(self, [bi], bi, no_graph)