D1677: revset: extract the logic to build the tree in it's own function

2017-12-19 Thread pulkit (Pulkit Goyal)
pulkit abandoned this revision.
pulkit added a comment.


  Not required anymore.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1677

To: pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1677: revset: extract the logic to build the tree in it's own function

2017-12-12 Thread pulkit (Pulkit Goyal)
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
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel