Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.6, 0.7, and 0.7.1

history: convert tag column to display changeset id

Changeset 25e2fe12f5e3

Parent 026284bad055

by TK Soh

Changes to 3 files · Browse files at 25e2fe12f5e3 Showing diff from parent 026284bad055 Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​history.py Stacked
 
129
130
131
132
 
133
134
135
136
137
138
 
139
140
141
 
 
142
143
144
 
129
130
131
 
132
133
134
135
136
137
 
138
139
 
 
140
141
142
143
144
@@ -129,16 +129,16 @@
  def _view_menu(self):   menu = gtk.Menu()   - button = gtk.CheckMenuItem("Show Ids") + button = gtk.CheckMenuItem("Show Rev")   button.connect("toggled", self.toggle_view_column,   'rev-column-visible')   button.set_active(True)   button.set_draw_as_radio(True)   menu.append(button) - button = gtk.CheckMenuItem("Show Tags") + button = gtk.CheckMenuItem("Show ID")   button.connect("toggled", self.toggle_view_column, - 'tags-column-visible') - button.set_active(True) + 'id-column-visible') + button.set_active(False)   button.set_draw_as_radio(True)   menu.append(button)   button = gtk.CheckMenuItem("Show Date")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
44
45
46
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
77
 
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
 ''' Mercurial revision DAG visualization library     Implements a gtk.TreeModel which visualizes a Mercurial repository   revision history.    Portions of this code stolen mercilessly from bzr-gtk visualization  dialog. Other portions stolen from graphlog extension.  '''    import gtk  import gobject  import re  from time import (strftime, gmtime)  from mercurial import util +from mercurial.node import short    # FIXME: dirty hack to import toutf() from hggtk.hglib.  #  # Python 2.5's relative imports doesn't seem to work either,  # when running history.py directly.  #  # Besides, we want to be compatible older Python versions.  try:   # when history.py is invoked directly   from hglib import toutf  except ImportError:   # when history.py is imported and called from hgproc.py   from hggtk.hglib import toutf    # treemodel row enumerated attributes  LINES = 0  NODE = 1  REVID = 2  LAST_LINES = 3  MESSAGE = 4  COMMITER = 5  TIMESTAMP = 6  REVISION = 7  PARENTS = 8  WCPARENT = 9  HEAD = 10  TAGS = 11  MARKED = 12  FGCOLOR = 13 +HEXID = 14    class TreeModel(gtk.GenericTreeModel):     def __init__ (self, repo, graphdata, color_func):   gtk.GenericTreeModel.__init__(self)   self.revisions = {}   self.repo = repo   self.parents = [x.rev() for x in repo.changectx(None).parents()]   self.heads = [repo.changelog.rev(x) for x in repo.heads()]   self.line_graph_data = graphdata   self.author_re = re.compile('<.*@.*>', 0)   self.color_func = color_func     def on_get_flags(self):   return gtk.TREE_MODEL_LIST_ONLY     def on_get_n_columns(self):   return 14     def on_get_column_type(self, index):   if index == NODE: return gobject.TYPE_PYOBJECT   if index == LINES: return gobject.TYPE_PYOBJECT   if index == REVID: return gobject.TYPE_STRING   if index == LAST_LINES: return gobject.TYPE_PYOBJECT   if index == MESSAGE: return gobject.TYPE_STRING   if index == COMMITER: return gobject.TYPE_STRING   if index == TIMESTAMP: return gobject.TYPE_STRING   if index == REVISION: return gobject.TYPE_PYOBJECT   if index == PARENTS: return gobject.TYPE_PYOBJECT   if index == WCPARENT: return gobject.TYPE_BOOLEAN   if index == HEAD: return gobject.TYPE_BOOLEAN   if index == TAGS: return gobject.TYPE_STRING   if index == MARKED: return gobject.TYPE_BOOLEAN   if index == FGCOLOR: return gobject.TYPE_STRING + if index == HEXID: return gobject.TYPE_STRING     def on_get_iter(self, path):   return path[0]     def on_get_path(self, rowref):   return rowref     def on_get_value(self, rowref, column):   (revid, node, lines, parents) = self.line_graph_data[rowref]     if column == REVID: return revid   if column == NODE: return node   if column == LINES: return lines   if column == PARENTS: return parents   if column == LAST_LINES:   if rowref>0:   return self.line_graph_data[rowref-1][2]   return []     if revid not in self.revisions:   ctx = self.repo.changectx(revid)     summary = ctx.description().replace('\0', '')   summary = summary.split('\n')[0]   summary = gobject.markup_escape_text(toutf(summary))   node = self.repo.lookup(revid)   tags = self.repo.nodetags(node)   taglist = toutf(', '.join(tags))   for tag in tags:   summary = '<span background="#ffffaa"> %s </span> %s' % (   tag, summary)     if '<' in ctx.user():   author = toutf(self.author_re.sub('', ctx.user()).strip(' '))   else:   author = toutf(util.shortuser(ctx.user()))     date = strftime("%Y-%m-%d %H:%M:%S", gmtime(ctx.date()[0]))     wc_parent = revid in self.parents   head = revid in self.heads   color = self.color_func(parents, revid, author)     revision = (None, node, revid, None, summary,   author, date, None, parents, wc_parent, head, taglist, - None, color) + None, color, short(node))   self.revisions[revid] = revision   else:   revision = self.revisions[revid]     if column == REVISION:   return revision   if column == MARKED:   return revid == self.marked_rev   return revision[column]     def on_iter_next(self, rowref):   if rowref < len(self.line_graph_data) - 1:   return rowref+1   return None     def on_iter_children(self, parent):   if parent is None: return 0   return None     def on_iter_has_child(self, rowref):   return False     def on_iter_n_children(self, rowref):   if rowref is None: return len(self.line_graph_data)   return 0     def on_iter_nth_child(self, parent, n):   if parent is None: return n   return None     def on_iter_parent(self, child):   return None
 
