comparison mercurial/revsetlang.py @ 34030:dcfdf4d09663

revset: improve documentation about ordering handling The old documentation is a bit confusing. Namely, it's unclear whether `define` means "I should ALWAYS define a new order", or "I should SOMETIMES define a new order", and if it's the latter, what's the difference between `define` and `any`? This patch clarifies that and adds more examples. Differential Revision: https://phab.mercurial-scm.org/D523
author Jun Wu <quark@fb.com>
date Fri, 25 Aug 2017 11:20:34 -0700
parents 1b28525e6698
children 96f249dce03e
comparison
equal deleted inserted replaced
34029:1b28525e6698 34030:dcfdf4d09663
258 return 258 return
259 return x[2] 259 return x[2]
260 260
261 # Constants for ordering requirement, used in getset(): 261 # Constants for ordering requirement, used in getset():
262 # 262 #
263 # If 'define', any nested functions and operations can change the ordering of 263 # If 'define', any nested functions and operations MAY change the ordering of
264 # the entries in the set. If 'follow', any nested functions and operations 264 # the entries in the set (but if changes the ordering, it MUST ALWAYS change
265 # should take the ordering specified by the first operand to the '&' operator. 265 # it). If 'follow', any nested functions and operations MUST take the ordering
266 # specified by the first operand to the '&' operator.
266 # 267 #
267 # For instance, 268 # For instance,
268 # 269 #
269 # X & (Y | Z) 270 # X & (Y | Z)
270 # ^ ^^^^^^^ 271 # ^ ^^^^^^^
274 # will be evaluated as 'or(y(x()), z(x()))', where 'x()' can change the order 275 # will be evaluated as 'or(y(x()), z(x()))', where 'x()' can change the order
275 # of the entries in the set, but 'y()', 'z()' and 'or()' shouldn't. 276 # of the entries in the set, but 'y()', 'z()' and 'or()' shouldn't.
276 # 277 #
277 # 'any' means the order doesn't matter. For instance, 278 # 'any' means the order doesn't matter. For instance,
278 # 279 #
279 # X & !Y 280 # (X & Y) | ancestors(Z)
280 # ^ 281 # ^ ^
281 # any 282 # any any
282 # 283 #
283 # 'y()' can either enforce its ordering requirement or take the ordering 284 # For 'X & Y', 'X' decides order so the order of 'Y' does not matter. For
284 # specified by 'x()' because 'not()' doesn't care the order. 285 # 'ancestors(Z)', Z's order does not matter since 'ancestors' does not care
285 anyorder = 'any' # don't care the order 286 # about the order of its argument.
286 defineorder = 'define' # should define the order 287 #
287 followorder = 'follow' # must follow the current order 288 # Currently, most revsets do not care about the order, so 'define' is
289 # equivalent to 'follow' for them, and the resulting order is based on the
290 # 'subset' parameter passed down to them:
291 #
292 # m = revset.match(..., order=defineorder)
293 # m(repo, subset)
294 # ^^^^^^
295 # For most revsets, 'define' means using the order this subset provides
296 #
297 # There are a few revsets that always redefine the order if 'define' is
298 # specified: 'sort(X)', 'reverse(X)', 'x:y'.
299 anyorder = 'any' # don't care the order, could be even random-shuffled
300 defineorder = 'define' # ALWAYS redefine, or ALWAYS follow the current order
301 followorder = 'follow' # MUST follow the current order
288 302
289 def _matchonly(revs, bases): 303 def _matchonly(revs, bases):
290 """ 304 """
291 >>> f = lambda *args: _matchonly(*map(parse, args)) 305 >>> f = lambda *args: _matchonly(*map(parse, args))
292 >>> f('ancestors(A)', 'not ancestors(B)') 306 >>> f('ancestors(A)', 'not ancestors(B)')