diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
index 1bf3e6041e2c682ea1ba717a9bb8901172ba1bb8_bWVyY3VyaWFsL2NleHQvcmV2bG9nLmM=..a91a2837150bdcb27ae76b3646e6c93cd6a15904_bWVyY3VyaWFsL2NleHQvcmV2bG9nLmM= 100644
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -2311,7 +2311,7 @@
 	/* to pass index_get_parents() */
 	int (*)(indexObject *, Py_ssize_t, int*, int),
 	/* intrevs vector */
-	int initrevslen, long *initrevs,
+	Py_ssize_t initrevslen, long *initrevs,
 	long stoprev,
 	int inclusive);
 void rustlazyancestors_drop(rustlazyancestorsObject *self);
diff --git a/rust/hg-direct-ffi/src/ancestors.rs b/rust/hg-direct-ffi/src/ancestors.rs
index 1bf3e6041e2c682ea1ba717a9bb8901172ba1bb8_cnVzdC9oZy1kaXJlY3QtZmZpL3NyYy9hbmNlc3RvcnMucnM=..a91a2837150bdcb27ae76b3646e6c93cd6a15904_cnVzdC9oZy1kaXJlY3QtZmZpL3NyYy9hbmNlc3RvcnMucnM= 100644
--- a/rust/hg-direct-ffi/src/ancestors.rs
+++ b/rust/hg-direct-ffi/src/ancestors.rs
@@ -60,8 +60,8 @@
 pub extern "C" fn rustlazyancestors_init(
     index: IndexPtr,
     parents: IndexParentsFn,
-    initrevslen: usize,
+    initrevslen: ssize_t,
     initrevs: *mut c_long,
     stoprev: c_long,
     inclusive: c_int,
 ) -> *mut AncestorsIterator<Index> {
@@ -64,7 +64,8 @@
     initrevs: *mut c_long,
     stoprev: c_long,
     inclusive: c_int,
 ) -> *mut AncestorsIterator<Index> {
+    assert!(initrevslen >= 0);
     unsafe {
         raw_init(
             Index::new(index, parents),
@@ -68,7 +69,7 @@
     unsafe {
         raw_init(
             Index::new(index, parents),
-            initrevslen,
+            initrevslen as usize,
             initrevs,
             stoprev,
             inclusive,