12
14
from xml.sax.saxutils import escape
14
from bzrlib.config import parse_username
15
from bzrlib.revision import NULL_REVISION
16
from time import (strftime, localtime)
37
32
class TreeModel(gtk.GenericTreeModel):
39
35
def __init__ (self, branch, line_graph_data):
40
36
gtk.GenericTreeModel.__init__(self)
41
37
self.revisions = {}
43
39
self.repository = branch.repository
44
40
self.line_graph_data = line_graph_data
46
if self.branch.supports_tags():
42
if self.branch.supports_tags():
47
43
self.tags = self.branch.tags.get_reverse_tag_dict()
58
54
def on_get_flags(self):
59
55
return gtk.TREE_MODEL_LIST_ONLY
61
57
def on_get_n_columns(self):
64
60
def on_get_column_type(self, index):
65
61
if index == REVID: return gobject.TYPE_STRING
66
62
if index == NODE: return gobject.TYPE_PYOBJECT
75
71
if index == PARENTS: return gobject.TYPE_PYOBJECT
76
72
if index == CHILDREN: return gobject.TYPE_PYOBJECT
77
73
if index == TAGS: return gobject.TYPE_PYOBJECT
78
if index == AUTHORS: return gobject.TYPE_STRING
80
75
def on_get_iter(self, path):
83
78
def on_get_path(self, rowref):
86
81
def on_get_value(self, rowref, column):
87
82
if len(self.line_graph_data) > 0:
88
83
(revid, node, lines, parents,
106
101
if column == TAGS: return self.tags.get(revid, [])
108
if not revid or revid == NULL_REVISION:
110
105
if revid not in self.revisions:
111
106
revision = self.repository.get_revisions([revid])[0]
112
107
self.revisions[revid] = revision
114
109
revision = self.revisions[revid]
116
111
if column == REVISION: return revision
117
112
if column == SUMMARY: return escape(revision.get_summary())
118
113
if column == MESSAGE: return escape(revision.message)
119
if column == COMMITTER: return parse_username(revision.committer)[0]
120
if column == TIMESTAMP:
114
if column == COMMITTER: return re.sub('<.*@.*>', '',
115
revision.committer).strip(' ')
116
if column == TIMESTAMP:
121
117
return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp))
122
if column == AUTHORS:
124
parse_username(author)[0] for author in revision.get_apparent_authors()])
126
119
def on_iter_next(self, rowref):
127
120
if rowref < len(self.line_graph_data) - 1:
131
124
def on_iter_children(self, parent):
132
125
if parent is None: return 0
135
128
def on_iter_has_child(self, rowref):
138
131
def on_iter_n_children(self, rowref):
139
132
if rowref is None: return len(self.line_graph_data)
142
135
def on_iter_nth_child(self, parent, n):
143
136
if parent is None: return n
146
139
def on_iter_parent(self, child):