D6517: rust-discovery: read the index from a repo passed at init
gracinet (Georges Racinet)
phabricator at mercurial-scm.org
Wed Aug 14 16:16:10 EDT 2019
Closed by commit rHGb6f3f704a561: rust-discovery: read the index from a repo passed at init (authored by gracinet).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D6517?vs=16011&id=16184
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
@@ -31,6 +31,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(PartialDiscovery is None or cparsers is None,
"rustext or the C Extension parsers module "
@@ -50,6 +55,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:
@@ -60,8 +68,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())
@@ -76,24 +83,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
@@ -34,10 +34,11 @@
// implemented.
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