From 203d59b115bd7dd653b68892fb6fd514df628480 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Thu, 17 Jun 2010 14:02:53 -0700 Subject: [PATCH] views.dag: Use the parent/child attributes from Commit objects We don't need to track this in the view now that the commit objects provide them. Signed-off-by: David Aguilar --- cola/views/dag.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/cola/views/dag.py b/cola/views/dag.py index 9cc9b74e..feff8aa5 100644 --- a/cola/views/dag.py +++ b/cola/views/dag.py @@ -321,8 +321,6 @@ class GraphView(QtGui.QGraphicsView): self._items = [] self._selected = [] - self._commits = {} - self._children = {} self._nodes = {} self._loc = {} @@ -545,10 +543,6 @@ class GraphView(QtGui.QGraphicsView): def add(self, commits): scene = self.scene() for commit in commits: - self._commits[commit.sha1] = commit - for p in commit.parents: - children = self._children.setdefault(p, []) - children.append(commit.sha1) node = Node(commit) scene.addItem(node) self._nodes[commit.sha1] = node @@ -558,13 +552,9 @@ class GraphView(QtGui.QGraphicsView): """Create edges linking commits with their parents""" scene = self.scene() for commit in commits: - children = self._children.get(commit.sha1, None) - # root commit - if children is None: - continue commit_node = self._nodes[commit.sha1] - for child_sha1 in children: - child_node = self._nodes[child_sha1] + for child in commit.children: + child_node = self._nodes[child.sha1] edge = Edge(commit_node, child_node) scene.addItem(edge) @@ -575,13 +565,6 @@ class GraphView(QtGui.QGraphicsView): xpos = 0 ypos = 0 for commit in commits: - if commit.sha1 not in self._children: - self._loc[commit.sha1] = (xpos, ypos) - node = self._nodes.get(commit.sha1, None) - node.setPos(xpos, ypos) - xpos += self._xoff - gxmax = max(xpos, gxmax) - continue ymax = 0 xmax = None for sha1 in self._children[commit.sha1]: -- 2.11.4.GIT