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

login
register
mail settings
Submitter phabricator
Date Dec. 13, 2017, 1:55 a.m.
Message ID <differential-rev-PHID-DREV-dyghdkb75ilo67yhvhab-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26259/
State Superseded
Headers show

Comments

phabricator - Dec. 13, 2017, 1:55 a.m.
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




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 19, 2017, 12:18 p.m.
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

Patch

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