Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

revdisplay: remove unused class RevDisplay

Changeset 611649d618db

Parent 70138eee273e

by Adrian Buehlmann

Changes to one file · Browse files at 611649d618db Showing diff from parent 70138eee273e Diff from another changeset...

 
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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
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
257
258
259
260
261
262
 
16
17
18
 
 
19
20
21
22
23
 
24
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
29
30
@@ -16,247 +16,15 @@
   import re   -from mercurial.node import short as short_hex -  from PyQt4 import QtCore, QtGui  Qt = QtCore.Qt  connect = QtCore.QObject.connect  SIGNAL = QtCore.SIGNAL   -from tortoisehg.util.util import format_desc, xml_escape, tounicode +from tortoisehg.util.util import xml_escape, tounicode  from tortoisehg.util import hglib    from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt.config import HgConfig - -headerstyle = ''' -<style type="text/css"> -.rev_number { font-family:Courier; } -.rev_hash { font-family:Courier; } -.label { color:gray; } -</style> -''' - -linkfmt = '<span class="rev_number">%s</span>:' \ - '<span class="rev_hash"><a href="%s">%s</a>&nbsp;</span>' - -labelfmt = '<td width=%i align="right"><span class="label">%s&nbsp;&nbsp;</span></td>' - -csetfmt = '<tr>' + labelfmt + '<td>%s<span class="short_desc">%s</span></td></tr>\n' - -labelwidth = 50 -descwidth = 80 # number of chars displayed for parent/child descriptions - -def cset(ctx, labelname): - short = short_hex(ctx.node()) - desc = format_desc(ctx.description(), descwidth) - rev = ctx.rev() - rev = linkfmt % (rev, rev, short) - return csetfmt % (labelwidth, labelname, rev, desc) - - -class RevDisplay(QtGui.QWidget): - """ - Display metadata for one revision (rev, author, description, etc.) - """ - - commitsignal = QtCore.pyqtSignal(QtCore.QString) - - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self._message = None - self.ctx = None - - hb = QtGui.QHBoxLayout() - hb.setMargin(0) - self.setLayout(hb) - - self._header = w = QtGui.QLabel() - w.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.LinksAccessibleByMouse) - hb.addWidget(w) - hb.addStretch(0) - - vb = QtGui.QVBoxLayout() - hb.addLayout(vb) - - hb2 = QtGui.QHBoxLayout() - hb2.addStretch(0) - vb.addLayout(hb2) - - # expand header button - self._expander = w = QtGui.QToolButton() - w.setArrowType(Qt.UpArrow) - w.setIconSize(QtCore.QSize(10, 10)) - a = QtGui.QAction(self) - connect(a, SIGNAL("triggered()"), self.expand) - w.setDefaultAction(a) - hb2.addWidget(w, 0, Qt.AlignTop) - self._expanded = True - - hb3 = QtGui.QHBoxLayout() - hb3.addStretch(0) - vb.addLayout(hb3) - self._commitbutton = w = QtGui.QPushButton() - hb3.addWidget(w, 0, Qt.AlignBottom) - connect(w, SIGNAL('clicked()'), self.commit) - - connect(self._header, - SIGNAL('linkActivated(const QString&)'), - self.anchorClicked) - - def commit(self): - if self.mqpatch: - action = 'qrefresh' - else: - action = 'commit' - self.commitsignal.emit(action) - - def expand(self): - self.setExpanded(not self._expanded) - - def setExpanded(self, state): - state = bool(state) - if (state == self._expanded): - return - self._expanded = state - if self._expanded: - t = Qt.UpArrow - else: - t = Qt.DownArrow - self._expander.setArrowType(t) - self.refreshDisplay() - - def expanded(self): - return self._expanded - - def sizeHint(self): - return self.minimumSizeHint() - - def minimumSizeHint(self): - return self._header.minimumSizeHint() - - def setMessageWidget(self, w): - self._message = w - - def anchorClicked(self, qurl): - """ - Callback called when a link is clicked in the text browser - """ - rev = str(qurl) - if rev.startswith('diff_'): - self.diffrev = int(rev[5:]) - self.refreshDisplay() - # TODO: emit a signal to recompute the diff - self.emit(SIGNAL('parentRevisionSelected'), self.diffrev) - else: - self.emit(SIGNAL('revisionSelected'), int(rev)) - - def setDiffRevision(self, rev): - if rev != self.diffrev: - self.diffrev = rev - self.refreshDisplay() - - def displayRevision(self, ctx): - self.ctx = ctx - self.diffrev = ctx.parents()[0].rev() - if hasattr(self.ctx._repo, "mq"): - self.mqseries = self.ctx._repo.mq.series[:] - self.mqunapplied = [x[1] for x in self.ctx._repo.mq.unapplied(self.ctx._repo)] - mqpatch = set(self.ctx.tags()).intersection(self.mqseries) - if mqpatch: - self.mqpatch = mqpatch.pop() - else: - self.mqpatch = None - else: - self.mqseries = [] - self.mqunapplied = [] - self.mqpatch = None - - self.refreshDisplay() - - def selectNone(self): - self._message.selectNone() - - def searchString(self, text): - self._message.searchString(text) - - def refreshDisplay(self): - if self.ctx == None: - return - - ctx = self.ctx - rev = ctx.rev() - - enableci = self._expanded and not rev - if enableci: - if self.mqpatch: - self._commitbutton.setText(_('QRefresh')) - else: - self._commitbutton.setText(_('Commit')) - self._commitbutton.setVisible(enableci) - - buf = headerstyle - if self.mqpatch: - buf += "<table width=100%>\n" - buf += '<tr bgcolor=%s>' % HgConfig(ctx._repo.ui).getMQFGColor() - buf += '<td colspan=3 width=100%><b>Patch queue:</b>&nbsp;' - for p in self.mqseries: - if p in self.mqunapplied: - p = "<i>%s</i>" % p - elif p == self.mqpatch: - p = "<b>%s</b>" % p - buf += '&nbsp;%s&nbsp;' % (p) - buf += '</td></tr>\n' - buf += "</table>\n" - - buf += '<table width=100%>\n<tr>' - if rev is None: - buf += '<td><b>%s</b></td>' % 'Working Directory' - else: - desc = format_desc(ctx.description(), 80) - buf += '<td><span class="rev_number">%d:</span>' \ - '<span class="rev_hash">%s&nbsp;</span>' \ - '<span class="short_desc"><b>%s</b></span></td>' \ - '\n' % (ctx.rev(), short_hex(ctx.node()), desc) - - buf += (labelfmt + '<td>%s</td>\n') % (labelwidth, 'Branch', ctx.branch()) - buf += '</tr></table>\n' - - if self._expanded: - buf += self.expandedText() - - self._header.setText(buf) - - self._message.displayRevision(ctx, self.mqpatch) - - def expandedText(self): - ctx = self.ctx - buf = '<table width=100%>\n' - - user = xml_escape(tounicode(ctx.user())) - buf += ('<tr>' + labelfmt + '<td>%s</td></tr>\n') % ( - labelwidth, 'Author', user) - - date = ctx.date() - disptime = hglib.displaytime(date) - age = hglib.age(date) - buf += ('<tr>' + labelfmt + '<td>%s (%s)</td></tr>\n') % ( - labelwidth, 'Date', disptime, age) - - parents = [p for p in ctx.parents() if p] - for p in parents: - if p.rev() > -1: - buf += cset(p, 'Parent') - if len(parents) == 2: - a = parents[0].ancestor(parents[1]) - buf += cset(a, 'Ancestor') - - for c in ctx.children(): - if c.rev() > -1: - buf += cset(c, 'Child') - - buf += "</table>\n" - return buf      # initialize changeset and url link regex