Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

visdiff: move readtools() to hglib.difftools() for sharing

Use this function in thgconfig, so auto-detected merge tools show up as
available for visual diff use.

Changeset a598edc9be56

Parent 24c12bb59d95

by Steve Borho

Changes to 3 files · Browse files at a598edc9be56 Showing diff from parent 24c12bb59d95 Diff from another changeset...

 
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
 
 
1013
1014
1015
 
1002
1003
1004
 
 
 
 
 
 
 
 
1005
1006
1007
1008
1009
@@ -1002,14 +1002,8 @@
  curvalue = self.get_ini_config(cpath)     if cpath == 'tortoisehg.vdiff': - # Special case, add extdiff.cmd.* to possible values - for name, value in self.ui.configitems('extdiff'): - if name.startswith('cmd.'): - if name[4:] not in values: - values.append(name[4:]) - elif not name.startswith('opts.'): - if name not in values: - values.append(name) + tools = hglib.difftools(self.ui) + values.extend(tools.keys())   elif cpath == 'ui.merge':   # Special case, add [merge-tools] to possible values   hglib.mergetools(self.ui, values)
 
8
9
10
11
12
13
14
 
102
103
104
105
 
106
107
108
 
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
 
379
380
381
382
 
383
384
385
 
8
9
10
 
11
12
13
 
101
102
103
 
104
105
106
107
 
339
340
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
343
344
 
349
350
351
 
352
353
354
355
@@ -8,7 +8,6 @@
 import gtk  import gobject  import os -import shlex  import subprocess  import shutil  import tempfile @@ -102,7 +101,7 @@
  _('No repository found here'), None).run()   return   - tools = readtools(repo.ui) + tools = hglib.difftools(repo.ui)   preferred = repo.ui.config('tortoisehg', 'vdiff', 'vdiff')   if preferred and preferred in tools:   if len(tools) > 1: @@ -340,35 +339,6 @@
  gdialog.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] - mergetools = [] - hglib.mergetools(ui, mergetools) - for t in mergetools: - if t.startswith('internal:'): - continue - opts = ui.config('merge-tools', t + '.diffargs', '') - tools[t] = [t, shlex.split(opts)] - return tools -  def rawextdiff(ui, *pats, **opts):   'launch raw extdiff command, block until finish'   from hgext import extdiff @@ -379,7 +349,7 @@
  # hgtk should catch this earlier   ui.warn(_('No repository found here') + '\n')   return - tools = readtools(ui) + tools = hglib.difftools(repo.ui)   preferred = ui.config('tortoisehg', 'vdiff', 'vdiff')   try:   diffcmd, diffopts = tools[preferred]
 
7
8
9
10
11
 
12
13
14
15
 
 
16
17
18
 
191
192
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
195
196
 
268
269
270
271
 
 
 
7
8
9
 
 
10
11
12
 
 
13
14
15
16
17
 
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
 
297
298
299
 
 
300
@@ -7,12 +7,11 @@
   import os  import sys -import traceback -import shlib +import shlex  import time   -from mercurial import hg, ui, util, extensions, commands, hook, match -from mercurial import dispatch, encoding, templatefilters, bundlerepo, url +from mercurial import ui, util, extensions, match, bundlerepo, url +from mercurial import dispatch, encoding, templatefilters    _encoding = encoding.encoding  _encodingmode = encoding.encodingmode @@ -191,6 +190,36 @@
  return values     +def difftools(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] + mt = [] + mergetools(ui, mt) + for t in mt: + if t.startswith('internal:'): + continue + opts = ui.config('merge-tools', t + '.diffargs', '') + tools[t] = [t, shlex.split(opts)] + return tools + +  def hgcmd_toq(q, *args):   '''   Run an hg command in a background thread, pipe all output to a Queue @@ -268,4 +297,4 @@
  if len(parents) > 1:   return False   - return rev == parents[0].node() \ No newline at end of file
+ return rev == parents[0].node()