Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.3, 2.0, and 2.0.1

stable cmdui: rename output_log to outputLog

Changeset 5d191b8321bb

Parent 78660f611adf

by Steve Borho

Changes to 3 files · Browse files at 5d191b8321bb Showing diff from parent 78660f611adf Diff from another changeset...

 
153
154
155
156
157
158
 
 
159
160
161
 
278
279
280
281
 
282
283
284
 
287
288
289
290
 
291
292
293
 
662
663
664
665
666
 
 
667
668
669
 
684
685
686
687
 
688
689
690
691
 
692
693
694
 
716
717
718
719
 
720
721
722
 
751
752
753
754
 
755
756
757
 
820
821
822
823
 
824
825
826
 
843
844
845
846
 
847
848
849
 
153
154
155
 
 
 
156
157
158
159
160
 
277
278
279
 
280
281
282
283
 
286
287
288
 
289
290
291
292
 
661
662
663
 
 
664
665
666
667
668
 
683
684
685
 
686
687
688
689
 
690
691
692
693
 
715
716
717
 
718
719
720
721
 
750
751
752
 
753
754
755
756
 
819
820
821
 
822
823
824
825
 
842
843
844
 
845
846
847
848
@@ -153,9 +153,8 @@
  self.useproc = False   self.internallog = useInternal   if useInternal: - self.output_text = LogWidget() - self.output_text.installEventFilter( - qscilib.KeyPressInterceptor(self)) + self.outputLog = LogWidget() + self.outputLog.installEventFilter(qscilib.KeyPressInterceptor(self))     ### Public Methods ###   @@ -278,7 +277,7 @@
  self.thread.progressReceived.connect(self.progress)     if self.internallog: - self.thread.outputReceived.connect(self.output_text.appendLog) + self.thread.outputReceived.connect(self.outputLog.appendLog)   if self.stbar:   self.thread.progressReceived.connect(self.stbar.progress)   @@ -287,7 +286,7 @@
    def clearOutput(self):   if self.internallog: - self.output_text.clear() + self.outputLog.clear()     ### Signal Handlers ###   @@ -662,8 +661,8 @@
  vbox.setContentsMargins(*(1,)*4)     # command output area - self.core.output_text.setHidden(True) - vbox.addWidget(self.core.output_text, 1) + self.core.outputLog.setHidden(True) + vbox.addWidget(self.core.outputLog, 1)     ## status and progress labels   self.stbar = ThgStatusBar() @@ -684,11 +683,11 @@
    def setShowOutput(self, visible):   if self.internallog: - self.core.output_text.setShown(visible) + self.core.outputLog.setShown(visible)     def outputShown(self):   if self.internallog: - return self.core.output_text.isVisible() + return self.core.outputLog.isVisible()   else:   return False   @@ -716,7 +715,7 @@
  vbox.setContentsMargins(*(1,)*4)     # command output area - vbox.addWidget(self.core.output_text, 1) + vbox.addWidget(self.core.outputLog, 1)     ## status and progress labels   self.stbar = ThgStatusBar() @@ -751,7 +750,7 @@
    def setShowOutput(self, visible):   """show/hide command output""" - self.core.output_text.setVisible(visible) + self.core.outputLog.setVisible(visible)   self.detailBtn.setChecked(visible)     # workaround to adjust only window height @@ -820,7 +819,7 @@
  self.core.progress.connect(self.progress)     if useInternal: - self.core.output_text.setMinimumSize(460, 320) + self.core.outputLog.setMinimumSize(460, 320)     ### Public Methods ###   @@ -843,7 +842,7 @@
  self.dlg.setWindowFlags(flags)   box = QVBoxLayout()   box.setContentsMargins(*(0,)*4) - box.addWidget(self.core.output_text) + box.addWidget(self.core.outputLog)   self.dlg.setLayout(box)   self.dlg.setVisible(visible)  
 
392
393
394
395
 
396
397
398
 
392
393
394
 
