D1677: revset: extract the logic to build the tree in it's own function
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Wed Dec 13 01:55:13 UTC 2017
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This will help us to get the tree at more high level API and we can parse the
tree there before doing optimizations and returning the matcher.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1677
AFFECTED FILES
mercurial/revset.py
CHANGE DETAILS
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2148,6 +2148,19 @@
# hook for extensions to execute code on the optimized tree
pass
+def buildtree(specs, repo=None):
+ """ builds the tree on basis of specs and returns it """
+ lookup = None
+ if repo:
+ lookup = repo.__contains__
+ if len(specs) == 1:
+ tree = revsetlang.parse(specs[0], lookup)
+ else:
+ tree = ('or',
+ ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs))
+
+ return tree
+
def match(ui, spec, repo=None):
"""Create a matcher for a single revision spec"""
return matchany(ui, [spec], repo=repo)
@@ -2167,14 +2180,8 @@
return emptymatcher
if not all(specs):
raise error.ParseError(_("empty query"))
- lookup = None
- if repo:
- lookup = repo.__contains__
- if len(specs) == 1:
- tree = revsetlang.parse(specs[0], lookup)
- else:
- tree = ('or',
- ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs))
+
+ tree = buildtree(specs, repo)
aliases = []
warn = None
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list