Mercurial > hg
comparison tests/test-rust-ancestor.py @ 51241:578c049f0408
rust-index: using `hg::index::Index` in `hg-cpython::dagops`
Hooking `headrevs` to the Rust index is straightforward as long as
we go the `PySharedRef` way. Direct attempts of obtaining a reference
to the inner `hg::index::Index` fail for lifetime reasons: the reference
is bound to the GIL, yet the `as_set` local variable is considered to
be static (the borrow checker clearly does not realize or care that this
set only stores `Revision` values).
In `rank()`, the chosen solution is the simplest as far as `hg-cpython` is
concerned, but it has the defect of removing an implementation
that would be easily adaptable if the core index did implement `RankedGraph`
(returning the same error as long as only `REVLOGV1` is supported), but that
would introduce a direct dependency of `hg-core` on the ``vcsgraph` crate.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Sun, 29 Oct 2023 10:47:54 +0100 |
parents | 59d81768ad6d |
children | 03fdd4d7b5bd |
comparison
equal
deleted
inserted
replaced
51240:59d81768ad6d | 51241:578c049f0408 |
---|---|
155 self.assertIsInstance(exc, ValueError) | 155 self.assertIsInstance(exc, ValueError) |
156 # rust-cpython issues appropriate str instances for Python 2 and 3 | 156 # rust-cpython issues appropriate str instances for Python 2 and 3 |
157 self.assertEqual(exc.args, ('InvalidRevision', wdirrev)) | 157 self.assertEqual(exc.args, ('InvalidRevision', wdirrev)) |
158 | 158 |
159 def testheadrevs(self): | 159 def testheadrevs(self): |
160 idx = self.parseindex() | 160 idx = self.parserustindex() |
161 self.assertEqual(dagop.headrevs(idx, [1, 2, 3]), {3}) | 161 self.assertEqual(dagop.headrevs(idx, [1, 2, 3]), {3}) |
162 | 162 |
163 | 163 |
164 if __name__ == '__main__': | 164 if __name__ == '__main__': |
165 import silenttestrunner | 165 import silenttestrunner |