Exemplo n.º 1
0
    def test_get_revid_branch_info(self):
        builder = self.make_branch_builder('trunk')
        builder.start_series()
        rev_a = builder.build_snapshot(None, [
            ('add', ('', b'TREE_ROOT', 'directory', b'')),
        ])
        rev_branch = builder.build_snapshot([rev_a], [])
        rev_trunk = builder.build_snapshot([rev_a], [])
        builder.finish_series()
        #   ○ branch
        #   │
        # ○ │ trunk
        # ├─╯
        # ○ rev-a

        trunk = builder.get_branch()
        #trunk.set_last_revision(rev_trunk)

        branch = trunk.controldir.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))
Exemplo n.º 2
0
    def test_branch_tips_date_sorted(self):
        common_rev, 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(
            [
                (new.last_revision(), 2, None, [(2, 2, 0, True)]),  #     ○
                #     │
                (old.last_revision(), 1, None, [(1, 1, 0, True),
                                                (2, 2, 0, True)]),  #   ○ │
                #   │ │
                (
                    trunk.last_revision(),
                    0,
                    None,
                    [
                        (0, 0, 0, True),
                        (1, 0, 0, True),  # ○ │ │
                        (2, 0, 0, True)
                    ]),  # ├─╯─╯
                (common_rev, 0, None, [])
            ],  # ○
            computed)
Exemplo n.º 3
0
    def test_branch_tips_date_sorted_with_working_tree_provider(self):
        common_rev, trunk, old, new = self.make_banches_for_tips_date_sorted()
        trunk_tree = trunk.controldir.create_workingtree()
        old_tree = old.controldir.open_workingtree()
        new_tree = new.controldir.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)]),  #     ○
                #     │
                (new.last_revision(), 2, None, [(2, 2, 0, True)]),  #     ○
                #     │
                (
                    gv.tree_revid(old_tree),
                    1,
                    None,
                    [
                        (1, 1, 2, True),  #   ○ │
                        (2, 2, 0, True)
                    ]),  #   │ │
                (old.last_revision(), 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)
                    ]),  # │ │ │
                (
                    trunk.last_revision(),
                    0,
                    None,
                    [
                        (0, 0, 0, True),
                        (1, 0, 0, True),  # ○ │ │
                        (2, 0, 0, True)
                    ]),  # ├─╯─╯
                (common_rev, 0, None, [])
            ],  # ○
            computed)
Exemplo n.º 4
0
    def test_with_working_tree_provider_out_of_date_wt(self):
        tree, [rev_a, rev_b] = 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(
            [
                (
                    bytes('current:%s' % tree.basedir, 'utf-8'),
                    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)
Exemplo n.º 5
0
    def test_with_working_tree_provider(self):
        # RJLRJL tree.basedir seems to come back as a string here...
        tree, [rev_a, rev_b] = 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)

        # RJLRL Force 'current...' string to bytes
        self.assertComputed(
            [
                (
                    bytes('current:%s' % tree.basedir, 'utf-8'),
                    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    def test_pending_merges_provider(self):
        tree, [rev_a, rev_b] = 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)
Exemplo n.º 8
0
    def test_out_of_date_wt(self):
        tree, [rev_a, rev_b] = 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)
Exemplo n.º 9
0
    def test_get_revid_branch_info_with_ghost(self):
        tree = self.make_branch_and_tree('tree')
        rev_a = tree.commit('a')
        tree.add_parent_tree_id(b'rev-b')
        rev_c = tree.commit('c')
        # rev-b is a ghost. We think he is there, but he does 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, b'rev-b')
Exemplo n.º 10
0
    def test_with_ghost_mainline(self):
        tree = self.make_branch_and_tree('tree')
        tree.add_parent_tree_id(b'rev-a', allow_leftmost_as_ghost=True)
        rev_b = tree.commit('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)]),  # ○
                # │
                (b'rev-a', 0, None, [])
            ],  # ○
            computed)
Exemplo n.º 11
0
    def test_with_working_tree_provider_filtered(self):
        # This test makes sure that label 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()
        rev_a = builder.build_snapshot(None, [
            ('add', ('', b'TREE_ROOT', 'directory', b'')),
        ])
        rev_b = builder.build_snapshot([rev_a], [])
        rev_c = builder.build_snapshot([rev_a], [])
        builder.finish_series()

        branch = builder.get_branch()
        tree = branch.controldir.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')])))
        state.filters.append(
            BasicFilterer(set([bytes('current:%s' % tree.basedir, 'utf-8')])))
        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)
Exemplo n.º 12
0
    def test_with_ghost(self):
        tree = self.make_branch_and_tree('tree')
        rev_a = tree.commit('a')
        tree.add_parent_tree_id(b'rev-b')
        rev_c = tree.commit('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)]),  # ⊖
                # ├─╮
                (b'rev-b', 1, None, [(0, 0, 0, True)]),  # │ ○
                # │
                (rev_a, 0, None, [])
            ],  # ○
            computed)
Exemplo n.º 13
0
 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)