Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek Merge with stable

Changeset 36e87958af73

Parents ca666161b014

Parents ed75d8f72a86

by David Golub

Changes to 14 files · Browse files at 36e87958af73 Showing diff from parent ca666161b014 ed75d8f72a86 Diff from another changeset...

Change 1 of 1 Show Entire File setup.py Stacked
 
334
335
336
 
 
 
 
 
 
 
 
 
337
338
339
 
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
@@ -334,6 +334,15 @@
  if '--version' not in sys.argv:   raise   + # Allow use of environment variables to specify the location of Mercurial + import modulefinder + path = os.getenv('MERCURIAL_PATH') + if path: + modulefinder.AddPackagePath('mercurial', path) + path = os.getenv('HGEXT_PATH') + if path: + modulefinder.AddPackagePath('hgext', path) +   if 'py2exe' in sys.argv:   import hgext   hgextdir = os.path.dirname(hgext.__file__)
 
60
61
62
 
 
63
64
65
 
60
61
62
63
64
65
66
67
@@ -60,6 +60,8 @@
  grid.addWidget(newbranch, 1, 0)   grid.addWidget(branchCombo, 1, 1)   grid.addWidget(closebranch, 2, 0) + grid.setColumnStretch(0, 0) + grid.setColumnStretch(1, 1)   layout.addLayout(grid)     newbranch.toggled.connect(branchCombo.setEnabled)
 
7
8
9
10
 
11
12
13
 
55
56
57
58
59
60
61
 
114
115
116
117
 
118
 
119
120
121
 
196
197
198
 
 
199
200
201
 
436
437
438
 
 
 
 
439
440
441
 
451
452
453
454
 
455
456
457
 
7
8
9
 
10
11
12
13
 
55
56
57
 
58
59
60
 
113
114
115
 
116
117
118
119
120
121
 
196
197
198
199
200
201
202
203
 
438
439
440
441
442
443
444
445
446
447
 
457
458
459
 
460
461
462
463
@@ -7,7 +7,7 @@
 # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.   -import os, string +import os    from PyQt4.QtCore import *  from PyQt4.QtGui import * @@ -55,7 +55,6 @@
  self.src_combo = QComboBox()   self.src_combo.setEditable(True)   self.src_combo.setMinimumWidth(310) - self.src_combo.lineEdit().returnPressed.connect(self.clone)   self.src_btn = QPushButton(_('Browse...'))   self.src_btn.setAutoDefault(False)   self.src_btn.clicked.connect(self.browse_src) @@ -114,8 +113,9 @@
  if btnlabel:   btn = QPushButton(btnlabel)   btn.setEnabled(False) - btn.setAutoDefault = False + btn.setAutoDefault(False)   btn.clicked.connect(btnslot) + hbox.addSpacing(6)   hbox.addWidget(btn)   chk.toggled.connect(   lambda e: self.toggle_enabled(e, text, target2=btn)) @@ -196,6 +196,8 @@
  # connect extra signals   self.src_combo.editTextChanged.connect(self.composeCommand)   self.src_combo.editTextChanged.connect(self.onUrlHttps) + self.src_combo.editTextChanged.connect(self.onResetDefault) + self.src_combo.currentIndexChanged.connect(self.onResetDefault)   self.dest_combo.editTextChanged.connect(self.composeCommand)   self.rev_chk.toggled.connect(self.composeCommand)   self.rev_text.textChanged.connect(self.composeCommand) @@ -436,6 +438,10 @@
  self.qclone_txt.setFocus()   self.composeCommand()   + @pyqtSlot(QString) + def onResetDefault(self, text): + self.clone_btn.setDefault(True) +   def command_started(self):   self.cmd.setShown(True)   self.clone_btn.setHidden(True) @@ -451,7 +457,7 @@
  self.detail_btn.setChecked(True)   self.clone_btn.setShown(True)   self.close_btn.setShown(True) - self.close_btn.setAutoDefault(True) + self.close_btn.setDefault(True)   self.close_btn.setFocus()   self.cancel_btn.setHidden(True)   else:
 
512
513
514
 
515
516
517
 
566
567
568
569
 
 
570
571
572
 
626
627
628
 
629
630
631
 
512
513
514
515
516
517
518
 
567
568
569
 
570
571
572
573
574
 
628
629
630
631
632
633
634
@@ -512,6 +512,7 @@
  self.setFocusProxy(self._logwidget)   self.setRepository(None)   self.openPrompt() + self.suppressPrompt = False     def _initlogwidget(self):   self._logwidget = _LogWidgetForConsole(self) @@ -566,7 +567,8 @@
  try:   self._logwidget.appendLog(msg, label)   finally: - self.openPrompt() + if not self.suppressPrompt: + self.openPrompt()     @pyqtSlot(object)   def setRepository(self, repo): @@ -626,6 +628,7 @@
    @_cmdtable   def _cmd_hg(self, args): + self.closePrompt()   if self._repo:   args = ['--cwd', self._repo.root] + args   self._cmdcore.run(args)
 
