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

repowidget: replace with csinfo

Changeset 44a951eef813

Parent 7ec08aebefb6

by Yuki KODAMA

Changes to 3 files · Browse files at 44a951eef813 Showing diff from parent 7ec08aebefb6 Diff from another changeset...

 
30
31
32
33
 
34
35
 
36
37
38
 
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
71
72
73
74
 
 
75
76
77
 
234
235
236
237
238
 
 
239
240
241
 
243
244
245
246
247
 
 
248
249
250
 
308
309
310
311
 
 
312
313
314
 
379
380
381
382
 
383
384
385
 
390
391
392
393
394
 
 
395
396
397
 
30
31
32
 
33
34
 
35
36
37
38
 
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
 
337
338
339
 
 
340
341
342
343
344
 
346
347
348
 
 
349
350
351
352
353
 
411
412
413
 
414
415
416
417
418
 
483
484
485
 
486
487
488
489
 
494
495
496
 
 
497
498
499
500
501
@@ -30,9 +30,9 @@
 from tortoisehg.hgqt.manifestdialog import ManifestDialog  from tortoisehg.hgqt.widgetmixin import WidgetMixin  from tortoisehg.hgqt.update import UpdateDialog -from tortoisehg.hgqt import cmdui +from tortoisehg.hgqt import cmdui, csinfo, qtlib   -from tortoisehg.util import paths +from tortoisehg.util import paths, hglib    from mercurial.error import RepoError   @@ -65,13 +65,116 @@
    self.createActions()   + def label_func(widget, item): + if item == 'cset': + return _('Changeset:') + elif item == 'parents': + return _('Parent:') + elif item == 'children': + return _('Child:') + elif item == 'patch': + return _('Patch:') + raise csinfo.UnknownItem(item) + def revid_markup(revid, **kargs): + opts = dict(family='monospace', size='9pt') + opts.update(kargs) + return qtlib.markup(revid, **opts) + def data_func(widget, item, ctx): + def summary_line(desc): + desc = desc.replace('\0', '').split('\n')[0] + return hglib.tounicode(desc[:80]) + def revline_data(ctx, hl=False, branch=None): + if isinstance(ctx, basestring): + return ctx + desc = ctx.description() + return (str(ctx.rev()), str(ctx), summary_line(desc), hl, branch) + if item == 'cset': + return revline_data(ctx) + elif item == 'branch': + value = hglib.tounicode(ctx.branch()) + return value != 'default' and value or None + elif item == 'parents': + # TODO: need to put 'diff to other' checkbox + #pindex = self.diff_other_parent() and 1 or 0 + pindex = 0 # always show diff with first parent + pctxs = ctx.parents() + parents = [] + for pctx in pctxs: + highlight = len(pctxs) == 2 and pctx == pctxs[pindex] + branch = None + if hasattr(pctx, 'branch') and pctx.branch() != ctx.branch(): + branch = pctx.branch() + parents.append(revline_data(pctx, highlight, branch)) + return parents + elif item == 'children': + children = [] + for cctx in ctx.children(): + branch = None + if hasattr(cctx, 'branch') and cctx.branch() != ctx.branch(): + branch = cctx.branch() + children.append(revline_data(cctx, branch=branch)) + return children + elif item in ('transplant', 'p4', 'svn'): + ts = widget.get_data(item, usepreset=True) + if not ts: + return None + try: + tctx = self.repo[ts] + return revline_data(tctx) + except (error.LookupError, error.RepoLookupError, error.RepoError): + return ts + elif item == 'patch': + if hasattr(ctx, '_patchname'): + desc = ctx.description() + return (ctx._patchname, str(ctx), summary_line(desc)) + return None + raise csinfo.UnknownItem(item) + def markup_func(widget, item, value): + def revline_markup(revnum, revid, summary, highlight=None, branch=None): + def branch_markup(branch): + opts = dict(fg='black', bg='#aaffaa') + return qtlib.markup(' %s ' % branch, **opts) + revnum = qtlib.markup(revnum) + summary = qtlib.markup(summary) + if revid: + revid = revid_markup(revid) + if branch: + branch = branch_markup(branch) + return '%s (%s) %s %s' % (revnum, revid, branch, summary) + return '%s (%s) %s' % (revnum, revid, summary) + else: + if branch: + branch = branch_markup(branch) + return '%s - %s %s' % (revnum, branch, summary) + return '%s - %s' % (revnum, summary) + if item in ('cset', 'transplant', 'patch', 'p4', 'svn'): + if isinstance(value, basestring): + return revid_markup(value) + return revline_markup(*value) + elif item in ('parents', 'children'): + csets = [] + for cset in value: + if isinstance(cset, basestring): + csets.append(revid_markup(cset)) + else: + csets.append(revline_markup(*cset)) + return csets + raise csinfo.UnknownItem(item) + + custom = csinfo.custom(data=data_func, label=label_func, + markup=markup_func) + style = csinfo.panelstyle(contents=('cset', 'branch', 'user', + 'dateage', 'parents', 'children', 'tags', + 'transplant', 'p4', 'svn'), selectable=True) + self.revpanel = csinfo.create(self.repo, style=style, custom=custom) + self.verticalLayout.insertWidget(0, self.revpanel) +   self.fileview.setFont(self._font)   connect(self.fileview, SIGNAL('showMessage'), self.showMessage)   connect(self.repoview, SIGNAL('showMessage'), self.showMessage)   - self.revdisplay.setMessageWidget(self.message) - - self.revdisplay.commitsignal.connect(self.commit) +# self.revdisplay.setMessageWidget(self.message) +# self.revdisplay.commitsignal.connect(self.commit)     connect(self.message, SIGNAL('revisionSelected'), self.repoview.goto)   @@ -234,8 +337,8 @@
  filetable = self.tableView_filelist   connect(filetable, SIGNAL('fileSelected'),   self.fileview.displayFile) - connect(self.fileview, SIGNAL('revForDiffChanged'), - self.revdisplay.setDiffRevision) +# connect(self.fileview, SIGNAL('revForDiffChanged'), +# self.revdisplay.setDiffRevision)     def setupRevisionTable(self):   view = self.repoview @@ -243,8 +346,8 @@
  connect(view, SIGNAL('revisionSelected'), self.revision_selected)   connect(view, SIGNAL('revisionActivated'), self.revision_activated)   connect(view, SIGNAL('updateToRevision'), self.updateToRevision) - connect(self.revdisplay, SIGNAL('revisionSelected'), view.goto) - connect(self.revdisplay, SIGNAL('parentRevisionSelected'), self.fileview.displayDiff) +# connect(self.revdisplay, SIGNAL('revisionSelected'), view.goto) +# connect(self.revdisplay, SIGNAL('parentRevisionSelected'), self.fileview.displayDiff)   self.attachQuickBar(view.goto_toolbar)   gotoaction = view.goto_toolbar.toggleViewAction()   gotoaction.setIcon(geticon('goto')) @@ -308,7 +411,8 @@
  if self.repomodel.graph:   ctx = self.repomodel.repo.changectx(rev)   self.fileview.setContext(ctx) - self.revdisplay.displayRevision(ctx) +# self.revdisplay.displayRevision(ctx) + self.revpanel.update(ctx.rev())   self.filelistmodel.setSelectedRev(ctx)   if len(self.filelistmodel):   self.tableView_filelist.selectRow(0) @@ -379,7 +483,7 @@
  wb = "RepoWidget/"   for n in self.splitternames:   s.setValue(wb + n, getattr(self, n).saveState()) - s.setValue(wb + 'revdisplay.expanded', self.revdisplay.expanded()) +# s.setValue(wb + 'revdisplay.expanded', self.revdisplay.expanded())     def restoreSettings(self):   s = QtCore.QSettings() @@ -390,8 +494,8 @@
  n += '_splitter'   self.splitternames.append(n)   getattr(self, n).restoreState(s.value(wb + n).toByteArray()) - expanded = s.value(wb + 'revdisplay.expanded', True).toBool() - self.revdisplay.setExpanded(expanded) +# expanded = s.value(wb + 'revdisplay.expanded', True).toBool() +# self.revdisplay.setExpanded(expanded)     def closeRepoWidget(self):   '''returns False if close should be aborted'''
 
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
 
