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

manifestdialog: update copyright line

Changeset 186308639573

Parent 3656bbf7cf9b

by Yuya Nishihara

Changes to one file · Browse files at 186308639573 Showing diff from parent 3656bbf7cf9b 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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
 
 
 
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
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
-# -*- coding: utf-8 -*- -# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE). -# http://www.logilab.fr/ -- mailto:contact@logilab.fr +# manifestdialog.py - Dialog and widget for TortoiseHg manifest view +# +# Copyright (C) 2003-2010 LOGILAB S.A. <http://www.logilab.fr/> +# Copyright (C) 2010 Yuya Nishihara <yuya@tcha.org>  #  # This program is free software; you can redistribute it and/or modify it under  # the terms of the GNU General Public License as published by the Free Software  # Foundation; either version 2 of the License, or (at your option) any later  # version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -""" -Qt4 dialogs to display hg revisions of a file -""" +  import os    from mercurial import util    from PyQt4.QtCore import *  from PyQt4.QtGui import *    from tortoisehg.util import paths, hglib    from tortoisehg.hgqt import qtlib, qscilib, annotate, status, thgrepo, \   visdiff, wctxactions  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt.manifestmodel import ManifestModel    class ManifestDialog(QMainWindow):   """   Qt4 dialog to display all files of a repo at a given revision   """   def __init__(self, ui, repo, rev=None, parent=None):   QMainWindow.__init__(self, parent)   self._repo = repo   self.resize(400, 300)     self._manifest_widget = ManifestWidget(ui, repo, rev)   self._manifest_widget.revChanged.connect(self._updatewindowtitle)   self._manifest_widget.editSelected.connect(self._openInEditor)   self._manifest_widget.grepRequested.connect(self._openSearchWidget)   self.setCentralWidget(self._manifest_widget)   self.addToolBar(self._manifest_widget.toolbar)     self._searchbar = qscilib.SearchToolBar()   connectsearchbar(self._manifest_widget, self._searchbar)   self.addToolBar(self._searchbar)     self.setStatusBar(QStatusBar())   self._manifest_widget.revisionHint.connect(self.statusBar().showMessage)     self._readsettings()   self._updatewindowtitle()     @pyqtSlot()   def _updatewindowtitle(self):   self.setWindowTitle(_('Hg manifest viewer - %s:%s') % (   self._repo.root, self._manifest_widget.rev))     def closeEvent(self, event):   self._writesettings()   super(ManifestDialog, self).closeEvent(event)     def _readsettings(self):   s = QSettings()   self.restoreGeometry(s.value('manifest/geom').toByteArray())   # TODO: don't call deeply   self._manifest_widget._splitter.restoreState(   s.value('manifest/splitter').toByteArray())     def _writesettings(self):   s = QSettings()   s.setValue('manifest/geom', self.saveGeometry())   # TODO: don't call deeply   s.setValue('manifest/splitter',   self._manifest_widget._splitter.saveState())     def setSource(self, path, rev, line=None):   self._manifest_widget.setSource(path, rev, line)     def setSearchPattern(self, text):   """Set search pattern [unicode]"""   self._searchbar.setPattern(text)     @pyqtSlot(unicode, dict)   def _openSearchWidget(self, pattern, opts):   opts = dict((str(k), str(v)) for k, v in opts.iteritems())   from tortoisehg.hgqt import run   run.grep(self._repo.ui, hglib.fromunicode(pattern), **opts)     @pyqtSlot(unicode, object, int)   def _openInEditor(self, path, rev, line):   """Open editor to show the specified file"""   _openineditor(self._repo, path, rev, line,   pattern=self._searchbar.pattern(), parent=self)    class ManifestWidget(QWidget):   """Display file tree and contents at the specified revision"""     revChanged = pyqtSignal(object)   """Emitted (rev) when the current revision changed"""     revisionHint = pyqtSignal(unicode)   """Emitted when to show revision summary as a hint"""     searchRequested = pyqtSignal(unicode)   """Emitted (pattern) when user request to search content"""     editSelected = pyqtSignal(unicode, object, int)   """Emitted (path, rev, line) when user requests to open editor"""     grepRequested = pyqtSignal(unicode, dict)   """Emitted (pattern, opts) when user request to search changelog"""     def __init__(self, ui, repo, rev=None, parent=None):   super(ManifestWidget, self).__init__(parent)   self._ui = ui   self._repo = repo   self._rev = rev     self._initwidget()   self._initactions()   self._setupmodel()   self._treeview.setCurrentIndex(self._treemodel.index(0, 0))     def _initwidget(self):   self.setLayout(QVBoxLayout())   self._splitter = QSplitter()   self.layout().addWidget(self._splitter)   self.layout().setContentsMargins(2, 2, 2, 2)     navlayout = QVBoxLayout(spacing=0)   navlayout.setContentsMargins(0, 0, 0, 0)   self._toolbar = QToolBar()   self._toolbar.setIconSize(QSize(16,16))   self._treeview = QTreeView(self, headerHidden=True, dragEnabled=True)   navlayout.addWidget(self._toolbar)   navlayout.addWidget(self._treeview)   navlayoutw = QWidget()   navlayoutw.setLayout(navlayout)     self._contentview = QStackedWidget()   self._splitter.addWidget(navlayoutw)   self._splitter.addWidget(self._contentview)   self._splitter.setStretchFactor(0, 1)   self._splitter.setStretchFactor(1, 3)     self._nullcontent = QWidget()   self._contentview.addWidget(self._nullcontent)   self._fileview = annotate.AnnotateView(self._repo)   self._fileview.sourceChanged.connect(self.setSource)   self._contentview.addWidget(self._fileview)   for name in ('revisionHint', 'searchRequested', 'editSelected',   'grepRequested'):   getattr(self._fileview, name).connect(getattr(self, name))     def _initactions(self):   self._statusfilter = _StatusFilterButton(text='MAC')   self._toolbar.addWidget(self._statusfilter)     self._action_annotate_mode = QAction(_('Annotate'), self, checkable=True)   self._action_annotate_mode.toggled.connect(   self._fileview.setAnnotationEnabled)   self._toolbar.addAction(self._action_annotate_mode)     @property   def toolbar(self):   """Return toolbar for manifest widget"""   return self._toolbar     @pyqtSlot(unicode, bool, bool, bool)   def find(self, pattern, icase=False, wrap=False, forward=True):   return self._fileview.find(pattern, icase, wrap, forward)     @pyqtSlot(unicode, bool)   def highlightText(self, pattern, icase=False):   self._fileview.highlightText(pattern, icase)     def _setupmodel(self):   self._treemodel = ManifestModel(self._repo, self._rev,   statusfilter=self._statusfilter.text,   parent=self)   self._treeview.setModel(self._treemodel)   self._treeview.selectionModel().currentChanged.connect(self._updatecontent)   self._statusfilter.textChanged.connect(self._treemodel.setStatusFilter)   self._statusfilter.textChanged.connect(self._autoexpandtree)   self._autoexpandtree()     @pyqtSlot()   def _autoexpandtree(self):   """expand file tree if the number of the items isn't large"""   if 'C' not in self._statusfilter.text:   self._treeview.expandAll()     def reload(self):   # TODO   pass     @property   def rev(self):   """Return current revision"""   return self._rev     @pyqtSlot(object)   def setRev(self, rev):   """Change revision to show"""   self.setSource(self.path, rev)     @pyqtSlot(unicode, object)   @pyqtSlot(unicode, object, int)   def setSource(self, path, rev, line=None):   """Change path and revision to show at once"""   revchanged = self._rev != rev   if revchanged:   self._rev = rev   self._setupmodel()   self.setPath(path)   if self.path in self._repo[rev]:   self._fileview.setSource(path, rev, line)   if revchanged:   self.revChanged.emit(rev)     @property   def path(self):   """Return currently selected path"""   return self._treemodel.filePath(self._treeview.currentIndex())     @pyqtSlot(unicode)   def setPath(self, path):   """Change path to show"""   self._treeview.setCurrentIndex(self._treemodel.indexFromPath(path))     @pyqtSlot()   def _updatecontent(self):   if hglib.fromunicode(self.path) not in self._repo[self._rev]:   self._contentview.setCurrentWidget(self._nullcontent)   return     self._contentview.setCurrentWidget(self._fileview)   self._fileview.setSource(self.path, self._rev)    # TODO: share this menu with status widget?  class _StatusFilterButton(QToolButton):   """Button with drop-down menu for status filter"""   textChanged = pyqtSignal(str)     _TYPES = 'MARC'     def __init__(self, text=_TYPES, parent=None):   super(_StatusFilterButton, self).__init__(   parent, popupMode=QToolButton.InstantPopup,   icon=qtlib.geticon('status'),   toolButtonStyle=Qt.ToolButtonTextBesideIcon)     self._initactions(text=text)   self._setText(self.text)     def _initactions(self, text):   self._actions = {}   menu = QMenu(self)   for c in self._TYPES:   st = status.statusTypes[c]   a = menu.addAction('%s %s' % (c, st.name))   a.setCheckable(True)   a.setChecked(c in text)   a.toggled.connect(self._update)   self._actions[c] = a   self.setMenu(menu)     @pyqtSlot()   def _update(self):   self._setText(self.text)   self.textChanged.emit(self.text)     @property   def text(self):   """Return the text for status filter"""   return ''.join(c for c in self._TYPES   if self._actions[c].isChecked())     @pyqtSlot(str)   def setText(self, text):   """Set the status text"""   assert util.all(c in self._TYPES for c in text)   for c in self._TYPES:   self._actions[c].setChecked(c in text)     def _setText(self, text):   super(_StatusFilterButton, self).setText(text)    class ManifestTaskWidget(ManifestWidget):   """Manifest widget designed for task tab"""     def __init__(self, ui, repo, rev=None, parent=None):   super(ManifestTaskWidget, self).__init__(ui, repo, rev, parent)   self.editSelected.connect(self._openInEditor)     @pyqtSlot()   def showSearchBar(self):   self._searchbar.show()   self._searchbar.setFocus()     @util.propertycache   def _searchbar(self):   searchbar = qscilib.SearchToolBar(hidable=True)   searchbar.hide()   self.layout().addWidget(searchbar)   connectsearchbar(self, searchbar)   return searchbar     @pyqtSlot(unicode, object, int)   def _openInEditor(self, path, rev, line):   """Open editor to show the specified file"""   _openineditor(self._repo, path, rev, line,   pattern=self._searchbar.pattern(), parent=self)    def connectsearchbar(manifestwidget, searchbar):   """Connect searchbar to manifest widget"""   searchbar.conditionChanged.connect(manifestwidget.highlightText)   searchbar.searchRequested.connect(manifestwidget.find)   manifestwidget.searchRequested.connect(searchbar.search)    def _openineditor(repo, path, rev, line=None, pattern=None, parent=None):   """Open editor to show the specified file [unicode]"""   path = hglib.fromunicode(path)   pattern = hglib.fromunicode(pattern)   base = visdiff.snapshot(repo, [path], repo[rev])[0]   files = [os.path.join(base, path)]   wctxactions.edit(parent, repo.ui, repo, files, line, pattern)      def run(ui, *pats, **opts):   repo = opts.get('repo') or thgrepo.repository(ui, paths.find_root())   dlg = ManifestDialog(ui, repo, opts.get('rev'))     # set initial state after dialog visible   def init():   try:   path = hglib.canonpaths(pats)[0]   line = opts.get('line') and int(opts['line']) or None   dlg.setSource(path, opts.get('rev'), line)   except IndexError:   pass   dlg.setSearchPattern(hglib.tounicode(opts.get('pattern')) or '')   QTimer.singleShot(0, init)     return dlg