Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

logview: renew cache mechanism for columns

Now treemodel has literally 'on-demand cache' mechanism.
Data of cached columns are stored and calcurated individually per column.

Changeset c02191832be8

Parent 2deace3b5d61

by Yuki KODAMA

Changes to one file · Browse files at c02191832be8 Showing diff from parent 2deace3b5d61 Diff from another changeset...

 
132
133
134
 
 
 
 
 
 
 
135
136
137
138
139
140
141
142
 
149
150
151
 
 
152
153
154
155
156
 
 
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
159
160
 
172
173
174
 
175
176
177
178
179
180
181
 
193
194
195
196
197
198
199
200
201
202
 
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
 
 
 
236
237
238
239
240
241
242
243
244
245
 
246
247
248
 
132
133
134
135
136
137
138
139
140
141
142
 
 
 
 
143
144
145
 
152
153
154
155
156
157
 
 
 
 
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
 
206
207
208
209
210
 
211
 
212
213
214
 
226
227
228
 
 
 
 
229
230
231
 
250
251
252
 
 
 
 
 
 
 
 
 
 
 
 
253
254
255
256
 
 
 
 
 
 
 
 
 
257
258
259
260
@@ -132,11 +132,14 @@
  return []   if column == WFILE: return path or ''   + try: + ctx = self.repo[revid] + except IndexError: + return None + + # non-cached columns +   if column in (HEXID, REVHEX, BRANCH, LOCALTIME, UTC): - try: - ctx = self.repo[revid] - except IndexError: - return None   if column == HEXID:   return str(ctx)   if column == REVHEX: @@ -149,12 +152,43 @@
  if column == UTC:   return hglib.utctime(ctx.date())   + # cached columns +   if revid not in self.revisions: - try: - ctx = self.repo[revid] - except IndexError: - return None + self.revisions[revid] = {} + cache = self.revisions[revid]   + if cache.has_key(column): + return cache[column] + + if column in (COMMITER, FGCOLOR): + cache[COMMITER] = hglib.toutf(hglib.username(ctx.user())) + + if column == TAGS: + tags = self.repo.nodetags(ctx.node()) + cache[TAGS] = hglib.toutf(', '.join(tags)) + + elif column == AGE: + cache[AGE] = hglib.age(ctx.date()) + + elif column == FGCOLOR: + cache[FGCOLOR] = self.color_func(revid, cache[COMMITER]) + + elif column == CHANGES: + parent = self.parents.get(revid, None) + if parent is None: + parent = ctx.parents()[0].node() + M, A, R = self.repo.status(parent, ctx.node())[:3] + common = dict(color='black') + M = M and gtklib.markup(' %s ' % len(M), + background=gtklib.PORANGE, **common) or '' + A = A and gtklib.markup(' %s ' % len(A), + background=gtklib.PGREEN, **common) or '' + R = R and gtklib.markup(' %s ' % len(R), + background=gtklib.PRED, **common) or '' + cache[CHANGES] = ''.join((M, A, R)) + + elif column in (MESSAGE, GRAPHNODE):   # convert to Unicode for valid string operations   summary = hglib.tounicode(ctx.description()).replace(u'\0', '')   if self.longsummary: @@ -172,10 +206,9 @@
  summary = lines and lines[0] or ''   escape = gtklib.markup_escape_text   summary = escape(hglib.toutf(summary)) +   node = ctx.node() -   tags = self.repo.nodetags(node) - taglist = hglib.toutf(', '.join(tags))   tstr = ''   for tag in tags:   if tag not in self.hidetags: @@ -193,10 +226,6 @@
  bstr += gtklib.markup(' %s ' % branch, color='black',   background=gtklib.PGREEN) + ' '   - author = hglib.toutf(hglib.username(ctx.user())) - age = hglib.age(ctx.date()) - - color = self.color_func(revid, author)   if revid in self.wcparents:   sumstr = bstr + tstr + '<b><u>' + summary + '</u></b>'   status = 4 @@ -221,28 +250,11 @@
  # new   status += 2   - parent = self.parents.get(revid, None) - if parent is None: - parent = ctx.parents()[0].node() - M, A, R = self.repo.status(parent, ctx.node())[:3] - common = dict(color='black') - M = M and gtklib.markup(' %s ' % len(M), - background=gtklib.PORANGE, **common) or '' - A = A and gtklib.markup(' %s ' % len(A), - background=gtklib.PGREEN, **common) or '' - R = R and gtklib.markup(' %s ' % len(R), - background=gtklib.PRED, **common) or '' - changes = ''.join((M, A, R)) + cache[MESSAGE] = sumstr + gcolumn, gcolor = graphnode + cache[GRAPHNODE] = (gcolumn, gcolor, status)   - revision = (sumstr, author, taglist, color, age, changes, status) - self.revisions[revid] = revision - else: - revision = self.revisions[revid] - if column == GRAPHNODE: - column, color = graphnode - return (column, color, revision[-1]) - else: - return revision[column-MESSAGE] + return cache[column]     def on_iter_next(self, rowref):   if rowref < len(self.graphdata) - 1: