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

manifestdialog: add annotate view to contentview

Context menu of annotate view is not supported yet.

Changeset d92f179a85af

Parent 781cc2bca0ab

by Yuya Nishihara

Changes to one file · Browse files at d92f179a85af Showing diff from parent 781cc2bca0ab Diff from another changeset...

 
28
29
30
31
 
32
33
34
 
45
46
47
 
48
49
 
 
 
 
 
 
 
 
 
 
 
 
50
51
52
 
106
107
108
 
 
 
 
 
 
 
 
 
 
 
 
 
109
110
111
 
117
118
119
 
120
121
122
 
129
130
131
132
133
 
 
 
 
 
 
 
 
134
135
136
 
144
145
146
 
 
 
 
 
 
 
147
148
149
 
28
29
30
 
31
32
33
34
 
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 
143
144
145
146
147
148
149
 
156
157
158
 
 
159
160
161
162
163
164
165
166
167
168
169
 
177
178
179
180
181
182
183
184
185
186
187
188
189
@@ -28,7 +28,7 @@
 from tortoisehg.util import paths, thgrepo  from tortoisehg.util.hglib import tounicode   -from tortoisehg.hgqt import qtlib +from tortoisehg.hgqt import qtlib, annotate  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt.manifestmodel import ManifestModel  from tortoisehg.hgqt.lexers import get_lexer @@ -45,8 +45,21 @@
  self._manifest_widget = ManifestWidget(ui, repo, rev)   self.setCentralWidget(self._manifest_widget)   + self._initactions()   self._readsettings()   + def _initactions(self): + self._toolbar = QToolBar() + self.addToolBar(self._toolbar) + # TODO: not sure 'Annotate' mode is good for toolbar + self._action_annotate_mode = QAction(_('Annotate'), self, checkable=True) + self._action_annotate_mode.toggled.connect(self._annotate_mode_toggled) + self._toolbar.addAction(self._action_annotate_mode) + + @pyqtSlot(bool) + def _annotate_mode_toggled(self, checked): + self._manifest_widget.setfileview(checked and 'annotate' or 'cat') +   def closeEvent(self, event):   self._writesettings()   super(ManifestDialog, self).closeEvent(event) @@ -106,6 +119,19 @@
  self.setMarginWidth(1, str(nlines)+'00')   self.setText(data)   +class _FileAnnotateView(annotate.AnnotateView): + def __init__(self, ui, repo, parent=None): + super(_FileAnnotateView, self).__init__(parent) + self._ui = ui + self._repo = repo + + @pyqtSlot(unicode, object) + def setsource(self, path, rev): + ctx = self._repo[rev] + if path not in ctx: + return # TODO + self.annotateFileAtRev(self._repo, ctx, path) +  class ManifestWidget(QWidget):   """Display file tree and contents at the specified revision"""   def __init__(self, ui, repo, rev=None, parent=None): @@ -117,6 +143,7 @@
  self._initwidget()   self._initmodel()   self._treeview.setCurrentIndex(self._treemodel.index(0, 0)) + self.setfileview('cat')     def _initwidget(self):   self.setLayout(QVBoxLayout()) @@ -129,8 +156,14 @@
  self._splitter.setStretchFactor(0, 1)   self._splitter.setStretchFactor(1, 3)   - self._textview = _FileTextView(self._ui, self._repo) - self._contentview.addWidget(self._textview) + self._filewidgets = { + 'cat': _FileTextView(self._ui, self._repo), + 'annotate': _FileAnnotateView(self._ui, self._repo), + } + for w in self._filewidgets.itervalues(): + self._contentview.addWidget(w) + self._contentview.currentChanged.connect( + lambda: self._fileselected(self._treeview.currentIndex()))     def _initmodel(self):   self._treemodel = ManifestModel(self._repo, self._rev) @@ -144,6 +177,13 @@
  path = self._treemodel.pathFromIndex(index)   self._contentview.currentWidget().setsource(path, self._rev)   + @pyqtSlot(unicode) + def setfileview(self, mode): + """Change widget for file content view""" + assert mode in self._filewidgets + self._curfileview = self._filewidgets[mode] + self._contentview.setCurrentWidget(self._curfileview) +    def run(ui, *pats, **opts):   repo = opts.get('repo') or thgrepo.repository(ui, paths.find_root())