Mercurial > public > mercurial-scm > hg-stable
diff mercurial/pure/parsers.py @ 51999:22da1dc97281
head-revs: teach the pure indexes about the `headrevs` method
Having this computation done at the index level unify the API and remove revlog
side complexity. It might also be a front runner of handing more responsability
to the index.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 25 Sep 2024 17:18:40 +0200 |
parents | f4733654f144 |
children | 609700e5d8df |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Thu Sep 26 00:50:21 2024 +0200 +++ b/mercurial/pure/parsers.py Wed Sep 25 17:18:40 2024 +0200 @@ -696,6 +696,22 @@ p = p[revlog_constants.INDEX_HEADER.size :] return p + def headrevs(self, excluded_revs=None): + count = len(self) + if not count: + return [nullrev] + # we won't iter over filtered rev so nobody is a head at start + ishead = [0] * (count + 1) + revs = range(count) + if excluded_revs is not None: + revs = (r for r in revs if r not in excluded_revs) + + for r in revs: + ishead[r] = 1 # I may be an head + e = self[r] + ishead[e[5]] = ishead[e[6]] = 0 # my parent are not + return [r for r, val in enumerate(ishead) if val] + class IndexObject(BaseIndexObject): def __init__(self, data):