@@ -17,7 +17,7 @@ import obsolete as obsmod
import pathutil
import repoview
-def _revancestors(repo, revs, followfirst):
+def _revancestors(repo, revs, followfirst, while_=None):
"""Like revlog.ancestors(), but supports followfirst."""
cut = followfirst and 1 or None
cl = repo.changelog
@@ -41,10 +41,11 @@ def _revancestors(repo, revs, followfirs
revsnode = revqueue.popleft()
heapq.heappush(h, -revsnode)
seen.add(current)
- yield current
- for parent in cl.parentrevs(current)[:cut]:
- if parent != node.nullrev:
- heapq.heappush(h, -parent)
+ if while_ is None or current in while_:
+ yield current
+ for parent in cl.parentrevs(current)[:cut]:
+ if parent != node.nullrev:
+ heapq.heappush(h, -parent)
return generatorset(iterate(), iterasc=False)
@@ -343,15 +344,22 @@ def ancestor(repo, subset, x):
return baseset()
def _ancestors(repo, subset, x, followfirst=False):
- heads = getset(repo, spanset(repo), x)
+ args = getargs(x, 0, 2, _('ancestors takes no, one or two arguments'))
+ if not args:
+ return baseset()
+ heads = getset(repo, spanset(repo), args[0])
if not heads:
return baseset()
- s = _revancestors(repo, heads, followfirst)
+ while_ = None
+ if len(args) > 1:
+ while_ = getset(repo, spanset(repo), args[1])
+ s = _revancestors(repo, heads, followfirst, while_=while_)
return subset.filter(s.__contains__)
def ancestors(repo, subset, x):
- """``ancestors(set)``
+ """``ancestors(set, [while])``
Changesets that are ancestors of a changeset in set.
+ If a while set is specified, only follow ancestors in that set.
"""
return _ancestors(repo, subset, x)
@@ -246,6 +246,10 @@ ancestor can accept 0 or more arguments
5
$ log 'ancestor(ancestors(5))'
0
+ $ log 'ancestors(5+9, 1:7)'
+ 1
+ 3
+ 5
$ log 'author(bob)'
2
$ log 'author("re:bob|test")'