[PATCH 3 of 3 STABLE] rust: propagate Python exception raised from index_get_parents_checked()

Georges Racinet gracinet at anybox.fr
Tue Oct 30 10:48:43 EDT 2018


On 10/29/2018 02:03 PM, Yuya Nishihara wrote:
> On Sun, 28 Oct 2018 22:11:03 +0900, Yuya Nishihara wrote:
>> # HG changeset patch
>> # User Yuya Nishihara <yuya at tcha.org>
>> # Date 1540730473 -32400
>> #      Sun Oct 28 21:41:13 2018 +0900
>> # Branch stable
>> # Node ID c40ceec4d993927b6788ad430dc6b4f3087d9aeb
>> # Parent  28a5ec244ba88ce4a46a26a32c24fa36f7597245
>> rust: propagate Python exception raised from index_get_parents_checked()
>>  static int rustla_contains(rustlazyancestorsObject *self, PyObject *rev) {
>> +	int res;
>>  	if (!(PyInt_Check(rev))) {
>>  		return 0;
as a reminder, this one, that you don't modify also takes care of the
case of None, for which there is an explicit comment in the Python
implementation.
>>  	}
>> -	return rustlazyancestors_contains(self->iter, PyInt_AS_LONG(rev));
>> +	res = rustlazyancestors_contains(self->iter, PyInt_AS_LONG(rev));
>> +	if (PyErr_Occurred())
>> +		return -1;
>> +	return res;
> Not that a proper fix is to make AncestorsIterator functions return
> Result<_, GraphError>. I can send the patch for stable if it's preferred.
Returning Result<_, GraphError> as much as possible is my intent indeed,
but it wouldn't apply to next(), because the Iterator trait does not
allow for that, unless we change the signature to an Iterator with Item
= Result<Revision, GraphError>. I didn't dare to do that earlier, as it
seemed to be too heavy.

That being said, I'm not sure how much of these errors (bad stoprev etc)
we can get rid of from the start. The more serious case would be that of
the corrupted index, though, in which a correct initialization can still
give rise to errors later on.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


-- 
Georges Racinet
Anybox SAS, http://anybox.fr
Téléphone: +33 6 51 32 07 27
GPG: B59E 22AB B842 CAED 77F7 7A7F C34F A519 33AB 0A35, sur serveurs publics




More information about the Mercurial-devel mailing list