38
39
40
 
 
41
42
43
 
70
71
72
 
 
73
74
75
 
38
39
40
41
42
43
44
45
 
72
73
74
75
76
77
78
79
@@ -38,6 +38,8 @@
  progress = pyqtSignal(QString, object, QString, QString, object)   output = pyqtSignal(QString, QString)   makeLogVisible = pyqtSignal(bool) + beginSuppressPrompt = pyqtSignal() + endSuppressPrompt = pyqtSignal()     def __init__(self, repo, pats, opts, embedded=False, parent=None, rev=None):   QWidget.__init__(self, parent=parent) @@ -70,6 +72,8 @@
  self.runner.output.connect(self.output)   self.runner.progress.connect(self.progress)   self.runner.makeLogVisible.connect(self.makeLogVisible) + self.runner.commandStarted.connect(self.beginSuppressPrompt) + self.runner.commandFinished.connect(self.endSuppressPrompt)   self.runner.commandFinished.connect(self.commandFinished)     layout = QVBoxLayout()
 
41
42
43
 
 
 
 
 
 
 
 
 
44
45
46
 
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@@ -41,6 +41,15 @@
  def output(self, msg, label):   self.logte.appendLog(msg, label)   + @pyqtSlot() + def beginSuppressPrompt(self): + self.logte.suppressPrompt = True + + @pyqtSlot() + def endSuppressPrompt(self): + self.logte.suppressPrompt = False + self.logte.openPrompt() +   def showEvent(self, event):   self.visibilityChanged.emit(True)  
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
353
354
355
356
 
 
 
 
 
 
 
 
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
 
 
 
 
 
 
 
 
 
 
 
 
 
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
 # hgemail.py - TortoiseHg's dialog for sending patches via email  #  # Copyright 2007 TK Soh <teekaysoh@gmail.com>  # Copyright 2007 Steve Borho <steve@borho.org>  # 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 os, tempfile, re  from StringIO import StringIO  from PyQt4.QtCore import *  from PyQt4.QtGui import *  from mercurial import error, extensions, util, cmdutil  from tortoisehg.util import hglib, paths  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt import cmdui, lexers, qtlib, thgrepo  from tortoisehg.hgqt.hgemail_ui import Ui_EmailDialog    class EmailDialog(QDialog):   """Dialog for sending patches via email"""   def __init__(self, repo, revs, parent=None, outgoing=False,   outgoingrevs=None):   """Create EmailDialog for the given repo and revs     :revs: List of revisions to be sent.   :outgoing: Enable outgoing bundle support. You also need to set   outgoing revisions to `revs`.   :outgoingrevs: Target revision of outgoing bundle.   (Passed as `hg email --bundle --rev {rev}`)   """   super(EmailDialog, self).__init__(parent)   self.setWindowFlags(Qt.Window)   self._repo = repo   self._outgoing = outgoing   self._outgoingrevs = outgoingrevs or []     self._qui = Ui_EmailDialog()   self._qui.setupUi(self)     self._initchangesets(revs)   self._initpreviewtab()   self._initenvelopebox()   self._qui.bundle_radio.toggled.connect(self._updateforms)   self._initintrobox()   self._readhistory()   self._filldefaults()   self._updateforms()   self._readsettings()   QShortcut(QKeySequence('CTRL+Return'), self, self.accept)   QShortcut(QKeySequence('Ctrl+Enter'), self, self.accept)     def closeEvent(self, event):   self._writesettings()   super(EmailDialog, self).closeEvent(event)     def _readsettings(self):   s = QSettings()   self.restoreGeometry(s.value('email/geom').toByteArray())   self._qui.intro_changesets_splitter.restoreState(   s.value('email/intro_changesets_splitter').toByteArray())     def _writesettings(self):   s = QSettings()   s.setValue('email/geom', self.saveGeometry())   s.setValue('email/intro_changesets_splitter',   self._qui.intro_changesets_splitter.saveState())     def _readhistory(self):   s = QSettings()   for k in ('to', 'cc', 'from', 'flag'):   w = getattr(self._qui, '%s_edit' % k)   w.addItems(s.value('email/%s_history' % k).toStringList())   w.setCurrentIndex(-1) # unselect     def _writehistory(self):   def itercombo(w):   if w.currentText():   yield w.currentText()   for i in xrange(w.count()):   if w.itemText(i) != w.currentText():   yield w.itemText(i)     s = QSettings()   for k in ('to', 'cc', 'from', 'flag'):   w = getattr(self._qui, '%s_edit' % k)   s.setValue('email/%s_history' % k, list(itercombo(w))[:10])     def _initchangesets(self, revs):   def purerevs(revs):   return hglib.revrange(self._repo,   iter(str(e) for e in revs))     self._changesets = _ChangesetsModel(self._repo,   # TODO: [':'] is inefficient   revs=purerevs(revs or [':']),   selectedrevs=purerevs(revs),   parent=self)   self._changesets.dataChanged.connect(self._updateforms)   self._qui.changesets_view.setModel(self._changesets)     @property   def _ui(self):   return self._repo.ui     @property   def _revs(self):   """Returns list of revisions to be sent"""   return self._changesets.selectedrevs     def _filldefaults(self):   """Fill form by default values"""   def getfromaddr(ui):   """Get sender address in the same manner as patchbomb"""   addr = ui.config('email', 'from') or ui.config('patchbomb', 'from')   if addr:   return addr   try:   return ui.username()   except error.Abort:   return ''     self._qui.to_edit.setEditText(   hglib.tounicode(self._ui.config('email', 'to', '')))   self._qui.cc_edit.setEditText(   hglib.tounicode(self._ui.config('email', 'cc', '')))   self._qui.from_edit.setEditText(hglib.tounicode(getfromaddr(self._ui)))     self.setdiffformat(self._ui.configbool('diff', 'git') and 'git' or 'hg')     def setdiffformat(self, format):   """Set diff format, 'hg', 'git' or 'plain'"""   try:   radio = getattr(self._qui, '%spatch_radio' % format)   except AttributeError:   raise ValueError('unknown diff format: %r' % format)     radio.setChecked(True)     def getdiffformat(self):   """Selected diff format"""   for e in self._qui.patch_frame.children():   m = re.match(r'(\w+)patch_radio', str(e.objectName()))   if m and e.isChecked():   return m.group(1)     return 'hg'     def getextraopts(self):   """Dict of extra options"""   opts = {}   for e in self._qui.extra_frame.children():   m = re.match(r'(\w+)_check', str(e.objectName()))   if m:   opts[m.group(1)] = e.isChecked()     return opts     def _patchbombopts(self, **opts):   """Generate opts for patchbomb by form values"""   def headertext(s):   # QLineEdit may contain newline character   return re.sub(r'\s', ' ', hglib.fromunicode(s))     opts['to'] = [headertext(self._qui.to_edit.currentText())]   opts['cc'] = [headertext(self._qui.cc_edit.currentText())]   opts['from'] = headertext(self._qui.from_edit.currentText())   opts['in_reply_to'] = headertext(self._qui.inreplyto_edit.text())   opts['flag'] = [headertext(self._qui.flag_edit.currentText())]     if self._qui.bundle_radio.isChecked():   assert self._outgoing # only outgoing bundle is supported   opts['rev'] = map(str, self._outgoingrevs)   opts['bundle'] = True   else:   opts['rev'] = map(str, self._revs)     def diffformat():   n = self.getdiffformat()   if n == 'hg':   return {}   else:   return {n: True}   opts.update(diffformat())     opts.update(self.getextraopts())     def writetempfile(s):   fd, fname = tempfile.mkstemp(prefix='thg_emaildesc_')   try:   os.write(fd, s)   return fname   finally:   os.close(fd)     opts['intro'] = self._qui.writeintro_check.isChecked()   if opts['intro']:   opts['subject'] = headertext(self._qui.subject_edit.text())   opts['desc'] = writetempfile(hglib.fromunicode(self._qui.body_edit.toPlainText()))   # TODO: change patchbomb not to use temporary file     # Include the repo in the command so it can be found when thg is not   # run from within a hg path   opts['repository'] = self._repo.root     return opts     def _isvalid(self):   """Filled all required values?"""   for e in ('to_edit', 'from_edit'):   if not getattr(self._qui, e).currentText():   return False     if self._qui.writeintro_check.isChecked() and not self._qui.subject_edit.text():   return False     if not self._revs:   return False     return True     @pyqtSlot()   def _updateforms(self):   """Update availability of form widgets"""   valid = self._isvalid()   self._qui.send_button.setEnabled(valid)   self._qui.main_tabs.setTabEnabled(self._previewtabindex(), valid)   self._qui.writeintro_check.setEnabled(not self._introrequired())     self._qui.bundle_radio.setEnabled(   self._outgoing and self._changesets.isselectedall())   self._changesets.setReadOnly(self._qui.bundle_radio.isChecked())   if self._qui.bundle_radio.isChecked():   # workaround to disable preview for outgoing bundle because it   # may freeze main thread   self._qui.main_tabs.setTabEnabled(self._previewtabindex(), False)     if self._introrequired():   self._qui.writeintro_check.setChecked(True)     def _initenvelopebox(self):   for e in ('to_edit', 'from_edit'):   getattr(self._qui, e).editTextChanged.connect(self._updateforms)     def accept(self):   # TODO: want to pass patchbombopts directly   def cmdargs(opts):   args = []   for k, v in opts.iteritems():   if isinstance(v, bool):   if v:   args.append('--%s' % k.replace('_', '-'))   else:   for e in isinstance(v, basestring) and [v] or v:   args += ['--%s' % k.replace('_', '-'), e]     return args     hglib.loadextension(self._ui, 'patchbomb')     opts = self._patchbombopts()   try:   cmd = cmdui.Dialog(['email'] + cmdargs(opts), parent=self)   cmd.setWindowTitle(_('Sending Email'))   cmd.setShowOutput(False)   cmd.finished.connect(cmd.deleteLater)   if cmd.exec_():   self._writehistory()   finally:   if 'desc' in opts:   os.unlink(opts['desc']) # TODO: don't use tempfile     def _initintrobox(self):   self._qui.intro_box.hide() # hidden by default   self._qui.subject_edit.textChanged.connect(self._updateforms)   self._qui.writeintro_check.toggled.connect(self._updateforms)     def _introrequired(self):   """Is intro message required?"""   return len(self._revs) > 1 or self._qui.bundle_radio.isChecked()     def _initpreviewtab(self):   def initqsci(w):   w.setUtf8(True)   w.setReadOnly(True)   w.setMarginWidth(1, 0) # hide area for line numbers   self.lexer = lex = lexers.get_diff_lexer(self)   fh = qtlib.getfont('fontdiff')   fh.changed.connect(self.forwardFont)   lex.setFont(fh.font())   w.setLexer(lex)   # TODO: better way to setup diff lexer     initqsci(self._qui.preview_edit)     self._qui.main_tabs.currentChanged.connect(self._refreshpreviewtab)   self._refreshpreviewtab(self._qui.main_tabs.currentIndex())     def forwardFont(self, font):   if self.lexer:   self.lexer.setFont(font)     @pyqtSlot(int)   def _refreshpreviewtab(self, index):   """Generate preview text if current tab is preview"""   if self._previewtabindex() != index:   return     self._qui.preview_edit.setText(self._preview())     def _preview(self):   """Generate preview text by running patchbomb"""   def loadpatchbomb():   hglib.loadextension(self._ui, 'patchbomb')   return extensions.find('patchbomb')     def wrapui(ui):   buf = StringIO()   # TODO: common way to prepare pure ui   newui = ui.copy()   newui.setconfig('ui', 'interactive', False)   newui.setconfig('diff', 'git', False)   newui.write = lambda *args, **opts: buf.write(''.join(args))   newui.status = lambda *args, **opts: None   return newui, buf     def stripheadmsg(s):   # TODO: skip until first Content-type: line ??   return '\n'.join(s.splitlines()[3:])     ui, buf = wrapui(self._ui)   opts = self._patchbombopts(test=True)   try:   # TODO: fix hgext.patchbomb's implementation instead   if 'PAGER' in os.environ:   del os.environ['PAGER']     loadpatchbomb().patchbomb(ui, self._repo, **opts)   return stripheadmsg(hglib.tounicode(buf.getvalue()))   finally:   if 'desc' in opts:   os.unlink(opts['desc']) # TODO: don't use tempfile     def _previewtabindex(self):   """Index of preview tab"""   return self._qui.main_tabs.indexOf(self._qui.preview_tab)     @pyqtSlot()   def on_settings_button_clicked(self):   from tortoisehg.hgqt import settings   if settings.SettingsDialog(parent=self, focus='email.from').exec_():   # not use repo.configChanged because it can clobber user input   # accidentally.   self._repo.invalidateui() # force reloading config immediately   self._filldefaults()   + @pyqtSlot() + def on_selectall_button_clicked(self): + self._changesets.selectAll() + + @pyqtSlot() + def on_selectnone_button_clicked(self): + self._changesets.selectNone() +  class _ChangesetsModel(QAbstractTableModel): # TODO: use component of log viewer?   _COLUMNS = [('rev', lambda ctx: '%d:%s' % (ctx.rev(), ctx)),   ('author', lambda ctx: hglib.username(ctx.user())),   ('date', lambda ctx: util.shortdate(ctx.date())),   ('description', lambda ctx: ctx.longsummary())]     def __init__(self, repo, revs, selectedrevs, parent=None):   super(_ChangesetsModel, self).__init__(parent)   self._repo = repo   self._revs = list(reversed(sorted(revs)))   self._selectedrevs = set(selectedrevs)   self._readonly = False     @property   def revs(self):   return self._revs     @property   def selectedrevs(self):   """Return the list of selected revisions"""   return list(sorted(self._selectedrevs))     def isselectedall(self):   return len(self._revs) == len(self._selectedrevs)     def data(self, index, role):   if not index.isValid():   return QVariant()     rev = self._revs[index.row()]   if index.column() == 0 and role == Qt.CheckStateRole:   return rev in self._selectedrevs and Qt.Checked or Qt.Unchecked   if role == Qt.DisplayRole:   coldata = self._COLUMNS[index.column()][1]   return QVariant(hglib.tounicode(coldata(self._repo.changectx(rev))))     return QVariant()     def setData(self, index, value, role=Qt.EditRole):   if not index.isValid() or self._readonly:   return False     rev = self._revs[index.row()]   if index.column() == 0 and role == Qt.CheckStateRole:   origvalue = rev in self._selectedrevs   if value == Qt.Checked:   self._selectedrevs.add(rev)   else:   self._selectedrevs.remove(rev)     if origvalue != (rev in self._selectedrevs):   self.dataChanged.emit(index, index)     return True     return False     def setReadOnly(self, readonly):   self._readonly = readonly     def flags(self, index):   v = super(_ChangesetsModel, self).flags(index)   if index.column() == 0 and not self._readonly:   return Qt.ItemIsUserCheckable | v   else:   return v     def rowCount(self, parent=QModelIndex()):   if parent.isValid():   return 0 # no child   return len(self._revs)     def columnCount(self, parent=QModelIndex()):   if parent.isValid():   return 0 # no child   return len(self._COLUMNS)     def headerData(self, section, orientation, role):   if role != Qt.DisplayRole or orientation != Qt.Horizontal:   return QVariant()     return QVariant(self._COLUMNS[section][0].capitalize())   + def selectAll(self): + self._selectedrevs = set(self._revs) + self.updateAll() + + def selectNone(self): + self._selectedrevs = set() + self.updateAll() + + def updateAll(self): + first = self.createIndex(0, 0) + last = self.createIndex(len(self._revs) - 1, 0) + self.dataChanged.emit(first, last) +  def run(ui, *revs, **opts):   # TODO: same options as patchbomb   if opts.get('rev'):   if revs:   raise util.Abort(_('use only one form to specify the revision'))   revs = opts.get('rev')     # TODO: repo should be a required argument?   repo = opts.get('repo') or thgrepo.repository(ui, paths.find_root())     try:   return EmailDialog(repo, revs, outgoing=opts.get('outgoing', False),   outgoingrevs=opts.get('outgoingrevs', None))   except error.RepoLookupError, e:   qtlib.ErrorMsgBox(_('Failed to open Email dialog'),   hglib.tounicode(e.message))
 
7
8
9
10
 
11
12
13
 
357
358
359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
361
362
 
7
8
9
 
10
11
12
13
 
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
@@ -7,7 +7,7 @@
  <x>0</x>   <y>0</y>   <width>660</width> - <height>506</height> + <height>519</height>   </rect>   </property>   <property name="windowTitle"> @@ -357,6 +357,37 @@
  </property>   </widget>   </item> + <item> + <layout class="QHBoxLayout" name="selectallnone_layout"> + <item> + <widget class="QPushButton" name="selectall_button"> + <property name="text"> + <string>Select &amp;All</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="selectnone_button"> + <property name="text"> + <string>Select &amp;None</string> + </property> + </widget> + </item> + <item> + <spacer name="selectallnone_spacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item>   </layout>   </widget>   </widget>
 
545
546
547
548
549
550
551
552
553
 
 
 
 
554
555
556
 
545
546
547
 
 
 
 
548
549
550
551
552
553
554
555
556
@@ -545,12 +545,12 @@
  try:   char = s[s.index('&')+1].lower()   self.hotkeys[char] = btn - if default == i: - self.setDefaultButton(btn) - if esc == i: - self.setEscapeButton(btn)   except (ValueError, IndexError):   pass + if default == i: + self.setDefaultButton(btn) + if esc == i: + self.setEscapeButton(btn)     def run(self):   return self.exec_()
 
