changing-files: rework the way we store changed files in side-data
We need to store new data so this is a good opportunity to rework this fully.
1) We directly store the list of affected file in the side data:
* This avoid having to fetch and parse the `files` list in the revision in
addition to the sidedata. Making the data more self sufficient.
* This work around situation where that `files` field contains wrong
information, and open the way to other bug fixing (eg:
issue6219)
* The format (fixed initial index, sorted files) allow for fast lookup of
filename within the structure.
* This unify the storage of affected files and copies sources and destination,
limiting the number filename stored redundantly.
* This prepare for the fact we should drop the `files` as soon as we do any
change affecting the revision schema.
* This rely on compression to avoid a significant increase of the changelog.d.
More testing on this will be done before we freeze the final format.
2) We can store additional data:
* The new "merged" field,
* A future "salvaged" set recording files that might have been deleted but have
were still present in the final result.
Differential Revision: https://phab.mercurial-scm.org/D9090
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__)