# HG changeset patch # User Yuya Nishihara # Date 1471746597 -32400 # Node ID 371c2a39eead4a8dc044c672dea17b3a5053a470 # Parent e4b4168a4f1ce0801f19cd366df1c1861294015d revset: make analyze() a separate step from optimize() This will allow us to evaluate unoptimized tree and compare the result with optimized one. The private _analyze() function isn't renamed since I'll add more parameters to it. diff -r e4b4168a4f1c -r 371c2a39eead mercurial/commands.py --- a/mercurial/commands.py Sun Aug 07 14:35:03 2016 +0900 +++ b/mercurial/commands.py Sun Aug 21 11:29:57 2016 +0900 @@ -3530,6 +3530,7 @@ if newtree != tree: ui.note(("* concatenated:\n"), revset.prettyformat(newtree), "\n") if opts["optimize"]: + newtree = revset.analyze(newtree) optimizedtree = revset.optimize(newtree) ui.note(("* optimized:\n"), revset.prettyformat(optimizedtree), "\n") diff -r e4b4168a4f1c -r 371c2a39eead mercurial/revset.py --- a/mercurial/revset.py Sun Aug 07 14:35:03 2016 +0900 +++ b/mercurial/revset.py Sun Aug 21 11:29:57 2016 +0900 @@ -2343,12 +2343,6 @@ return (op,) + tuple(_fixops(y) for y in x[1:]) def _analyze(x): - """Transform raw parsed tree to evaluatable tree which can be fed to - optimize() or getset() - - All pseudo operations should be mapped to real operations or functions - defined in methods or symbols table respectively. - """ if x is None: return x @@ -2399,11 +2393,16 @@ return (op, x[1], _analyze(x[2])) raise ValueError('invalid operator %r' % op) +def analyze(x): + """Transform raw parsed tree to evaluatable tree which can be fed to + optimize() or getset() + + All pseudo operations should be mapped to real operations or functions + defined in methods or symbols table respectively. + """ + return _analyze(x) + def _optimize(x, small): - """Optimize evaluatable tree - - All pseudo operations should be transformed beforehand. - """ if x is None: return 0, x @@ -2505,7 +2504,10 @@ raise ValueError('invalid operator %r' % op) def optimize(tree): - tree = _analyze(tree) + """Optimize evaluatable tree + + All pseudo operations should be transformed beforehand. + """ _weight, newtree = _optimize(tree, small=True) return newtree @@ -2619,6 +2621,7 @@ if ui: tree = expandaliases(ui, tree, showwarning=ui.warn) tree = foldconcat(tree) + tree = analyze(tree) tree = optimize(tree) posttreebuilthook(tree, repo) def mfunc(repo, subset=None): diff -r e4b4168a4f1c -r 371c2a39eead tests/test-revset.t --- a/tests/test-revset.t Sun Aug 07 14:35:03 2016 +0900 +++ b/tests/test-revset.t Sun Aug 21 11:29:57 2016 +0900 @@ -54,7 +54,7 @@ > tree = revset.parse(expr, lookup=repo.__contains__) > ui.note(revset.prettyformat(tree), "\n") > if opts["optimize"]: - > opttree = revset.optimize(tree) + > opttree = revset.optimize(revset.analyze(tree)) > ui.note("* optimized:\n", revset.prettyformat(opttree), "\n") > func = revset.match(ui, expr, repo) > revs = func(repo)