80
81
82
 
 
 
 
 
 
83
84
85
 
119
120
121
122
 
 
 
 
123
124
125
 
139
140
141
142
 
 
 
 
143
144
145
146
147
148
 
 
 
 
 
149
150
151
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
156
157
 
181
182
183
184
 
 
 
 
185
186
187
 
80
81
82
83
84
85
86
87
88
89
90
91
 
125
126
127
 
128
129
130
131
132
133
134
 
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
 
212
213
214
 
215
216
217
218
219
220
221
@@ -80,6 +80,12 @@
  if self.command == 'revert':   ## no backup checkbox   chk = QCheckBox(_('Do not save backup files (*.orig)')) + elif self.command == 'remove': + ## force checkbox + chk = QCheckBox(_('Force removal of modified files (--force)')) + else: + chk = None + if chk:   self.chk = chk   hbox.addWidget(chk)   @@ -119,7 +125,10 @@
  stwidget.loadSettings(s, 'quickop')   self.restoreGeometry(s.value('quickop/geom').toByteArray())   if hasattr(self, 'chk'): - self.chk.setChecked(s.value('quickop/nobackup', True).toBool()) + if self.command == 'revert': + self.chk.setChecked(s.value('quickop/nobackup', True).toBool()) + elif self.command == 'remove': + self.chk.setChecked(s.value('quickop/forceremove', False).toBool())   self.stwidget = stwidget   self.stwidget.refreshWctx()   QShortcut(QKeySequence('Ctrl+Return'), self, self.accept) @@ -139,19 +148,41 @@
  def accept(self):   cmdline = [self.command]   if hasattr(self, 'chk') and self.chk.isChecked(): - cmdline.append('--no-backup') + if self.command == 'revert': + cmdline.append('--no-backup') + elif self.command == 'remove': + cmdline.append('--force')   files = self.stwidget.getChecked()   if not files:   qtlib.WarningMsgBox(_('No files selected'),   _('No operation to perform'),   parent=self)   return + self.repo.bfstatus = True + self.repo.lfstatus = True + repostate = self.repo.status() + self.repo.bfstatus = False + self.repo.lfstatus = False   if self.command == 'remove': - self.repo.bfstatus = True - self.repo.lfstatus = True - repostate = self.repo.status() - self.repo.bfstatus = False - self.repo.lfstatus = False + if not self.chk.isChecked(): + modified = repostate[0] + selmodified = [] + for wfile in files: + if wfile in modified: + selmodified.append(wfile) + if selmodified: + prompt = qtlib.CustomPrompt(_('Confirm Remove'), + _('You have selected one or more files that have been ' + 'modified. By default, these files will not be ' + 'removed. What would you like to do?'), self, + (_('Remove &Unmodified Files'), + _('Remove &All Selected Files'), _('Cancel')), + 0, 2, selmodified) + ret = prompt.run() + if ret == 1: + cmdline.append('--force') + elif ret == 2: + return   unknown, ignored = repostate[4:6]   for wfile in files:   if wfile in unknown or wfile in ignored: @@ -181,7 +212,10 @@
  self.stwidget.saveSettings(s, 'quickop')   s.setValue('quickop/geom', self.saveGeometry())   if hasattr(self, 'chk'): - s.setValue('quickop/nobackup', self.chk.isChecked()) + if self.command == 'revert': + s.setValue('quickop/nobackup', self.chk.isChecked()) + elif self.command == 'remove': + s.setValue('quickop/forceremove', self.chk.isChecked())   QDialog.reject(self)     def addLfiles(self):
 
