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

wctxactions: implement edit and copy methods

Changeset 093e6fae10a5

Parent bf5f87a7befd

by Steve Borho

Changes to one file · Browse files at 093e6fae10a5 Showing diff from parent bf5f87a7befd Diff from another changeset...

 
6
7
8
 
9
10
11
 
13
14
15
16
 
17
18
19
 
102
103
104
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
107
108
 
171
172
173
174
 
 
 
 
 
 
 
 
 
 
175
176
 
177
178
179
 
6
7
8
9
10
11
12
 
14
15
16
 
17
18
19
20
 
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
 
195
196
197
 
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
@@ -6,6 +6,7 @@
 # GNU General Public License version 2, incorporated herein by reference.    import os +import subprocess    from mercurial import util, cmdutil, error, merge, commands  from tortoisehg.hgqt import qtlib, htmlui @@ -13,7 +14,7 @@
 from tortoisehg.util.i18n import _    from PyQt4.QtCore import Qt, SIGNAL -from PyQt4.QtGui import QAction, QMenu, QMessageBox +from PyQt4.QtGui import QAction, QMenu, QMessageBox, QFileDialog    def wctxactions(parent, point, repo, selrows):   if not selrows: @@ -102,7 +103,30 @@
  visualdiff(ui, repo, files, {})    def edit(parent, ui, repo, files): - raise NotImplementedError() + editor = (ui.config('tortoisehg', 'editor') or + ui.config('gtools', 'editor') or + os.environ.get('HGEDITOR') or + ui.config('ui', 'editor') or + os.environ.get('EDITOR', 'vi')) + if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): + res = QtGui.QMessageBox.critical(parent, + _('No visual editor configured'), + _('Please configure a visual editor.')) + #dlg = thgconfig.ConfigDialog(False, focus='tortoisehg.editor') + #dlg.exec_() + return + + cmdline = ' '.join([editor] + [util.localpath(f) for f in files]) + cmdline = util.quotecommand(cmdline) + try: + from tortoisehg.hgqt.visdiff import openflags + subprocess.Popen(cmdline, shell=True, creationflags=openflags, + stderr=None, stdout=None, stdin=None) + except (OSError, EnvironmentError), e: + QtGui.QMessageBox.warning(parent, + _('Editor launch failure'), + _('%s : %s') % (cmd, str(e))) + return False    def viewmissing(parent, ui, repo, files):   raise NotImplementedError() @@ -171,9 +195,19 @@
  return True    def copy(parent, ui, repo, files): - raise NotImplementedError() + assert len(files) == 1 + wfile = repo.wjoin(files[0]) + fd = QFileDialog(parent) + fname = fd.getSaveFileName(parent, _('Copy file to'), wfile) + if not fname: + return + fname = hglib.fromunicode(fname) + wfiles = [wfile, fname] + commands.copy(ui, repo, *wfiles) + return True    def rename(parent, ui, repo, files): + # needs rename dialog   raise NotImplementedError()    def resolve(parent, ui, repo, files):