Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 34018:de286200f722
revset: move order argument to run-time match function
We no longer need the order flag to build a parsed tree.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 30 Aug 2017 22:41:36 +0900 |
parents | 62cc1f17c571 |
children | 205c47e30a93 |
comparison
equal
deleted
inserted
replaced
34017:62cc1f17c571 | 34018:de286200f722 |
---|---|
74 # | 74 # |
75 # Currently, most revsets do not care about the order, so 'define' is | 75 # Currently, most revsets do not care about the order, so 'define' is |
76 # equivalent to 'follow' for them, and the resulting order is based on the | 76 # equivalent to 'follow' for them, and the resulting order is based on the |
77 # 'subset' parameter passed down to them: | 77 # 'subset' parameter passed down to them: |
78 # | 78 # |
79 # m = revset.match(..., order=defineorder) | 79 # m = revset.match(...) |
80 # m(repo, subset) | 80 # m(repo, subset, order=defineorder) |
81 # ^^^^^^ | 81 # ^^^^^^ |
82 # For most revsets, 'define' means using the order this subset provides | 82 # For most revsets, 'define' means using the order this subset provides |
83 # | 83 # |
84 # There are a few revsets that always redefine the order if 'define' is | 84 # There are a few revsets that always redefine the order if 'define' is |
85 # specified: 'sort(X)', 'reverse(X)', 'x:y'. | 85 # specified: 'sort(X)', 'reverse(X)', 'x:y'. |
2118 | 2118 |
2119 def posttreebuilthook(tree, repo): | 2119 def posttreebuilthook(tree, repo): |
2120 # hook for extensions to execute code on the optimized tree | 2120 # hook for extensions to execute code on the optimized tree |
2121 pass | 2121 pass |
2122 | 2122 |
2123 def match(ui, spec, repo=None, order=defineorder): | 2123 def match(ui, spec, repo=None): |
2124 """Create a matcher for a single revision spec | 2124 """Create a matcher for a single revision spec""" |
2125 | 2125 return matchany(ui, [spec], repo=repo) |
2126 If order=followorder, a matcher takes the ordering specified by the input | 2126 |
2127 set. | 2127 def matchany(ui, specs, repo=None, localalias=None): |
2128 """ | |
2129 return matchany(ui, [spec], repo=repo, order=order) | |
2130 | |
2131 def matchany(ui, specs, repo=None, order=defineorder, localalias=None): | |
2132 """Create a matcher that will include any revisions matching one of the | 2128 """Create a matcher that will include any revisions matching one of the |
2133 given specs | 2129 given specs |
2134 | |
2135 If order=followorder, a matcher takes the ordering specified by the input | |
2136 set. | |
2137 | 2130 |
2138 If localalias is not None, it is a dict {name: definitionstring}. It takes | 2131 If localalias is not None, it is a dict {name: definitionstring}. It takes |
2139 precedence over [revsetalias] config section. | 2132 precedence over [revsetalias] config section. |
2140 """ | 2133 """ |
2141 if not specs: | 2134 if not specs: |
2164 tree = revsetlang.expandaliases(tree, aliases, warn=warn) | 2157 tree = revsetlang.expandaliases(tree, aliases, warn=warn) |
2165 tree = revsetlang.foldconcat(tree) | 2158 tree = revsetlang.foldconcat(tree) |
2166 tree = revsetlang.analyze(tree) | 2159 tree = revsetlang.analyze(tree) |
2167 tree = revsetlang.optimize(tree) | 2160 tree = revsetlang.optimize(tree) |
2168 posttreebuilthook(tree, repo) | 2161 posttreebuilthook(tree, repo) |
2169 return makematcher(tree, order) | 2162 return makematcher(tree) |
2170 | 2163 |
2171 def makematcher(tree, order=defineorder): | 2164 def makematcher(tree): |
2172 """Create a matcher from an evaluatable tree""" | 2165 """Create a matcher from an evaluatable tree""" |
2173 def mfunc(repo, subset=None): | 2166 def mfunc(repo, subset=None, order=defineorder): |
2174 if subset is None: | 2167 if subset is None: |
2175 subset = fullreposet(repo) | 2168 subset = fullreposet(repo) |
2176 return getset(repo, subset, tree, order) | 2169 return getset(repo, subset, tree, order) |
2177 return mfunc | 2170 return mfunc |
2178 | 2171 |