395
396
397
398
@@ -392,7 +392,7 @@
  (QMessageBox.No, _('Cancel')))   if qtlib.QuestionMsgBox(_('Confirm Clean Up'), main, text,   labels=labels, parent=self): - o = self.cmd.output_text + o = self.cmd.outputLog   o.appendLog(_('Canceling merge...\n'), 'control')   o.appendLog(_('(Please close any running merge tool)\n'), 'control')   self.cmd.cancel()
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
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
 # serve.py - TortoiseHg dialog to start web server  #  # Copyright 2010 Yuya Nishihara <yuya@tcha.org>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import sys, os, httplib, socket, tempfile  from PyQt4.QtCore import *  from PyQt4.QtGui import *  from mercurial import extensions, hgweb, util  from mercurial.hgweb import server # workaround for demandimport  from tortoisehg.util import paths, wconfig  from tortoisehg.hgqt import cmdui, qtlib  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt.serve_ui import Ui_ServeDialog  from tortoisehg.hgqt.webconf import WebconfForm    class ServeDialog(QDialog):   """Dialog for serving repositories via web"""   def __init__(self, webconf, parent=None):   super(ServeDialog, self).__init__(parent)   self.setWindowFlags((self.windowFlags() | Qt.WindowMinimizeButtonHint)   & ~Qt.WindowContextHelpButtonHint)   # TODO: choose appropriate icon   self.setWindowIcon(qtlib.geticon('proxy'))     self._qui = Ui_ServeDialog()   self._qui.setupUi(self)     self._initwebconf(webconf)   self._initcmd()   self._initactions()   self._updateform()     def _initcmd(self):   self._cmd = cmdui.Widget()   # TODO: forget old logs? - self._log_edit = self._cmd.core.output_text + self._log_edit = self._cmd.core.outputLog   self._qui.details_tabs.addTab(self._log_edit, _('Log'))   self._cmd.hide()   self._cmd.commandStarted.connect(self._updateform)   self._cmd.commandFinished.connect(self._updateform)     def _initwebconf(self, webconf):   self._webconf_form = WebconfForm(webconf=webconf, parent=self)   self._qui.details_tabs.addTab(self._webconf_form, _('Repositories'))     def _initactions(self):   self._qui.start_button.clicked.connect(self.start)   self._qui.stop_button.clicked.connect(self.stop)     @pyqtSlot()   def _updateform(self):   """update form availability and status text"""   self._updatestatus()   self._qui.start_button.setEnabled(not self.isstarted())   self._qui.stop_button.setEnabled(self.isstarted())   self._qui.settings_button.setEnabled(not self.isstarted())   self._qui.port_edit.setEnabled(not self.isstarted())   self._webconf_form.setEnabled(not self.isstarted())     def _updatestatus(self):   def statustext():   if self.isstarted():   # TODO: escape special chars   link = '<a href="%s">%s</a>' % (self.rooturl, self.rooturl)   return _('Running at %s') % link   else:   return _('Stopped')     self._qui.status_edit.setText(statustext())     @pyqtSlot()   def start(self):   """Start web server"""   if self.isstarted():   return     _setupwrapper()   self._cmd.run(self._cmdargs())     def _cmdargs(self):   """Build command args to run server"""   a = ['serve', '--port', str(self.port)]   if self._singlerepo:   a += ['-R', self._singlerepo]   else:   a += ['--web-conf', self._tempwebconf()]   return a     def _tempwebconf(self):   """Save current webconf to temporary file; return its path"""   if not hasattr(self._webconf, 'write'):   return self._webconf.path     fd, fname = tempfile.mkstemp(prefix='webconf_', dir=qtlib.gettempdir())   f = os.fdopen(fd, 'w')   try:   self._webconf.write(f)   return fname   finally:   f.close()     @property   def _webconf(self):   """Selected webconf object"""   return self._webconf_form.webconf     @property   def _singlerepo(self):   """Return repository path if serving single repository"""   # NOTE: we cannot use web-conf to serve single repository at '/' path   if len(self._webconf['paths']) != 1:   return   path = self._webconf.get('paths', '/')   if path and '*' not in path: # exactly a single repo (no wildcard)   return path     @pyqtSlot()   def stop(self):   """Stop web server"""   if not self.isstarted():   return     self._cmd.cancel()   self._fake_request()     def _fake_request(self):   """Send fake request for server to run python code"""   TIMEOUT = 0.5 # [sec]   conn = httplib.HTTPConnection('localhost:%d' % self.port)   origtimeout = socket.getdefaulttimeout()   socket.setdefaulttimeout(TIMEOUT)   try:   conn.request('GET', '/')   res = conn.getresponse()   res.read()   except (socket.error, httplib.HTTPException):   pass   finally:   socket.setdefaulttimeout(origtimeout)   conn.close()     def reject(self):   self.stop()   super(ServeDialog, self).reject()     def isstarted(self):   """Is the web server running?"""   return self._cmd.core.running()     @property   def rooturl(self):   """Returns the root URL of the web server"""   # TODO: scheme, hostname ?   return 'http://localhost:%d' % self.port     @property   def port(self):   """Port number of the web server"""   return int(self._qui.port_edit.value())     def keyPressEvent(self, event):   if self.isstarted() and event.key() == Qt.Key_Escape:   self.stop()   return     return super(ServeDialog, self).keyPressEvent(event)     def closeEvent(self, event):   if self.isstarted():   self._minimizetotray()   event.ignore()   return     return super(ServeDialog, self).closeEvent(event)     @util.propertycache   def _trayicon(self):   icon = QSystemTrayIcon(self.windowIcon(), parent=self)   icon.activated.connect(self._restorefromtray)   icon.setToolTip(self.windowTitle())   # TODO: context menu   return icon     # TODO: minimize to tray by minimize button     @pyqtSlot()   def _minimizetotray(self):   self._trayicon.show()   self.hide()     @pyqtSlot()   def _restorefromtray(self):   self._trayicon.hide()   self.show()     @pyqtSlot()   def on_settings_button_clicked(self):   from tortoisehg.hgqt import settings   settings.SettingsDialog(parent=self, focus='web.name').exec_()    def _create_server(orig, ui, app):   """wrapper for hgweb.server.create_server to be interruptable"""   server = orig(ui, app)   server.accesslog = ui   server.errorlog = ui # TODO: ui.warn   server._serving = False     def serve_forever(orig):   server._serving = True   try:   while server._serving:   server.handle_request()   except KeyboardInterrupt:   # raised outside try-block around process_request().   # see SocketServer.BaseServer   pass   finally:   server._serving = False   server.server_close()     def handle_error(orig, request, client_address):   type, value, _traceback = sys.exc_info()   if issubclass(type, KeyboardInterrupt):   server._serving = False   else:   ui.write_err('%s\n' % value)     extensions.wrapfunction(server, 'serve_forever', serve_forever)   extensions.wrapfunction(server, 'handle_error', handle_error)   return server    _setupwrapper_done = False  def _setupwrapper():   """Wrap hgweb.server.create_server to get along with thg"""   global _setupwrapper_done   if not _setupwrapper_done:   extensions.wrapfunction(hgweb.server, 'create_server',   _create_server)   _setupwrapper_done = True    def run(ui, *pats, **opts):   repopath = opts.get('root') or paths.find_root()   webconfpath = opts.get('web_conf') or opts.get('webdir_conf')   dlg = ServeDialog(webconf=_newwebconf(repopath, webconfpath))   if repopath or webconfpath:   dlg.start()   return dlg    def _newwebconf(repopath, webconfpath):   """create config obj for hgweb"""   if webconfpath:   # TODO: handle file not found   c = wconfig.readfile(webconfpath)   c.path = os.path.abspath(webconfpath)   return c   elif repopath: # imitate webconf for single repo   c = wconfig.config()   c.set('paths', '/', repopath)   return c