hgext3rd/topic/revset.py
changeset 4369 75276f858444
parent 4339 0f015fe4f71f
child 4379 2893b127923b
equal deleted inserted replaced
4368:acfd2b1a6176 4369:75276f858444
   106     else:
   106     else:
   107         branch = repo[None].branch()
   107         branch = repo[None].branch()
   108     return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & subset
   108     return revset.baseset(stack.stack(repo, branch=branch, topic=topic)[1:]) & subset
   109 
   109 
   110 if util.safehasattr(revset, 'subscriptrelations'):
   110 if util.safehasattr(revset, 'subscriptrelations'):
   111     def stackrel(repo, subset, x, rel, n, order):
   111     def stackrel(repo, subset, x, rel, n, *args):
   112         """This is a revset-flavored implementation of stack aliases.
   112         """This is a revset-flavored implementation of stack aliases.
   113 
   113 
   114         The syntax is: rev#stack[n] or rev#s[n]. Plenty of logic is borrowed
   114         The syntax is: rev#stack[n] or rev#s[n]. Plenty of logic is borrowed
   115         from topic._namemap, but unlike that function, which prefers to abort
   115         from topic._namemap, but unlike that function, which prefers to abort
   116         (e.g. when stack index is too high), this returns empty set to be more
   116         (e.g. when stack index is too high), this returns empty set to be more
   117         revset-friendly.
   117         revset-friendly.
   118         """
   118         """
       
   119         # hg 5.0 provides two bounds, for now we support only one
       
   120         if len(args) == 2 and args[0] != n:
       
   121             raise NotImplementedError
   119         s = revset.getset(repo, revset.fullreposet(repo), x)
   122         s = revset.getset(repo, revset.fullreposet(repo), x)
   120         if not s:
   123         if not s:
   121             return revset.baseset()
   124             return revset.baseset()
   122         revs = []
   125         revs = []
   123         for r in s:
   126         for r in s:
   141         return subset & revset.baseset(revs)
   144         return subset & revset.baseset(revs)
   142 
   145 
   143     revset.subscriptrelations['stack'] = stackrel
   146     revset.subscriptrelations['stack'] = stackrel
   144     revset.subscriptrelations['s'] = stackrel
   147     revset.subscriptrelations['s'] = stackrel
   145 
   148 
   146     def topicrel(repo, subset, x, rel, n, order):
   149     def topicrel(repo, subset, x, rel, n, *args):
       
   150         # hg 5.0 provides two bounds, for now we support only one
       
   151         if len(args) == 2 and args[0] != n:
       
   152             raise NotImplementedError
   147         ancestors = revset._ancestors
   153         ancestors = revset._ancestors
   148         descendants = revset._descendants
   154         descendants = revset._descendants
   149         subset = topicset(repo, subset, x)
   155         subset = topicset(repo, subset, x)
   150         if n <= 0:
   156         if n <= 0:
   151             n = -n
   157             n = -n