Пример #1
0
 def test_simple(self):
     lg = linegraph(self.get_graph({"A": ("B", "C"), "B": ()}), ["A"])
     self.assertEquals(lg,
         ([
            ['A', (0, 0), [(0, 0, 0)], ['B'], [], (2,)],
            ['B', (0, 0), [], (), ['A'], (1,)]
          ],
          {'A': 0, 'B': 1},
          1))
Пример #2
0
    def populate(self, revision=None):
        """Fill the treeview with contents.

        :param start: Revision id of revision to start with.
        :param maxnum: Maximum number of revisions to display, or None 
                       for no limit.
        :param broken_line_length: After how much lines branches \
                       should be broken.
        """

        if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
            # We'are using our own ui, let's tell it to use our widget.
            ui.ui_factory.set_progress_bar_widget(self.progress_widget)
        self.progress_bar = ui.ui_factory.nested_progress_bar()
        self.progress_bar.update("Loading ancestry graph", 0, 5)

        try:
            if self.compact:
                broken_line_length = 32
            else:
                broken_line_length = None

            show_graph = self.graph_column.get_visible()

            self.branch.lock_read()
            (linegraphdata, index, columns_len) = linegraph(
                self.branch.repository.get_graph(),
                self.start,
                self.maxnum, 
                broken_line_length,
                show_graph,
                self.mainline_only,
                self.progress_bar)

            self.model.set_line_graph_data(linegraphdata)
            self.graph_cell.columns_len = columns_len
            width = self.graph_cell.get_preferred_width(self.treeview)[1]
            if width > 500:
                width = 500
            elif width == 0:
                # The get_preferred_width() call got an insane value.
                width = 200
            self.graph_column.set_fixed_width(width)
            self.graph_column.set_max_width(width)
            self.index = index
            self.treeview.set_model(self.model)

            if not revision or revision == NULL_REVISION:
                self.treeview.set_cursor(Gtk.TreePath(path=0), None, False)
            else:
                self.set_revision(revision)

            self.emit('refreshed')
            return False
        finally:
            self.progress_bar.finished()