Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc2, 0.4rc3, and 0.4rc4

hggtk/history: fix UTF-8 encoding error in tags column

Changeset b2dcc5a0ccf0

Parent 8a56ab916e0a

by TK Soh

Changes to one file · Browse files at b2dcc5a0ccf0 Showing diff from parent 8a56ab916e0a Diff from another changeset...

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
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
 ''' 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    # 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    # FIXME:  # this function is a copy of hglib.touft(), but I've  # trouble importing hglib (resides one dir level above )  # into this module.  #  # Note: Python 2.5's new import syntax causes problem  # when importing this module from command line.  def toutf(s):   """   Convert a string to UTF-8 encoding   """   for e in ('utf-8', util._encoding):   try:   return s.decode(e, 'strict').encode('utf-8')   except UnicodeDecodeError:   pass   return s.decode(util._fallbackencoding, 'replace').encode('utf-8')    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.workingctx().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     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 = ', '.join(self.repo.nodetags(node)) + tags = toutf(', '.join(self.repo.nodetags(node)))     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, tags,   None, color)   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