Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

visdiff: option to use the extdiff extension instead of the built-in visdiff

Changeset 46ad593e6990

Parent 1e7a7033f60a

by Sune Foldager

Changes to 3 files · Browse files at 46ad593e6990 Showing diff from parent 1e7a7033f60a Diff from another changeset...

Change 1 of 1 Show Entire File hggtk/​gdialog.py Stacked
 
361
362
363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
365
366
367
368
369
370
371
 
372
373
374
 
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
@@ -361,14 +361,48 @@
    return True, textout   + def _do_diff(self, patterns, options, modal=False): + import visdiff + + if self.ui.configbool('tortoisehg', 'vdiffnowin'): + from hgext import extdiff + tools = visdiff.readtools(self.ui) + preferred = self.ui.config('tortoisehg', 'vdiff', 'vdiff') + if not preferred or preferred not in tools: + Prompt(_('No visual diff configured'), + _('Please select a visual diff application.'), self).run() + dlg = ConfigDialog(self.repo.root, False) + dlg.show_all() + dlg.focus_field('tortoisehg.vdiff') + dlg.run() + dlg.hide() + self.ui = ui.ui() + self._parse_config() + return + + file = len(patterns) == 1 and patterns[0] or '' + diffcmd, diffopts = tools[preferred] + opts = {'change': options.get('change')} + if not opts['change']: + opts['rev'] = options.get('rev') + + def dodiff(): + extdiff.dodiff(self.ui, self.repo, diffcmd, diffopts, + [self.repo.wjoin(file)], opts) + + thread = threading.Thread(target=dodiff, name='diff:' + file) + thread.setDaemon(True) + thread.start() + + else: + dialog = visdiff.FileSelectionDialog(patterns, options) + dialog.show_all() + if modal: + dialog.run() + dialog.hide() +   def _diff_file(self, stat, file): - from visdiff import FileSelectionDialog - if file: - pats = [file] - else: - pats = [] - dialog = FileSelectionDialog(pats, self.opts) - dialog.show_all() + self._do_diff(file and [file] or [], self.opts)     def _view_file(self, stat, file, force_left=False):   import atexit
Change 1 of 1 Show Entire File hggtk/​history.py Stacked
 
498
499
500
501
502
503
504
505
506
 
507
508
509
510
511
512
513
514
515
 
516
517
518
 
498
499
500
 
501
 
 
 
 
502
503
504
 
505
506
 
 
 
 
507
508
509
510
@@ -498,21 +498,13 @@
  dlg.hide()     def _vdiff_change(self, menuitem, pats=[]): - from visdiff import FileSelectionDialog   rev = self.currow[treemodel.REVID] - dialog = FileSelectionDialog(pats, {'change' : rev}) - dialog.show_all() - dialog.run() - dialog.hide() + self._do_diff(pats, {'change' : rev}, modal=True)     def _vdiff_local(self, menuitem, pats=[]): - from visdiff import FileSelectionDialog   rev = self.currow[treemodel.REVID]   opts = {'rev' : ["%s:." % rev]} - dialog = FileSelectionDialog(pats, opts) - dialog.show_all() - dialog.run() - dialog.hide() + self._do_diff(pats, opts, modal=True)     def _diff_revs(self, menuitem):   from status import GStatus
Change 1 of 3 Show Entire File hggtk/​visdiff.py Stacked
 
104
105
106
107
 
108
109
110
 
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
 
258
259
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
262
263
 
104
105
106
 
107
108
109
110
 
142
143
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
146
147
 
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
@@ -104,7 +104,7 @@
  _('No repository found here'), None).run()   return   - tools = self.readtools(repo.ui) + tools = readtools(repo.ui)   preferred = repo.ui.config('tortoisehg', 'vdiff', 'vdiff')   if preferred and preferred in tools:   if len(tools) > 1: @@ -142,28 +142,6 @@
  if sel in tools:   self.diffpath, self.diffopts = tools[sel]   - def readtools(self, ui): - tools = {} - for cmd, path in ui.configitems('extdiff'): - if cmd.startswith('cmd.'): - cmd = cmd[4:] - if not path: - path = cmd - diffopts = ui.config('extdiff', 'opts.' + cmd, '') - diffopts = diffopts and [diffopts] or [] - tools[cmd] = [path, diffopts] - elif cmd.startswith('opts.'): - continue - else: - # command = path opts - if path: - diffopts = shlex.split(path) - path = diffopts.pop(0) - else: - path, diffopts = cmd, [] - tools[cmd] = [path, diffopts] - return tools -   def find_files(self, repo, pats, opts, model):   revs = opts.get('rev')   change = opts.get('change') @@ -258,6 +236,28 @@
  Prompt(_('Tool launch failure'),   _('%s : %s') % (self.diffpath, str(e)), None).run()   +def readtools(ui): + tools = {} + for cmd, path in ui.configitems('extdiff'): + if cmd.startswith('cmd.'): + cmd = cmd[4:] + if not path: + path = cmd + diffopts = ui.config('extdiff', 'opts.' + cmd, '') + diffopts = diffopts and [diffopts] or [] + tools[cmd] = [path, diffopts] + elif cmd.startswith('opts.'): + continue + else: + # command = path opts + if path: + diffopts = shlex.split(path) + path = diffopts.pop(0) + else: + path, diffopts = cmd, [] + tools[cmd] = [path, diffopts] + return tools +  def run(ui, *pats, **opts):   root = rootpath()   canonpats = []