Patchwork [1,of,4] revset: move order constants from revsetlang

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 30, 2017, 3:42 p.m.
Message ID <76c19e653cb1165f5224.1504107779@mimosa>
Download mbox | patch
Permalink /patch/23509/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 30, 2017, 3:42 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1504099967 -32400
#      Wed Aug 30 22:32:47 2017 +0900
# Node ID 76c19e653cb1165f52242a398ed1d551e9ca5941
# Parent  ae7308d7604ef831e1c140512ba15db136efa466
revset: move order constants from revsetlang

Thanks to the recent refactor, the ordering rule is fully processed at
runtime.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -40,16 +40,53 @@  getrange = revsetlang.getrange
 getargs = revsetlang.getargs
 getargsdict = revsetlang.getargsdict
 
-# constants used as an argument of match() and matchany()
-anyorder = revsetlang.anyorder
-defineorder = revsetlang.defineorder
-followorder = revsetlang.followorder
-
 baseset = smartset.baseset
 generatorset = smartset.generatorset
 spanset = smartset.spanset
 fullreposet = smartset.fullreposet
 
+# Constants for ordering requirement, used in getset():
+#
+# If 'define', any nested functions and operations MAY change the ordering of
+# the entries in the set (but if changes the ordering, it MUST ALWAYS change
+# it). If 'follow', any nested functions and operations MUST take the ordering
+# specified by the first operand to the '&' operator.
+#
+# For instance,
+#
+#   X & (Y | Z)
+#   ^   ^^^^^^^
+#   |   follow
+#   define
+#
+# will be evaluated as 'or(y(x()), z(x()))', where 'x()' can change the order
+# of the entries in the set, but 'y()', 'z()' and 'or()' shouldn't.
+#
+# 'any' means the order doesn't matter. For instance,
+#
+#   (X & Y) | ancestors(Z)
+#        ^              ^
+#        any            any
+#
+# For 'X & Y', 'X' decides order so the order of 'Y' does not matter. For
+# 'ancesotrs(Z)', Z's order does not matter since 'ancesotrs' does not care
+# about the order of its argument.
+#
+# Currently, most revsets do not care about the order, so 'define' is
+# 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)
+#           ^^^^^^
+#      For most revsets, 'define' means using the order this subset provides
+#
+# There are a few revsets that always redefine the order if 'define' is
+# specified: 'sort(X)', 'reverse(X)', 'x:y'.
+anyorder = 'any'        # don't care the order, could be even random-shuffled
+defineorder = 'define'  # ALWAYS redefine, or ALWAYS follow the current order
+followorder = 'follow'  # MUST follow the current order
+
 # helpers
 
 def getset(repo, subset, x, order=defineorder):
diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -258,48 +258,6 @@  def _matchnamedfunc(x, funcname):
         return
     return x[2]
 
-# Constants for ordering requirement, used in getset():
-#
-# If 'define', any nested functions and operations MAY change the ordering of
-# the entries in the set (but if changes the ordering, it MUST ALWAYS change
-# it). If 'follow', any nested functions and operations MUST take the ordering
-# specified by the first operand to the '&' operator.
-#
-# For instance,
-#
-#   X & (Y | Z)
-#   ^   ^^^^^^^
-#   |   follow
-#   define
-#
-# will be evaluated as 'or(y(x()), z(x()))', where 'x()' can change the order
-# of the entries in the set, but 'y()', 'z()' and 'or()' shouldn't.
-#
-# 'any' means the order doesn't matter. For instance,
-#
-#   (X & Y) | ancestors(Z)
-#        ^              ^
-#        any            any
-#
-# For 'X & Y', 'X' decides order so the order of 'Y' does not matter. For
-# 'ancesotrs(Z)', Z's order does not matter since 'ancesotrs' does not care
-# about the order of its argument.
-#
-# Currently, most revsets do not care about the order, so 'define' is
-# 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)
-#           ^^^^^^
-#      For most revsets, 'define' means using the order this subset provides
-#
-# There are a few revsets that always redefine the order if 'define' is
-# specified: 'sort(X)', 'reverse(X)', 'x:y'.
-anyorder = 'any'        # don't care the order, could be even random-shuffled
-defineorder = 'define'  # ALWAYS redefine, or ALWAYS follow the current order
-followorder = 'follow'  # MUST follow the current order
-
 def _matchonly(revs, bases):
     """
     >>> f = lambda *args: _matchonly(*map(parse, args))