Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 51965: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 | 5e79783d4bc7 |
children | 42a116f1cdc1 |
comparison
equal
deleted
inserted
replaced
51964:8060257fd918 | 51965:22da1dc97281 |
---|---|
2380 assert heads | 2380 assert heads |
2381 return (orderedout, roots, heads) | 2381 return (orderedout, roots, heads) |
2382 | 2382 |
2383 def headrevs(self, revs=None): | 2383 def headrevs(self, revs=None): |
2384 if revs is None: | 2384 if revs is None: |
2385 try: | 2385 return self.index.headrevs() |
2386 return self.index.headrevs() | |
2387 except AttributeError: | |
2388 return self._headrevs() | |
2389 if rustdagop is not None and self.index.rust_ext_compat: | 2386 if rustdagop is not None and self.index.rust_ext_compat: |
2390 return rustdagop.headrevs(self.index, revs) | 2387 return rustdagop.headrevs(self.index, revs) |
2391 return dagop.headrevs(revs, self._uncheckedparentrevs) | 2388 return dagop.headrevs(revs, self._uncheckedparentrevs) |
2392 | 2389 |
2393 def headrevsdiff(self, start, stop): | 2390 def headrevsdiff(self, start, stop): |
2396 except AttributeError: | 2393 except AttributeError: |
2397 return dagop.headrevsdiff(self._uncheckedparentrevs, start, stop) | 2394 return dagop.headrevsdiff(self._uncheckedparentrevs, start, stop) |
2398 | 2395 |
2399 def computephases(self, roots): | 2396 def computephases(self, roots): |
2400 return self.index.computephasesmapsets(roots) | 2397 return self.index.computephasesmapsets(roots) |
2401 | |
2402 def _headrevs(self): | |
2403 count = len(self) | |
2404 if not count: | |
2405 return [nullrev] | |
2406 # we won't iter over filtered rev so nobody is a head at start | |
2407 ishead = [0] * (count + 1) | |
2408 index = self.index | |
2409 for r in self: | |
2410 ishead[r] = 1 # I may be an head | |
2411 e = index[r] | |
2412 ishead[e[5]] = ishead[e[6]] = 0 # my parent are not | |
2413 return [r for r, val in enumerate(ishead) if val] | |
2414 | 2398 |
2415 def _head_node_ids(self): | 2399 def _head_node_ids(self): |
2416 try: | 2400 try: |
2417 return self.index.head_node_ids() | 2401 return self.index.head_node_ids() |
2418 except AttributeError: | 2402 except AttributeError: |