##// END OF EJS Templates
mdiff: add a config option to use xdiff algorithm...
Jun Wu -
r36694:c6a61298 default
parent child Browse files
Show More
@@ -577,6 +577,9 b" coreconfigitem('experimental', 'update.a"
577 coreconfigitem('experimental', 'sshpeer.advertise-v2',
577 coreconfigitem('experimental', 'sshpeer.advertise-v2',
578 default=False,
578 default=False,
579 )
579 )
580 coreconfigitem('experimental', 'xdiff',
581 default=False,
582 )
580 coreconfigitem('extensions', '.*',
583 coreconfigitem('extensions', '.*',
581 default=None,
584 default=None,
582 generic=True,
585 generic=True,
@@ -63,6 +63,7 b' class diffopts(object):'
63 'upgrade': False,
63 'upgrade': False,
64 'showsimilarity': False,
64 'showsimilarity': False,
65 'worddiff': False,
65 'worddiff': False,
66 'xdiff': False,
66 }
67 }
67
68
68 def __init__(self, **opts):
69 def __init__(self, **opts):
@@ -188,6 +189,13 b' def blocksinrange(blocks, rangeb):'
188 raise error.Abort(_('line range exceeds file size'))
189 raise error.Abort(_('line range exceeds file size'))
189 return filteredblocks, (lba, uba)
190 return filteredblocks, (lba, uba)
190
191
192 def chooseblocksfunc(opts=None):
193 if (opts is None or not opts.xdiff
194 or not util.safehasattr(bdiff, 'xdiffblocks')):
195 return bdiff.blocks
196 else:
197 return bdiff.xdiffblocks
198
191 def allblocks(text1, text2, opts=None, lines1=None, lines2=None):
199 def allblocks(text1, text2, opts=None, lines1=None, lines2=None):
192 """Return (block, type) tuples, where block is an mdiff.blocks
200 """Return (block, type) tuples, where block is an mdiff.blocks
193 line entry. type is '=' for blocks matching exactly one another
201 line entry. type is '=' for blocks matching exactly one another
@@ -201,7 +209,7 b' def allblocks(text1, text2, opts=None, l'
201 if opts.ignorews or opts.ignorewsamount or opts.ignorewseol:
209 if opts.ignorews or opts.ignorewsamount or opts.ignorewseol:
202 text1 = wsclean(opts, text1, False)
210 text1 = wsclean(opts, text1, False)
203 text2 = wsclean(opts, text2, False)
211 text2 = wsclean(opts, text2, False)
204 diff = bdiff.blocks(text1, text2)
212 diff = chooseblocksfunc(opts)(text1, text2)
205 for i, s1 in enumerate(diff):
213 for i, s1 in enumerate(diff):
206 # The first match is special.
214 # The first match is special.
207 # we've either found a match starting at line 0 or a match later
215 # we've either found a match starting at line 0 or a match later
@@ -2256,6 +2256,7 b' def difffeatureopts(ui, opts=None, untru'
2256 'context': get('unified', getter=ui.config),
2256 'context': get('unified', getter=ui.config),
2257 }
2257 }
2258 buildopts['worddiff'] = ui.configbool('experimental', 'worddiff')
2258 buildopts['worddiff'] = ui.configbool('experimental', 'worddiff')
2259 buildopts['xdiff'] = ui.configbool('experimental', 'xdiff')
2259
2260
2260 if git:
2261 if git:
2261 buildopts['git'] = get('git')
2262 buildopts['git'] = get('git')
General Comments 0
You need to be logged in to leave comments. Login now