Changeset 46ad593e6990…
Parent 1e7a7033f60a…
by
Changes to 3 files · Browse files at 46ad593e6990 Showing diff from parent 1e7a7033f60a Diff from another changeset...
@@ -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
|
@@ -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
|
@@ -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 = []
|
Loading...