##// END OF EJS Templates
revset: lookup descendents for negative arguments to ancestor operator...
David Soria Parra -
r32699:f75d0aa5 default
parent child Browse files
Show More
@@ -97,6 +97,7 b' These are the supported infix operators:'
97
97
98 ``x~n``
98 ``x~n``
99 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
99 The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
100 For n < 0, the nth unambiguous descendent of x.
100
101
101 ``x ## y``
102 ``x ## y``
102 Concatenate strings and identifiers into one string.
103 Concatenate strings and identifiers into one string.
@@ -379,12 +379,33 b' def _firstancestors(repo, subset, x):'
379 # Like ``ancestors(set)`` but follows only the first parents.
379 # Like ``ancestors(set)`` but follows only the first parents.
380 return _ancestors(repo, subset, x, followfirst=True)
380 return _ancestors(repo, subset, x, followfirst=True)
381
381
382 def _childrenspec(repo, subset, x, n, order):
383 """Changesets that are the Nth child of a changeset
384 in set.
385 """
386 cs = set()
387 for r in getset(repo, fullreposet(repo), x):
388 for i in range(n):
389 c = repo[r].children()
390 if len(c) == 0:
391 break
392 if len(c) > 1:
393 raise error.RepoLookupError(
394 _("revision in set has more than one child"))
395 r = c[0]
396 else:
397 cs.add(r)
398 return subset & cs
399
382 def ancestorspec(repo, subset, x, n, order):
400 def ancestorspec(repo, subset, x, n, order):
383 """``set~n``
401 """``set~n``
384 Changesets that are the Nth ancestor (first parents only) of a changeset
402 Changesets that are the Nth ancestor (first parents only) of a changeset
385 in set.
403 in set.
386 """
404 """
387 n = getinteger(n, _("~ expects a number"))
405 n = getinteger(n, _("~ expects a number"))
406 if n < 0:
407 # children lookup
408 return _childrenspec(repo, subset, x, -n, order)
388 ps = set()
409 ps = set()
389 cl = repo.changelog
410 cl = repo.changelog
390 for r in getset(repo, fullreposet(repo), x):
411 for r in getset(repo, fullreposet(repo), x):
@@ -2975,6 +2975,14 b' parentrevspec'
2975 $ log 'merge()^^^'
2975 $ log 'merge()^^^'
2976 1
2976 1
2977
2977
2978 $ log '(merge() | 0)~-1'
2979 7
2980 1
2981 $ log 'merge()~-1'
2982 7
2983 $ log 'tip~-1'
2984 $ log '(tip | merge())~-1'
2985 7
2978 $ log 'merge()~0'
2986 $ log 'merge()~0'
2979 6
2987 6
2980 $ log 'merge()~1'
2988 $ log 'merge()~1'
@@ -2995,6 +3003,10 b' parentrevspec'
2995 hg: parse error: ^ expects a number 0, 1, or 2
3003 hg: parse error: ^ expects a number 0, 1, or 2
2996 [255]
3004 [255]
2997
3005
3006 $ log 'branchpoint()~-1'
3007 abort: revision in set has more than one child!
3008 [255]
3009
2998 Bogus function gets suggestions
3010 Bogus function gets suggestions
2999 $ log 'add()'
3011 $ log 'add()'
3000 hg: parse error: unknown identifier: add
3012 hg: parse error: unknown identifier: add
General Comments 0
You need to be logged in to leave comments. Login now