Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

logview: move row color logic to treemodel

Changeset ed1241d1c22d

Parent 497016c1efd6

by Steve Borho

Changes to 2 files · Browse files at ed1241d1c22d Showing diff from parent 497016c1efd6 Diff from another changeset...

 
40
41
42
43
 
44
45
46
47
48
49
50
51
52
53
54
 
55
56
57
 
168
169
170
171
 
172
173
174
 
220
221
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41
42
 
43
44
45
46
47
48
 
49
50
51
52
53
54
55
56
57
 
168
169
170
 
171
172
173
174
 
220
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
249
250
251
252
253
254
255
256
@@ -40,18 +40,18 @@
   class TreeModel(gtk.GenericTreeModel):   - def __init__ (self, repo, graphdata, color_func, outgoing, origtip, npreviews): + def __init__ (self, repo, graphdata, outgoing, origtip, npreviews):   gtk.GenericTreeModel.__init__(self)   self.repo = repo   self.outgoing = outgoing   self.revisions = {}   self.graphdata = graphdata - self.color_func = color_func   self.wcparents = [x.rev() for x in repo.parents()]   self.tagrevs = [repo[r].rev() for t, r in repo.tagslist()]   self.branchtags = repo.branchtags()   self.origtip = origtip   self.npreviews = npreviews + self.set_author_color()   self.hidetags = self.repo.ui.config(   'tortoisehg', 'hidetags', '').split()   @@ -168,7 +168,7 @@
  author = hglib.toutf(hglib.username(ctx.user()))   age = templatefilters.age(ctx.date())   - color = self.color_func(ctx.parents(), revid, author) + color = self.color_func(revid, author)   if revid in self.wcparents:   sumstr = bstr + tstr + '<b><u>' + summary + '</u></b>'   else: @@ -220,3 +220,37 @@
    def on_iter_parent(self, child):   return None + + def set_author_color(self): + # If user has configured authorcolor in [tortoisehg], color + # rows by author matches + self.author_pats = [] + self.color_func = self.text_color_default + + if self.repo is not None: + for k, v in self.repo.ui.configitems('tortoisehg'): + if not k.startswith('authorcolor.'): continue + pat = k[12:] + self.author_pats.append((re.compile(pat, re.I), v)) + if self.author_pats or self.repo.ui.configbool('tortoisehg', + 'authorcolor'): + self.color_func = self.text_color_author + + def text_color_default(self, rev, author): + return int(rev) >= self.origtip and 'darkgreen' or 'black' + + colors = '''black blue deeppink mediumorchid blue burlywood4 goldenrod + slateblue red2 navy dimgrey'''.split() + color_cache = {} + + def text_color_author(self, rev, author): + if int(rev) >= self.origtip: + return 'darkgreen' + for re, v in self.author_pats: + if (re.search(author)): + return v + if author not in self.color_cache: + color = self.colors[len(self.color_cache.keys()) % len(self.colors)] + self.color_cache[author] = color + return self.color_cache[author] +
 
137
138
139
140
141
142
143
 
249
250
251
252
253
 
254
255
256
 
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
 
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
 
137
138
139
 
140
141
142
 
248
249
250
 
 
251
252
253
254
 
369
370
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
373
374
375
376
377
 
378
379
380
 
525
526
527
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
529
530
@@ -137,7 +137,6 @@
  def set_repo(self, repo, pbar=None):   self.repo = repo   self.pbar = pbar - self.set_author_color()     def search_in_tree(self, model, column, key, iter, data):   """Searches all fields shown in the tree when the user hits crtr+f, @@ -249,8 +248,7 @@
    if not self.model:   model = treemodel.TreeModel(self.repo, self.graphdata, - self.color_func, self.outgoing, self.origtip, - self.npreviews) + self.outgoing, self.origtip, self.npreviews)   self.treeview.set_model(model)   self.model = model   @@ -371,28 +369,12 @@
  self.treeview.set_model(None)   self.pbar.set_status_text(_('Repository is empty'))   - def set_author_color(self): - # If user has configured authorcolor in [tortoisehg], color - # rows by author matches - self.author_pats = [] - self.color_func = self.text_color_default - - if self.repo is not None: - for k, v in self.repo.ui.configitems('tortoisehg'): - if not k.startswith('authorcolor.'): continue - pat = k[12:] - self.author_pats.append((re.compile(pat, re.I), v)) - if self.author_pats or self.repo.ui.configbool('tortoisehg', - 'authorcolor'): - self.color_func = self.text_color_author -   def construct_treeview(self):   self.treeview = gtk.TreeView()   self.treeview.set_rules_hint(True)   self.treeview.set_reorderable(False)   self.treeview.set_enable_search(True)   self.treeview.set_search_equal_func(self.search_in_tree, None) - self.set_author_color()     self.treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)   self.treeview.connect("cursor-changed", self._on_selection_changed) @@ -543,39 +525,6 @@
  def get_columns(self):   return self.columns   - def text_color_orig(self, parents, rev, author): - if int(rev) >= self.origtip: - return 'darkgreen' - if len(parents) == 2: - # mark merge changesets blue - return 'blue' - elif len(parents) == 1: - # detect non-trivial parent - if long(rev) != parents[0].rev()+1: - return '#900000' - else: - return 'black' - else: - return 'black' - - def text_color_default(self, parents, rev, author): - return int(rev) >= self.origtip and 'darkgreen' or 'black' - - colors = '''black blue deeppink mediumorchid blue burlywood4 goldenrod - slateblue red2 navy dimgrey'''.split() - color_cache = {} - - def text_color_author(self, parents, rev, author): - if int(rev) >= self.origtip: - return 'darkgreen' - for re, v in self.author_pats: - if (re.search(author)): - return v - if author not in self.color_cache: - color = self.colors[len(self.color_cache.keys()) % len(self.colors)] - self.color_cache[author] = color - return self.color_cache[author] -   def _on_selection_changed(self, treeview):   """callback for when the treeview changes."""   (path, focus) = treeview.get_cursor()