48
49
50
51
 
52
53
54
 
55
56
 
57
58
59
 
186
187
188
189
190
 
 
191
192
193
 
202
203
204
205
206
 
 
207
208
209
 
319
320
321
322
 
323
324
325
326
327
328
329
330
331
332
 
 
 
 
 
 
 
 
 
333
334
335
 
48
49
50
 
51
52
53
 
54
55
 
56
57
58
59
 
186
187
188
 
 
189
190
191
192
193
 
202
203
204
 
 
205
206
207
208
209
 
319
320
321
 
322
323
 
 
 
 
 
 
 
 
 
324
325
326
327
328
329
330
331
332
333
334
335
@@ -48,12 +48,12 @@
  gobject.PARAM_READWRITE),   'rev-column-visible': (gobject.TYPE_BOOLEAN,   'Rev', - 'Show revision id column', + 'Show revision number column',   False,   gobject.PARAM_READWRITE), - 'tags-column-visible': (gobject.TYPE_BOOLEAN, + 'id-column-visible': (gobject.TYPE_BOOLEAN,   'Tags', - 'Show tags column', + 'Show revision ID column',   False,   gobject.PARAM_READWRITE),   } @@ -186,8 +186,8 @@
  def do_get_property(self, property):   if property.name == 'date-column-visible':   return self.date_column.get_visible() - elif property.name == 'tags-column-visible': - return self.tag_column.get_visible() + elif property.name == 'id-column-visible': + return self.id_column.get_visible()   elif property.name == 'rev-column-visible':   return self.rev_column.get_visible()   elif property.name == 'repo': @@ -202,8 +202,8 @@
  def do_set_property(self, property, value):   if property.name == 'date-column-visible':   self.date_column.set_visible(value) - elif property.name == 'tags-column-visible': - self.tag_column.set_visible(value) + elif property.name == 'id-column-visible': + self.id_column.set_visible(value)   elif property.name == 'rev-column-visible':   self.rev_column.set_visible(value)   elif property.name == 'repo': @@ -319,17 +319,17 @@
  self.treeview.append_column(self.rev_column)     cell = gtk.CellRendererText() - cell.set_property("width-chars", 10) + cell.set_property("width-chars", 15)   cell.set_property("ellipsize", pango.ELLIPSIZE_END) - self.tag_column = gtk.TreeViewColumn("Tag") - self.tag_column.set_visible(False) - self.tag_column.set_resizable(True) - self.tag_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) - self.tag_column.set_fixed_width(cell.get_size(self.treeview)[2]) - self.tag_column.pack_start(cell, expand=True) - self.tag_column.add_attribute(cell, "text", treemodel.TAGS) - self.tag_column.add_attribute(cell, "foreground", treemodel.FGCOLOR) - self.treeview.append_column(self.tag_column) + self.id_column = gtk.TreeViewColumn("ID") + self.id_column.set_visible(False) + self.id_column.set_resizable(True) + self.id_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) + self.id_column.set_fixed_width(cell.get_size(self.treeview)[2]) + self.id_column.pack_start(cell, expand=True) + self.id_column.add_attribute(cell, "text", treemodel.HEXID) + self.id_column.add_attribute(cell, "foreground", treemodel.FGCOLOR) + self.treeview.append_column(self.id_column)     cell = gtk.CellRendererText()   mcell = gtk.CellRendererPixbuf()