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

manifestdialog: implement menu action to open specified content in editor

Changeset 55860cf8cff8

Parent d98e9a822a33

by Yuya Nishihara

Changes to one file · Browse files at 55860cf8cff8 Showing diff from parent d98e9a822a33 Diff from another changeset...

 
17
18
19
 
20
21
22
 
25
26
27
28
 
29
30
31
 
40
41
42
 
43
44
45
 
83
84
85
 
 
 
 
 
 
86
87
88
 
93
94
95
 
 
 
96
97
98
 
134
135
136
137
 
 
138
139
140
 
274
275
276
 
 
 
 
277
278
279
 
287
288
289
 
 
 
 
 
 
290
291
292
293
294
295
 
 
 
 
 
 
 
 
296
297
298
 
17
18
19
20
21
22
23
 
26
27
28
 
29
30
31
32
 
41
42
43
44
45
46
47
 
85
86
87
88
89
90
91
92
93
94
95
96
 
101
102
103
104
105
106
107
108
109
 
145
146
147
 
148
149
150
151
152
 
286
287
288
289
290
291
292
293
294
295
 
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
@@ -17,6 +17,7 @@
 """  Qt4 dialogs to display hg revisions of a file  """ +import os    from mercurial import util   @@ -25,7 +26,7 @@
   from tortoisehg.util import paths, hglib   -from tortoisehg.hgqt import qtlib, annotate, status, thgrepo +from tortoisehg.hgqt import qtlib, annotate, status, thgrepo, visdiff, wctxactions  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt.manifestmodel import ManifestModel   @@ -40,6 +41,7 @@
    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) @@ -83,6 +85,12 @@
  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) # emit when curret revision changed @@ -93,6 +101,9 @@
  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"""   @@ -134,7 +145,8 @@
  self._fileview = annotate.AnnotateView(self._repo)   self._fileview.sourceChanged.connect(self.setSource)   self._contentview.addWidget(self._fileview) - for name in ('revisionHint', 'searchRequested', 'grepRequested'): + for name in ('revisionHint', 'searchRequested', 'editSelected', + 'grepRequested'):   getattr(self._fileview, name).connect(getattr(self, name))     def _initactions(self): @@ -274,6 +286,10 @@
 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() @@ -287,12 +303,26 @@
  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.searchText)   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())