Page MenuHomePhabricator

cext: obtain reference to index entry type
Needs RevisionPublic

Authored by indygreg on Dec 26 2017, 7:35 PM.

Details

Reviewers
yuja
durin42
baymax
Group Reviewers
hg-reviewers
Summary

We recently introduced a dedicated type for index entries in the
pure Python implementation.

This commit tells the revlog C code about that type.

We register the type on the parsers module so it is exposed to
importers of the module.

In addition, we store a reference to the type on revlog index
instances. In theory, we could grab the reference from the
module. However, this requires a fair bit of C code. It is easier
to just re-import the original module and get a ref from there. This
also avoids problems with caching a type on a reload()d module.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Dec 26 2017, 7:35 PM
yuja requested changes to this revision.Jan 4 2018, 11:54 PM
yuja added a subscriber: yuja.

We hold off incrementing the version of the "parsers" extension
because nothing in core relies on the new API yet.

It's really minor nit, but we have to increment the version since new
compiled module doesn't work with old pure.parsers module, which
provides no IndexV1Entry type.

mercurial/cext/revlog.c
2117

Can we be sure that this IndexV1Entry is identical to self->entrytype
after reloading Python modules?

This revision now requires changes to proceed.Jan 4 2018, 11:54 PM
indygreg added inline comments.Jan 6 2018, 2:11 AM
mercurial/cext/revlog.c
2117

In theory, there could be a mismatch.

If this module is loaded, its IndexV1Entry will refer to whatever mercurial.pure.parsers.IndexV1Entry is. If mercurial.pure.parsers is then reloaded and its IndexV1Entry changes and a revlog index type is created, its IndexV1Entry will be the new one from the reloaded mercurial.pure.parsers.

Since I plan to replace the Python-implemented type with a C backed type, I'm inclined to not care about this.

indygreg edited the summary of this revision. (Show Details)Jan 6 2018, 3:26 AM
indygreg updated this revision to Diff 4737.
durin42 accepted this revision.Jan 10 2018, 5:54 PM
baymax requested changes to this revision.Jan 24 2020, 12:33 PM

There seems to have been no activities on this Diff for the past 3 Months.

By policy, we are automatically moving it out of the need-review state.

Please, move it back to need-review without hesitation if this diff should still be discussed.

:baymax:need-review-idle:

This revision now requires changes to proceed.Jan 24 2020, 12:33 PM