44
45
46
 
 
47
48
49
 
116
117
118
 
 
119
120
121
 
296
297
298
 
299
300
301
302
303
304
 
 
 
305
306
307
 
339
340
341
 
 
342
343
344
 
363
364
365
 
 
 
366
367
368
 
741
742
743
 
744
745
746
 
756
757
758
759
760
761
762
 
44
45
46
47
48
49
50
51
 
118
119
120
121
122
123
124
125
 
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
 
347
348
349
350
351
352
353
354
 
373
374
375
376
377
378
379
380
381
 
754
755
756
757
758
759
760
 
770
771
772
 
773
774
775
@@ -44,6 +44,8 @@
  output = pyqtSignal(QString, QString)   progress = pyqtSignal(QString, object, QString, QString, object)   makeLogVisible = pyqtSignal(bool) + beginSuppressPrompt = pyqtSignal() + endSuppressPrompt = pyqtSignal()     repoChanged = pyqtSignal(QString)   @@ -116,6 +118,8 @@
  self.runner.output.connect(self.output)   self.runner.progress.connect(self.progress)   self.runner.makeLogVisible.connect(self.makeLogVisible) + self.runner.commandStarted.connect(self.beginSuppressPrompt) + self.runner.commandFinished.connect(self.endSuppressPrompt)   self.runner.commandFinished.connect(self.onCommandFinished)     # Select the widget chosen by the user @@ -296,12 +300,16 @@
  w.setFocus() # to handle key press by InfoBar   return w   + @pyqtSlot()   def clearInfoBar(self, priority=None):   """Close current infobar if available; return True if got empty"""   it = self._infobarlayout.itemAt(0)   if not it:   return True   if priority is None or it.widget().infobartype <= priority: + # removes current infobar explicitly, because close() seems to + # delay deletion until next eventloop. + self._infobarlayout.removeItem(it)   it.widget().close()   return True   else: @@ -339,6 +347,8 @@
  cw.output.connect(self.output)   cw.progress.connect(self.progress)   cw.makeLogVisible.connect(self.makeLogVisible) + cw.beginSuppressPrompt.connect(self.beginSuppressPrompt) + cw.endSuppressPrompt.connect(self.endSuppressPrompt)   cw.linkActivated.connect(self._openLink)   cw.showMessage.connect(self.showMessage)   QTimer.singleShot(0, cw.reload) @@ -363,6 +373,9 @@
  sw.output.connect(self._showOutputOnInfoBar)   sw.progress.connect(self.progress)   sw.makeLogVisible.connect(self.makeLogVisible) + sw.beginSuppressPrompt.connect(self.beginSuppressPrompt) + sw.endSuppressPrompt.connect(self.endSuppressPrompt) + sw.syncStarted.connect(self.clearInfoBar)   sw.outgoingNodes.connect(self.setOutgoingNodes)   sw.showMessage.connect(self.showMessage)   sw.showMessage.connect(self._showMessageOnInfoBar) @@ -741,6 +754,7 @@
    def onRevisionClicked(self, rev):   'User clicked on a repoview row' + self.clearInfoBar(qtlib.InfoBar.INFO)   tw = self.taskTabsWidget   cw = tw.currentWidget()   if not cw.canswitch(): @@ -756,7 +770,6 @@
  def onRevisionSelected(self, rev):   'View selection changed, could be a reload'   self.showMessage('') - self.clearInfoBar(qtlib.InfoBar.INFO)   if self.repomodel.graph is None:   return   try:
 
36
37
38
39
 
 
40
41
42
 
51
52
53
 
54
55
56
 
60
61
62
 
 
63
64
65
 
287
288
289
 
290
 
291
292
293
 
294
 
 
295
296
297
 
649
650
651
 
652
653
654
 
705
706
707
 
 
 
 
708
709
710
 
752
753
754
 
755
756
757
 
787
788
789
 
790
791
792
 
825
826
827
 
828
829
830
 
898
899
900
 
 
901
902
903
904
905
906
907
 
908
909
910
 
916
917
918
 
 
 
 
 
 
 
 
 
 
 
 
919
920
921
 
923
924
925
926
 
 
927
928
929
 
1155
1156
1157
1158
 
1159
1160
1161
 
36
37
38
 
39
40
41
42
43
 
52
53
54
55
56
57
58
 
62
63
64
65
66
67
68
69
 
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
 
658
659
660
661
662
663
664
 
715
716
717
718
719
720
721
722
723
724
 
766
767
768
769
770
771
772
 
802
803
804
805
806
807
808
 
841
842
843
844
845
846
847
 
915
916
917
918
919
920
921
922
923
924
925
 
926
927
928
929
 
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
 
954
955
956
 
957
958
959
960
961
 
1187
1188
1189
 
1190
1191
1192
1193
@@ -36,7 +36,8 @@
  port = m.group(3)   folder = m.group(5) or '.'   else: - qtlib.WarningMsgBox(_('Malformed ssh URL'), hglib.tounicode(path)) + qtlib.WarningMsgBox(_('Malformed ssh URL'), hglib.tounicode(path), + parent=self)   host, port, folder = '', '', ''   elif path.startswith(('http://', 'https://', 'svn+https://')):   snpaqf = urlparse.urlparse(path) @@ -51,6 +52,7 @@
  return user, host, port, folder, passwd, scheme    class SyncWidget(QWidget, qtlib.TaskWidget): + syncStarted = pyqtSignal() # incoming/outgoing/pull/push started   outgoingNodes = pyqtSignal(object)   incomingBundle = pyqtSignal(QString)   showMessage = pyqtSignal(unicode) @@ -60,6 +62,8 @@
  output = pyqtSignal(QString, QString)   progress = pyqtSignal(QString, object, QString, QString, object)   makeLogVisible = pyqtSignal(bool) + beginSuppressPrompt = pyqtSignal() + endSuppressPrompt = pyqtSignal()   showBusyIcon = pyqtSignal(QString)   hideBusyIcon = pyqtSignal(QString)   @@ -287,11 +291,16 @@
  self.optionsbutton.pressed.connect(self.editOptions)     cmd = cmdui.Widget(not self.embedded, True, self) + cmd.commandStarted.connect(self.beginSuppressPrompt)   cmd.commandStarted.connect(self.commandStarted) + cmd.commandFinished.connect(self.endSuppressPrompt)   cmd.commandFinished.connect(self.commandFinished)   cmd.makeLogVisible.connect(self.makeLogVisible)   cmd.output.connect(self.output) + cmd.output.connect(self.outputHook)   cmd.progress.connect(self.progress) + if not self.embedded: + self.showMessage.connect(cmd.stbar.showMessage)     bottomlayout.addWidget(cmd)   cmd.setVisible(False) @@ -649,6 +658,7 @@
  def run(self, cmdline, details):   if self.cmd.core.running():   return + self.lastcmdline = list(cmdline)   for name in list(details) + ['remotecmd']:   val = self.opts.get(name)   if not val: @@ -705,6 +715,10 @@
  self.repo.incrementBusyCount()   self.cmd.run(cmdline, display=display, useproc='p4://' in cururl)   + def outputHook(self, msg, label): + if '\'hg push --new-branch\'' in msg: + self.needNewBranch = True +   ##   ## Workbench toolbar buttons   ## @@ -752,6 +766,7 @@
  ##     def inclicked(self): + self.syncStarted.emit()   url = self.currentUrl(True)   urlu = hglib.tounicode(url)   self.showMessage.emit(_('Getting incoming changesets from %s...') % urlu) @@ -787,6 +802,7 @@
  self.run(cmdline, ('force', 'branch', 'rev', 'subrepos'))     def pullclicked(self): + self.syncStarted.emit()   url = self.currentUrl(True)   urlu = hglib.tounicode(url)   def finished(ret, output): @@ -825,6 +841,7 @@
  self.run(cmdline, ('force', 'branch', 'rev', 'bookmark'))     def outclicked(self): + self.syncStarted.emit()   url = self.currentUrl(True)   urlu = hglib.tounicode(url)   self.showMessage.emit(_('Finding outgoing changesets to %s...') % urlu) @@ -898,13 +915,15 @@
  self.run(['--repository', self.repo.root, 'p4pending', '--verbose'], ())     def pushclicked(self, confirm, rev=None, branch=None): + validopts = ('force', 'new-branch', 'branch', 'rev', 'bookmark') + self.syncStarted.emit()   url = self.currentUrl(True)   urlu = hglib.tounicode(url)   if (not hg.islocal(self.currentUrl(False)) and confirm   and not self.targetcheckbox.isChecked()):   r = qtlib.QuestionMsgBox(_('Confirm Push to remote Repository'),   _('Push to remote repository\n%s\n?') - % urlu) + % urlu, parent=self)   if not r:   self.showMessage.emit(_('Push to %s aborted') % urlu)   self.pushCompleted.emit() @@ -916,6 +935,18 @@
  self.showMessage.emit(_('Push to %s completed') % urlu)   else:   self.showMessage.emit(_('Push to %s aborted, ret %d') % (urlu, ret)) + if self.needNewBranch: + r = qtlib.QuestionMsgBox(_('Confirm New Branch'), + _('One or more of the changesets that you ' + 'are attempting to push involve the ' + 'creation of a new branch. Do you want ' + 'to create a new branch in the remote ' + 'repository?'), parent=self) + if r: + cmdline = self.lastcmdline + cmdline.extend(['--new-branch']) + self.run(cmdline, validopts) + return   self.pushCompleted.emit()   self.finishfunc = finished   cmdline = ['--repository', self.repo.root, 'push'] @@ -923,7 +954,8 @@
  cmdline.extend(['--rev', str(rev)])   if branch:   cmdline.extend(['--branch', branch]) - self.run(cmdline, ('force', 'new-branch', 'branch', 'rev', 'bookmark')) + self.needNewBranch = False + self.run(cmdline, validopts)     def postpullclicked(self):   dlg = PostPullDialog(self.repo, self) @@ -1155,7 +1187,7 @@
  path = self.origurl   if alias in cfg['paths']:   if not qtlib.QuestionMsgBox(_('Confirm URL replace'), - _('%s already exists, replace URL?') % alias): + _('%s already exists, replace URL?') % alias, parent=self):   return   cfg.set('paths', alias, path)   self.repo.incrementBusyCount()
 
