# HG changeset patch # User Gregory Szorc # Date 1520121343 18000 # Node ID d382344c69aa89f2c57e762e157997a29d018b89 # Parent 04d64163039a748b5266a7e28729d3f6bb2a490e perf: teach perfbdiff to call blocks() and to use xdiff Differential Revision: https://phab.mercurial-scm.org/D2624 diff -r 04d64163039a -r d382344c69aa contrib/perf.py --- a/contrib/perf.py Tue Mar 06 19:31:17 2018 -0800 +++ b/contrib/perf.py Sat Mar 03 18:55:43 2018 -0500 @@ -939,11 +939,16 @@ timer(d) fm.end() -def _bdiffworker(q, ready, done): +def _bdiffworker(q, blocks, xdiff, ready, done): while not done.is_set(): pair = q.get() while pair is not None: - mdiff.textdiff(*pair) + if xdiff: + mdiff.bdiff.xdiffblocks(*pair) + elif blocks: + mdiff.bdiff.blocks(*pair) + else: + mdiff.textdiff(*pair) q.task_done() pair = q.get() q.task_done() # for the None one @@ -954,6 +959,8 @@ ('', 'count', 1, 'number of revisions to test (when using --startrev)'), ('', 'alldata', False, 'test bdiffs for all associated revisions'), ('', 'threads', 0, 'number of thread to use (disable with 0)'), + ('', 'blocks', False, 'test computing diffs into blocks'), + ('', 'xdiff', False, 'use xdiff algorithm'), ], '-c|-m|FILE REV') @@ -969,6 +976,11 @@ measure bdiffs for all changes related to that changeset (manifest and filelogs). """ + opts = pycompat.byteskwargs(opts) + + if opts['xdiff'] and not opts['blocks']: + raise error.CommandError('perfbdiff', '--xdiff requires --blocks') + if opts['alldata']: opts['changelog'] = True @@ -977,6 +989,8 @@ elif rev is None: raise error.CommandError('perfbdiff', 'invalid arguments') + blocks = opts['blocks'] + xdiff = opts['xdiff'] textpairs = [] r = cmdutil.openrevlog(repo, 'perfbdiff', file_, opts) @@ -1007,7 +1021,12 @@ if not withthreads: def d(): for pair in textpairs: - mdiff.textdiff(*pair) + if xdiff: + mdiff.bdiff.xdiffblocks(*pair) + elif blocks: + mdiff.bdiff.blocks(*pair) + else: + mdiff.textdiff(*pair) else: q = util.queue() for i in xrange(threads): @@ -1015,7 +1034,8 @@ ready = threading.Condition() done = threading.Event() for i in xrange(threads): - threading.Thread(target=_bdiffworker, args=(q, ready, done)).start() + threading.Thread(target=_bdiffworker, + args=(q, blocks, xdiff, ready, done)).start() q.join() def d(): for pair in textpairs: