Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

settings: support for configuring IBugTraqProvider plugin

Changeset b38306779932

Parent a80c4a9d1ca0

by Lloyd Markle

Changes to one file · Browse files at b38306779932 Showing diff from parent a80c4a9d1ca0 Diff from another changeset...

 
13
14
15
 
 
16
17
18
 
198
199
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
202
203
 
234
235
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
238
239
 
247
248
249
250
 
 
251
252
253
 
 
254
255
256
257
258
259
 
 
 
 
 
 
 
 
260
261
262
 
551
552
553
 
 
 
 
 
 
 
554
555
556
 
849
850
851
852
 
853
854
855
 
862
863
864
865
866
 
 
 
 
 
 
 
 
 
867
868
869
 
13
14
15
16
17
18
19
20
 
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
 
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
 
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
 
639
640
641
642
643
644
645
646
647
648
649
650
651
 
944
945
946
 
947
948
949
950
 
957
958
959
 
960
961
962
963
964
965
966
967
968
969
970
971
972
@@ -13,6 +13,8 @@
 from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt import qtlib, qscilib, thgrepo   +from tortoisehg.hgtk import bugtraq +  from PyQt4.QtCore import *  from PyQt4.QtGui import *   @@ -198,6 +200,66 @@
  return self.value() != self.curvalue     +class BugTraqConfigureEntry(QPushButton): + def __init__(self, parent=None, **opts): + QPushButton.__init__(self, parent, toolTip=opts['tooltip']) + + self.opts = opts + self.curvalue = None + self.options = None + + self.tracker = None + self.master = None + self.setText(opts['label']) + self.clicked.connect(self.on_clicked) + + def on_clicked(self, checked): + parameters = self.options + self.options = self.tracker.show_options_dialog(parameters) + + def master_updated(self): + self.setEnabled(False) + if self.master == None: + return + if self.master.value() == None: + return + if len(self.master.value()) == 0: + return + + try: + setting = self.master.value().split(' ', 1) + trackerid = setting[0] + name = setting[1] + self.tracker = bugtraq.BugTraq(trackerid) + except: + # failed to load bugtraq module or parse the setting: + # swallow the error and leave the widget disabled + return + + try: + self.setEnabled(self.tracker.has_options()) + except Exception, e: + qtlib.ErrorMsgBox(_('Issue Tracker'), + _('Failed to load issue tracker: \'%s\': %s. ' + % (name, e)), + parent=self) + + ## common APIs for all edit widgets + def setValue(self, curvalue): + if self.master == None: + self.master = self.opts['master'] + self.master.currentIndexChanged.connect(self.master_updated) + self.master_updated() + self.curvalue = curvalue + self.options = curvalue + + def value(self): + return self.options + + def isDirty(self): + return self.value() != self.curvalue + +  def genEditCombo(opts, defaults=[]):   opts['canedit'] = True   opts['defaults'] = defaults @@ -234,6 +296,22 @@
 def genFontEdit(opts):   return FontEntry(**opts)   +def genBugTraqEdit(opts): + return BugTraqConfigureEntry(**opts) + +def findIssueTrackerPlugins(): + plugins = bugtraq.get_issue_plugins_with_names() + names = [("%s %s" % (key[0], key[1])) for key in plugins] + return names + +def issuePluginVisible(): + try: + # quick test to see if we're able to load the bugtraq module + test = bugtraq.BugTraq('') + return True + except: + return False +  def findDiffTools():   return hglib.difftools(ui.ui())   @@ -247,16 +325,26 @@
 class _fi(object):   """Information of each field"""   __slots__ = ('label', 'cpath', 'values', 'tooltip', - 'restartneeded', 'globalonly') + 'restartneeded', 'globalonly', + 'master', 'visible')     def __init__(self, label, cpath, values, tooltip, - restartneeded=False, globalonly=False): + restartneeded=False, globalonly=False, + master=None, visible=None):   self.label = label   self.cpath = cpath   self.values = values   self.tooltip = tooltip   self.restartneeded = restartneeded   self.globalonly = globalonly + self.master = master + self.visible = visible + + def isVisible(self): + if self.visible == None: + return True + else: + return self.visible()    INFO = (  ({'name': 'general', 'label': 'TortoiseHg', 'icon': 'thg_logo'}, ( @@ -551,6 +639,13 @@
  'while {1} refers to the first group and so on. If no {n} tokens'   'are found in issue.link, the entire matched string is appended '   'instead.')), + _fi(_('Issue Tracker Plugin'), 'tortoisehg.issue.bugtraqplugin', + (genDeferredCombo, findIssueTrackerPlugins), + _('Configures a COM IBugTraqProvider or IBugTrackProvider2 issue ' + 'tracking plugin.'), visible=issuePluginVisible), + _fi(_('Configure Issue Tracker'), 'tortoisehg.issue.bugtraqparameters', genBugTraqEdit, + _('Configure the selected COM Bug Tracker plugin.'), + master='tortoisehg.issue.bugtraqplugin', visible=issuePluginVisible),   )),    ({'name': 'reviewboard', 'label': _('Review Board'), 'icon': 'reviewboard'}, ( @@ -849,7 +944,7 @@
    for e in info:   opts = {'label': e.label, 'cpath': e.cpath, 'tooltip': e.tooltip, - 'settings':self.settings} + 'master': e.master, 'settings':self.settings}   if isinstance(e.values, tuple):   func = e.values[0]   w = func(opts, e.values[1]) @@ -862,8 +957,16 @@
  lbl = QLabel(e.label)   lbl.installEventFilter(self)   lbl.setToolTip(e.tooltip) - form.addRow(lbl, w)   widgets.append(w) + if e.isVisible(): + form.addRow(lbl, w) + + # assign the master to widgets that have a master + for w in widgets: + if w.opts['master'] != None: + for dep in widgets: + if dep.opts['cpath'] == w.opts['master']: + w.opts['master'] = dep   return widgets     def fillExtensionsFrame(self):