D6517: rust-discovery: read the index from a repo passed at init
Alphare (Raphaël Gomès)
phabricator at mercurial-scm.org
Wed Jul 17 16:30:25 UTC 2019
Alphare updated this revision to Diff 15932.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6517?vs=15465&id=15932
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D6517/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D6517
AFFECTED FILES
rust/hg-cpython/src/discovery.rs
tests/test-rust-discovery.py
CHANGE DETAILS
diff --git a/tests/test-rust-discovery.py b/tests/test-rust-discovery.py
--- a/tests/test-rust-discovery.py
+++ b/tests/test-rust-discovery.py
@@ -38,6 +38,11 @@
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
)
+class fakerepo(object):
+ def __init__(self, idx):
+ """Just make so that self.changelog.index is the given idx."""
+ self.index = idx
+ self.changelog = self
@unittest.skipIf(rustext is None or cparsers is None,
"rustext or the C Extension parsers module "
@@ -57,6 +62,9 @@
def parseindex(self):
return cparsers.parse_index2(data_non_inlined, False)[0]
+ def repo(self):
+ return fakerepo(self.parseindex())
+
def testindex(self):
idx = self.parseindex()
# checking our assumptions about the index binary data:
@@ -67,8 +75,7 @@
3: (2, -1)})
def testaddcommonsmissings(self):
- idx = self.parseindex()
- disco = PartialDiscovery(idx, [3], True)
+ disco = PartialDiscovery(self.repo(), [3], True)
self.assertFalse(disco.hasinfo())
self.assertFalse(disco.iscomplete())
@@ -83,24 +90,21 @@
self.assertEqual(disco.commonheads(), {1})
def testaddmissingsstats(self):
- idx = self.parseindex()
- disco = PartialDiscovery(idx, [3], True)
+ disco = PartialDiscovery(self.repo(), [3], True)
self.assertIsNone(disco.stats()['undecided'], None)
disco.addmissings([2])
self.assertEqual(disco.stats()['undecided'], 2)
def testaddinfocommonfirst(self):
- idx = self.parseindex()
- disco = PartialDiscovery(idx, [3], True)
+ disco = PartialDiscovery(self.repo(), [3], True)
disco.addinfo([(1, True), (2, False)])
self.assertTrue(disco.hasinfo())
self.assertTrue(disco.iscomplete())
self.assertEqual(disco.commonheads(), {1})
def testaddinfomissingfirst(self):
- idx = self.parseindex()
- disco = PartialDiscovery(idx, [3], True)
+ disco = PartialDiscovery(self.repo(), [3], True)
disco.addinfo([(2, False), (1, True)])
self.assertTrue(disco.hasinfo())
self.assertTrue(disco.iscomplete())
diff --git a/rust/hg-cpython/src/discovery.rs b/rust/hg-cpython/src/discovery.rs
--- a/rust/hg-cpython/src/discovery.rs
+++ b/rust/hg-cpython/src/discovery.rs
@@ -31,10 +31,11 @@
def __new__(
_cls,
- index: PyObject,
+ repo: PyObject,
targetheads: PyObject,
_respectsize: bool
) -> PyResult<PartialDiscovery> {
+ let index = repo.getattr(py, "changelog")?.getattr(py, "index")?;
Self::create_instance(
py,
RefCell::new(Box::new(CorePartialDiscovery::new(
To: gracinet, #hg-reviewers, kevincox
Cc: durin42, kevincox, mercurial-devel
More information about the Mercurial-devel
mailing list