[PATCH 1 of 2] revset: add option to make matcher takes the ordering of the input set

Yuya Nishihara yuya at tcha.org
Sat Sep 17 06:17:39 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1462252708 -32400
#      Tue May 03 14:18:28 2016 +0900
# Node ID 961b53cbadd0e17b1e5e745d0e3cc582cbf6603f
# Parent  e40343ce9c4c4819ea5669abb3447d5c031a8270
# EXP-Topic revsetflag
revset: add option to make matcher takes the ordering of the input set

This allows us to evaluate match(subset) as if 'subset & expr', which will
be the complete fix for the issue5100.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2694,13 +2694,21 @@ def posttreebuilthook(tree, repo):
     # hook for extensions to execute code on the optimized tree
     pass
 
-def match(ui, spec, repo=None):
-    """Create a matcher for a single revision spec."""
-    return matchany(ui, [spec], repo=repo)
-
-def matchany(ui, specs, repo=None):
+def match(ui, spec, repo=None, order=defineorder):
+    """Create a matcher for a single revision spec
+
+    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):
     """Create a matcher that will include any revisions matching one of the
-    given specs"""
+    given specs
+
+    If order=followorder, a matcher takes the ordering specified by the input
+    set.
+    """
     if not specs:
         def mfunc(repo, subset=None):
             return baseset()
@@ -2718,7 +2726,7 @@ def matchany(ui, specs, repo=None):
     if ui:
         tree = expandaliases(ui, tree)
     tree = foldconcat(tree)
-    tree = analyze(tree)
+    tree = analyze(tree, order)
     tree = optimize(tree)
     posttreebuilthook(tree, repo)
     return makematcher(tree)


More information about the Mercurial-devel mailing list