Patchwork [3,of,4] revset: move order argument to run-time match function

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 30, 2017, 3:43 p.m.
Message ID <d0c9c6ba9c005021dabb.1504107781@mimosa>
Download mbox | patch
Permalink /patch/23511/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 30, 2017, 3:43 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1504100496 -32400
#      Wed Aug 30 22:41:36 2017 +0900
# Node ID d0c9c6ba9c005021dabb90f06194a5729f5ad561
# Parent  3b7bebd5335340797ee0b3aab5fc17ada6c91fb8
revset: move order argument to run-time match function

We no longer need the order flag to build a parsed tree.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2558,8 +2558,8 @@  def getgraphlogrevs(repo, pats, opts):
         if not (revs.isdescending() or revs.istopo()):
             revs.sort(reverse=True)
     if expr:
-        matcher = revset.match(repo.ui, expr, order=revset.followorder)
-        revs = matcher(repo, revs)
+        matcher = revset.match(repo.ui, expr)
+        revs = matcher(repo, revs, order=revset.followorder)
     if limit is not None:
         limitedrevs = []
         for idx, rev in enumerate(revs):
@@ -2584,8 +2584,8 @@  def getlogrevs(repo, pats, opts):
         return smartset.baseset([]), None, None
     expr, filematcher = _makelogrevset(repo, pats, opts, revs)
     if expr:
-        matcher = revset.match(repo.ui, expr, order=revset.followorder)
-        revs = matcher(repo, revs)
+        matcher = revset.match(repo.ui, expr)
+        revs = matcher(repo, revs, order=revset.followorder)
     if limit is not None:
         limitedrevs = []
         for idx, r in enumerate(revs):
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -76,8 +76,8 @@  fullreposet = smartset.fullreposet
 # equivalent to 'follow' for them, and the resulting order is based on the
 # 'subset' parameter passed down to them:
 #
-#   m = revset.match(..., order=defineorder)
-#   m(repo, subset)
+#   m = revset.match(...)
+#   m(repo, subset, order=defineorder)
 #           ^^^^^^
 #      For most revsets, 'define' means using the order this subset provides
 #
@@ -2120,21 +2120,14 @@  def posttreebuilthook(tree, repo):
     # hook for extensions to execute code on the optimized tree
     pass
 
-def match(ui, spec, repo=None, order=defineorder):
-    """Create a matcher for a single revision spec
+def match(ui, spec, repo=None):
+    """Create a matcher for a single revision spec"""
+    return matchany(ui, [spec], repo=repo)
 
-    If order=followorder, a matcher takes the ordering specified by the input
-    set.
-    """
-    return matchany(ui, [spec], repo=repo, order=order)
-
-def matchany(ui, specs, repo=None, order=defineorder, localalias=None):
+def matchany(ui, specs, repo=None, localalias=None):
     """Create a matcher that will include any revisions matching one of the
     given specs
 
-    If order=followorder, a matcher takes the ordering specified by the input
-    set.
-
     If localalias is not None, it is a dict {name: definitionstring}. It takes
     precedence over [revsetalias] config section.
     """
@@ -2166,11 +2159,11 @@  def matchany(ui, specs, repo=None, order
     tree = revsetlang.analyze(tree)
     tree = revsetlang.optimize(tree)
     posttreebuilthook(tree, repo)
-    return makematcher(tree, order)
+    return makematcher(tree)
 
-def makematcher(tree, order=defineorder):
+def makematcher(tree):
     """Create a matcher from an evaluatable tree"""
-    def mfunc(repo, subset=None):
+    def mfunc(repo, subset=None, order=defineorder):
         if subset is None:
             subset = fullreposet(repo)
         return getset(repo, subset, tree, order)