309
310
311
312
313
 
 
314
315
316
317
 
318
319
320
 
309
310
311
 
 
312
313
314
315
316
 
317
318
319
320
@@ -309,12 +309,12 @@
  from tortoisehg.hgqt.guess import DetectRenameDialog   dlg = DetectRenameDialog(repo, parent, *files)   def matched(): - ret = True - ret = False + ret[0] = True + ret = [False]   dlg.matchAccepted.connect(matched)   dlg.finished.connect(dlg.deleteLater)   dlg.exec_() - return ret + return ret[0]    def ignore(parent, ui, repo, files):   from tortoisehg.hgqt.hgignore import HgignoreDialog
 
644
645
646
 
 
647
648
649
 
644
645
646
647
648
649
650
651
@@ -644,6 +644,8 @@
  self.statusbar.progress(tp, p, i, u, tl, repo.root))   rw.output.connect(self.log.output)   rw.makeLogVisible.connect(self.log.setShown) + rw.beginSuppressPrompt.connect(self.log.beginSuppressPrompt) + rw.endSuppressPrompt.connect(self.log.endSuppressPrompt)   rw.revisionSelected.connect(self.updateHistoryActions)   rw.repoLinkClicked.connect(self.openLinkedRepo)   rw.taskTabsWidget.currentChanged.connect(self.updateTaskViewMenu)