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: support coloring by branch name

Changeset 1166cd930754

Parent ce236095a786

by Henrik Stuart

Changes to 3 files · Browse files at 1166cd930754 Showing diff from parent ce236095a786 Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​history.py Stacked
 
194
195
196
 
 
 
 
 
 
197
198
199
 
291
292
293
 
294
295
296
 
321
322
323
 
324
325
326
 
332
333
334
 
 
 
 
 
335
336
337
 
194
195
196
197
198
199
200
201
202
203
204
205
 
297
298
299
300
301
302
303
 
328
329
330
331
332
333
334
 
340
341
342
343
344
345
346
347
348
349
350
@@ -194,6 +194,12 @@
  button.set_active(self.showcol.get('branch', False))   button.set_draw_as_radio(True)   menu.append(button) + button = gtk.CheckMenuItem(_('Color by Branch')) + button.connect('toggled', self._branch_color, + 'branch-color') + button.set_active(self.branch_color) + button.set_draw_as_radio(True) + menu.append(button)   menu.show_all()   return menu   @@ -291,6 +297,7 @@
  settings = gdialog.GDialog.save_settings(self)   settings['glog-vpane'] = self.vpaned.get_position()   settings['glog-hpane'] = self.hpaned.get_position() + settings['branch-color'] = self.graphview.get_property('branch-color')   for col in ('rev', 'date', 'id', 'branch', 'utc'):   vis = self.graphview.get_property(col+'-column-visible')   settings['glog-vis-'+col] = vis @@ -321,6 +328,7 @@
  try:   self.setting_vpos = settings['glog-vpane']   self.setting_hpos = settings['glog-hpane'] + self.branch_color = settings.get('branch-color', False)   for col in ('rev', 'date', 'id', 'branch', 'utc'):   vis = settings['glog-vis-'+col]   self.showcol[col] = vis @@ -332,6 +340,11 @@
  if self.graphview.model:   self.graphview.model.refresh()   + def _branch_color(self, button, property): + active = button.get_active() + self.graphview.set_property(property, active) + self.reload_log() +   def reload_log(self, **filteropts):   'Send refresh event to treeview object'   os.chdir(self.repo.root) # for paths relative to repo root
 
9
10
11
12
 
13
14
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
 
33
34
35
36
 
37
38
39
 
47
48
49
50
 
51
52
53
54
55
56
 
 
 
 
57
58
59
60
61
62
63
64
65
 
66
67
68
69
70
71
72
73
 
74
75
76
 
83
84
85
86
 
87
88
89
 
9
10
11
 
12
13
14
15
16
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
45
46
47
 
48
49
50
51
 
59
60
61
 
62
63
64
65
66
67
 
68
69
70
71
72
 
73
74
75
76
77
78
 
79
80
81
82
83
 
 
 
 
84
85
86
87
 
94
95
96
 
