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

visdiff: add a tool selection combo

Changeset 083e2008c3c7

Parent faf4e5a2f160

by Steve Borho

Changes to one file · Browse files at 083e2008c3c7 Showing diff from parent faf4e5a2f160 Diff from another changeset...

 
313
314
315
 
316
317
318
 
351
352
353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
355
356
 
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
 
443
444
445
446
 
447
448
449
450
451
 
 
 
 
452
453
454
 
461
462
463
464
465
466
467
 
468
469
 
 
 
 
 
470
471
472
 
474
475
476
477
 
478
479
 
480
481
482
 
313
314
315
316
317
318
319
 
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
 
393
394
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
397
398
 
445
446
447
 
448
449
 
 
 
 
450
451
452
453
454
455
456
 
463
464
465
 
 
 
 
466
467
 
468
469
470
471
472
473
474
475
 
477
478
479
 
480
481
 
482
483
484
485
@@ -313,6 +313,7 @@
  'Initialize the Dialog'   QtGui.QDialog.__init__(self)   self.setWindowTitle(_('Visual Diffs')) + self.curFile = None     # TODO: Connect CTRL-D to row activation   #qtlib.set_tortoise_icon(self, 'menushowchanged.ico') @@ -351,6 +352,25 @@
  tools = hglib.difftools(repo.ui)   preferred = besttool(repo.ui, tools)   self.diffpath, self.diffopts, self.mergeopts = tools[preferred] + self.tools = tools + + if len(tools) > 1: + combo = QtGui.QComboBox() + layout.addWidget(combo) + for i, name in enumerate(tools.iterkeys()): + combo.addItem(name) + if name == preferred: + defrow = i + combo.setCurrentIndex(defrow) + patterns = repo.ui.configitems('diff-patterns') + patterns = [(p, t) for p,t in patterns if t in tools] + + callable = lambda row: self.fileselect(row, repo, combo, + patterns, preferred) + self.connect(list, QtCore.SIGNAL('currentRowChanged(int)'), + callable) + self.connect(combo, QtCore.SIGNAL('currentIndexChanged(QString)'), + self.toolSelect)     BB = QtGui.QDialogButtonBox   bb = BB() @@ -373,24 +393,6 @@
    self.updateDiffButtons(preferred)   - ''' - if len(tools) > 1: - combo = gtk.combo_box_new_text() - for i, name in enumerate(tools.iterkeys()): - combo.append_text(name) - if name == preferred: - defrow = i - combo.set_active(defrow) - combo.connect('changed', self.toolselect, tools) - hbox.pack_start(combo, False, False, 2) - - patterns = repo.ui.configitems('diff-patterns') - patterns = [(p, t) for p,t in patterns if t in tools] - filesel = treeview.get_selection() - filesel.connect('changed', self.fileselect, repo, combo, tools, - patterns, preferred) - ''' -   callable = lambda: self.fillmodel(repo, sa, sb)   QtCore.QTimer.singleShot(0, callable)   @@ -443,12 +445,12 @@
  row = QtCore.QString('%s %s' % (status, hglib.tounicode(f)))   self.list.addItem(row)   - def toolselect(self, combo, tools): + def toolSelect(self, tool):   'user selected a tool from the tool combo' - #sel = combo.get_active_text() - #if sel in tools: - # self.diffpath, self.diffopts, self.mergeopts = tools[sel] - # self.updateDiffButtons(sel) + tool = hglib.fromunicode(tool) + assert tool in self.tools + self.diffpath, self.diffopts, self.mergeopts = self.tools[tool] + self.updateDiffButtons(tool)     def updateDiffButtons(self, tool):   if hasattr(self, 'p1button'): @@ -461,12 +463,13 @@
  d2 = self.ui.configbool('merge-tools', tool + '.dirdiff')   self.dbutton.setEnabled(d2)   - def currentItemChanges(self, list, item): - pass # connect to below - - def fileselect(self, selection, repo, combo, tools, patterns, preferred): + def fileselect(self, row, repo, combo, patterns, preferred):   'user selected a file, pick an appropriate tool from combo' - fname = self.list.selectedItem().text()[2:] + fname = self.list.item(row).text()[2:] + fname = hglib.fromunicode(fname) + if self.curFile == fname: + return + self.curFile = fname   for pat, tool in patterns:   mf = match.match(repo.root, '', [pat])   if mf(fname): @@ -474,9 +477,9 @@
  break   else:   selected = preferred - for i, name in enumerate(tools.iterkeys()): + for i, name in enumerate(self.tools.iterkeys()):   if name == selected: - combo.set_active(i) + combo.setCurrentIndex(i)     def closeEvent(self, event):   while self.tmproot: