mercurial/revset.py
changeset 32699 f75d0aa5dc83
parent 32684 af854b1b36f8
child 32798 573b792872c1
equal deleted inserted replaced
32698:1b5c61d38a52 32699:f75d0aa5dc83
   377 def _firstancestors(repo, subset, x):
   377 def _firstancestors(repo, subset, x):
   378     # ``_firstancestors(set)``
   378     # ``_firstancestors(set)``
   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):
   391         for i in range(n):
   412         for i in range(n):
   392             try:
   413             try: