@matheusbsbs / matheus-bagliano / commits / 3fe5489a25
Fork 0

gitview: Display the lines joining commit nodes clearly.

Since i wanted to limit the graph box size i was resetting the window after an index of 5. This result in line joining commit nodes to pass over nodes which are not related. The changes fixes the same Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Aneesh Kumar K.V committed Feb 24, 2006 at 00:59 UTC 3fe5489a2550118e0eb3f90e348cb78afeeb61e0
1 file changed +35 -13
contrib/gitview/gitview
+35 -13
@@ -823,6 +823,7 @@ class GitView:
823 self.colours = {}
824 self.nodepos = {}
825 self.incomplete_line = {}
826 + self.commits = []
827
828 index = 0
829 last_colour = 0
@@ -840,12 +841,7 @@ class GitView:
841
842 commit = Commit(commit_lines)
843 if (commit != None ):
843 - (out_line, last_colour, last_nodepos) = self.draw_graph(commit,
844 - index, out_line,
845 - last_colour,
846 - last_nodepos)
847 - self.index[commit.commit_sha1] = index
848 - index += 1
844 + self.commits.append(commit)
845
846 # Skip the '\0
847 commit_lines = []
@@ -854,6 +850,14 @@ class GitView:
850
851 fp.close()
852
853 + for commit in self.commits:
854 + (out_line, last_colour, last_nodepos) = self.draw_graph(commit,
855 + index, out_line,
856 + last_colour,
857 + last_nodepos)
858 + self.index[commit.commit_sha1] = index
859 + index += 1
860 +
861 self.treeview.set_model(self.model)
862 self.treeview.show()
863
@@ -869,13 +873,6 @@ class GitView:
873 last_nodepos = 0
874
875 # Add the incomplete lines of the last cell in this
872 - for sha1 in self.incomplete_line.keys():
873 - if ( sha1 != commit.commit_sha1):
874 - for pos in self.incomplete_line[sha1]:
875 - in_line.append((pos, pos, self.colours[sha1]))
876 - else:
877 - del self.incomplete_line[sha1]
878 -
876 try:
877 colour = self.colours[commit.commit_sha1]
878 except KeyError:
@@ -897,6 +894,14 @@ class GitView:
894 self.colours[commit.parent_sha1[0]] = colour
895 self.nodepos[commit.parent_sha1[0]] = node_pos
896
897 + for sha1 in self.incomplete_line.keys():
898 + if ( sha1 != commit.commit_sha1):
899 + self.draw_incomplete_line(sha1, node_pos,
900 + out_line, in_line, index)
901 + else:
902 + del self.incomplete_line[sha1]
903 +
904 +
905 in_line.append((node_pos, self.nodepos[commit.parent_sha1[0]],
906 self.colours[commit.parent_sha1[0]]))
907
@@ -936,6 +941,23 @@ class GitView:
941 except KeyError:
942 self.incomplete_line[sha1] = [self.nodepos[sha1]]
943
944 + def draw_incomplete_line(self, sha1, node_pos, out_line, in_line, index):
945 + for idx, pos in enumerate(self.incomplete_line[sha1]):
946 + if(pos == node_pos):
947 + out_line.append((pos,
948 + pos+0.5, self.colours[sha1]))
949 + self.incomplete_line[sha1][idx] = pos = pos+0.5
950 + try:
951 + next_commit = self.commits[index+1]
952 + if (next_commit.commit_sha1 == sha1 and pos != int(pos)):
953 + # join the line back to the node point
954 + # This need to be done only if we modified it
955 + in_line.append((pos, pos-0.5, self.colours[sha1]))
956 + continue;
957 + except IndexError:
958 + pass
959 + in_line.append((pos, pos, self.colours[sha1]))
960 +
961
962 def _go_clicked_cb(self, widget, revid):
963 """Callback for when the go button for a parent is clicked."""