194
195
196
197
198
199
200
201
202
203
204
 
92
93
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
96
97
 
173
174
175
 
 
 
 
 
176
177
178
@@ -92,27 +92,6 @@
  <number>0</number>   </property>   <item> - <widget class="RevDisplay" name="revdisplay" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="font"> - <font> - <pointsize>9</pointsize> - </font> - </property> - </widget> - </item> - <item>   <widget class="QSplitter" name="message_splitter">   <property name="sizePolicy">   <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> @@ -194,11 +173,6 @@
  <header>repoview.h</header>   </customwidget>   <customwidget> - <class>RevDisplay</class> - <extends>QWidget</extends> - <header>revdisplay.h</header> - </customwidget> - <customwidget>   <class>HgFileListView</class>   <extends>QTableView</extends>   <header>filelistview.h</header>
 
1
2
3
 
4
5
 
6
7
8
 
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
120
121
122
123
 
124
125
126
 
1
2
 
3
4
 
5
6
7
8
 
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
 
108
109
110
 
111
112
113
114
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-   -# Form implementation generated from reading ui file 'C:\Users\adi\hgrepos\thg-qt\tortoisehg\hgqt\repowidget.ui' +# Form implementation generated from reading ui file 'repowidget.ui'  # -# Created: Sat May 15 18:55:13 2010 +# Created: Mon May 17 15:12:58 2010  # by: PyQt4 UI code generator 4.7.3  #  # WARNING! All changes made in this file will be lost! @@ -65,18 +65,6 @@
  self.verticalLayout.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)   self.verticalLayout.setMargin(0)   self.verticalLayout.setObjectName("verticalLayout") - self.revdisplay = RevDisplay(self.frame) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.revdisplay.sizePolicy().hasHeightForWidth()) - self.revdisplay.setSizePolicy(sizePolicy) - self.revdisplay.setMinimumSize(QtCore.QSize(0, 0)) - font = QtGui.QFont() - font.setPointSize(9) - self.revdisplay.setFont(font) - self.revdisplay.setObjectName("revdisplay") - self.verticalLayout.addWidget(self.revdisplay)   self.message_splitter = QtGui.QSplitter(self.frame)   sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)   sizePolicy.setHorizontalStretch(0) @@ -120,7 +108,7 @@
  def retranslateUi(self, Form):   Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))   -from revdisplay import RevDisplay, RevMessage +from revdisplay import RevMessage  from filelistview import HgFileListView  from fileview import HgFileView  from repoview import HgRepoView