Mercurial > hg
view tests/test-rust-revlog.py @ 45725:99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
I find this is useful in GUI log viewer since the tool only needs to support
"log -rREV" command.
This is basic implementation. Windowed search is not implemented since it
wouldn't work pretty well with the smartset API. And filename matcher is
not supported because the syntax isn't determined. My idea is to add handling
of diff(pattern, file(..)) and diff(pattern, follow(..)), which will then be
evolved to a full revset+matcher combinator support:
x & diff(pattern, y & z)
=====
y & z builds (revs(y) & revs(z), matcher(y) & matcher(z))
pair, and narrows the search space of diff()
====================
diff() returns matched (revs, matcher) pair
========================
revs and matcher will be combined respectively by &-operator, and the matcher
will optionally be used to filter "hg log -p" output
The predicate name "diff()" wouldn't be great, but grep() is already used.
Another options I can think of are "grepdiff()" and "containsdiff()".
Naming suggestions are welcome.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 08 Sep 2020 18:16:24 +0900 |
parents | 443dc1655923 |
children | 89a2afe31e82 |
line wrap: on
line source
from __future__ import absolute_import import unittest try: from mercurial import rustext rustext.__name__ # trigger immediate actual import except ImportError: rustext = None else: from mercurial.rustext import revlog # this would fail already without appropriate ancestor.__package__ from mercurial.rustext.ancestor import LazyAncestors from mercurial.testing import revlog as revlogtesting @unittest.skipIf( rustext is None, "rustext module revlog relies on is not available", ) class RustRevlogIndexTest(revlogtesting.RevlogBasedTestBase): def test_heads(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) self.assertEqual(rustidx.headrevs(), idx.headrevs()) def test_get_cindex(self): # drop me once we no longer need the method for shortest node idx = self.parseindex() rustidx = revlog.MixedIndex(idx) cidx = rustidx.get_cindex() self.assertTrue(idx is cidx) def test_len(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) self.assertEqual(len(rustidx), len(idx)) def test_ancestors(self): idx = self.parseindex() rustidx = revlog.MixedIndex(idx) lazy = LazyAncestors(rustidx, [3], 0, True) # we have two more references to the index: # - in its inner iterator for __contains__ and __bool__ # - in the LazyAncestors instance itself (to spawn new iterators) self.assertTrue(2 in lazy) self.assertTrue(bool(lazy)) self.assertEqual(list(lazy), [3, 2, 1, 0]) # a second time to validate that we spawn new iterators self.assertEqual(list(lazy), [3, 2, 1, 0]) # let's check bool for an empty one self.assertFalse(LazyAncestors(idx, [0], 0, False)) if __name__ == '__main__': import silenttestrunner silenttestrunner.main(__name__)