97
98
99
100
@@ -9,12 +9,24 @@
 __author__ = "Joel Rosdahl <joel@rosdahl.net>, Steve Borho <steve@borho.org>"    from mercurial.node import nullrev -from mercurial import cmdutil, util, ui +from mercurial import cmdutil, util    def __get_parents(repo, rev):   return [x for x in repo.changelog.parentrevs(rev) if x != nullrev]   -def revision_grapher(repo, start_rev, stop_rev, branch=None, noheads=False): +def _color_of(repo, rev, nextcolor, preferredcolor, branch_color=False): + if not branch_color: + if preferredcolor[0]: + rv = preferredcolor[0] + preferredcolor[0] = None + else: + rv = nextcolor[0] + nextcolor[0] = nextcolor[0] + 1 + return rv + else: + return sum([ord(c) for c in repo[rev].branch()]) + +def revision_grapher(repo, start_rev, stop_rev, branch=None, noheads=False, branch_color=False):   """incremental revision grapher     This generator function walks through the revision history from @@ -33,7 +45,7 @@
  curr_rev = start_rev   revs = []   rev_color = {} - nextcolor = 0 + nextcolor = [0]   while curr_rev >= stop_rev:   # Compute revs and next_revs.   if curr_rev not in revs: @@ -47,30 +59,29 @@
  continue   # New head.   revs.append(curr_rev) - rev_color[curr_rev] = curcolor = nextcolor ; nextcolor += 1 + rev_color[curr_rev] = _color_of(repo, curr_rev, nextcolor, [None], branch_color)   r = __get_parents(repo, curr_rev)   while r:   r0 = r[0]   if r0 < stop_rev: break   if r0 in rev_color: break - rev_color[r0] = curcolor + if not branch_color: + rev_color[r0] = rev_color[curr_rev] + else: + rev_color[r0] = _color_of(repo, r0, None, None, True)   r = __get_parents(repo, r0) - curcolor = rev_color[curr_rev]   rev_index = revs.index(curr_rev)   next_revs = revs[:]     # Add parents to next_revs.   parents = __get_parents(repo, curr_rev)   parents_to_add = [] - preferred_color = curcolor + preferred_color = [rev_color[curr_rev]]   for parent in parents:   if parent not in next_revs:   parents_to_add.append(parent)   if parent not in rev_color: - if preferred_color: - rev_color[parent] = preferred_color; preferred_color = None - else: - rev_color[parent] = nextcolor ; nextcolor += 1 + rev_color[parent] = _color_of(repo, parent, nextcolor, preferred_color, branch_color)   next_revs[rev_index:rev_index + 1] = parents_to_add     lines = [] @@ -83,7 +94,7 @@
  color = rev_color[parent]   lines.append( (i, next_revs.index(parent), color) )   - yield (curr_rev, (rev_index, curcolor), lines, parents) + yield (curr_rev, (rev_index, rev_color[curr_rev]), lines, parents)   revs = next_revs   curr_rev -= 1  
 
84
85
86
 
 
 
 
 
87
88
89
 
111
112
113
 
114
115
116
 
160
161
162
163
 
164
165
166
 
240
241
242
 
 
243
244
245
 
262
263
264
 
 
265
266
267
 
84
85
86
87
88
89
90
91
92
93
94
 
116
117
118
119
120
121
122
 
166
167
168
 
169
170
171
172
 
246
247
248
249
250
251
252
253
 
270
271
272
273
274
275
276
277
@@ -84,6 +84,11 @@
  'Show branch',   False,   gobject.PARAM_READWRITE), + 'branch-color': (gobject.TYPE_BOOLEAN, + 'Branch color', + 'Color by branch', + False, + gobject.PARAM_READWRITE)   }     __gsignals__ = { @@ -111,6 +116,7 @@
  self.construct_treeview()   self.pbar = pbar   self.origtip = None + self.branch_color = False     def set_repo(self, repo, pbar=None):   self.repo = repo @@ -160,7 +166,7 @@
  start = len(self.repo.changelog) - 1   noheads = opts.get('noheads', False)   self.grapher = revision_grapher(self.repo, start, end, pats, - noheads) + noheads, self.branch_color)   elif opts.get('revs', None):   self.grapher = dumb_log_generator(self.repo, opts['revs'])   else: @@ -240,6 +246,8 @@
  return self.rev_column.get_visible()   elif property.name == 'branch-column-visible':   return self.branch_column.get_visible() + elif property.name == 'branch-color': + return self.branch_color   elif property.name == 'utc-column-visible':   return self.utc_column.get_visible()   elif property.name == 'repo': @@ -262,6 +270,8 @@
  self.rev_column.set_visible(value)   elif property.name == 'branch-column-visible':   self.branch_column.set_visible(value) + elif property.name == 'branch-color': + self.branch_color = value   elif property.name == 'utc-column-visible':   self.utc_column.set_visible(value)   elif property.name == 'repo':