( )⚙ D7418 procutil: teach resourcereader() to handle exe relative resources

This is an archive of the discontinued Mercurial Phabricator instance.

procutil: teach resourcereader() to handle exe relative resources
Changes PlannedPublic

Authored by indygreg on Nov 14 2019, 10:58 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary

Mercurial distributions like those produced with py2exe store
their data/resource files relative to the executable. For
example, in our Windows distributions, help files are in
the help/ directory relative to hg.exe.

In a future world where we are using the ResourceReader API
for accessing package resources, we need a way to provide
a ResourceReader for these pieces of data without breaking
these Mercurial distributions.

This commit introduces logic into resourcereader() which will
return a filesystem-based ResourceReader if resources are
relative to the executable and we are requesting resources for
the "mercurial" package.

Ideally we wouldn't need to do this and would instead change
packaging. However, various downstream consumers may be sensitive
to changes in the on-disk layout of Mercurial installs. I'm
unwilling to cross this bridge at this time. I think it is more
important to get things working with the ResourceReader API first.
Then we can tackle better resource packaging/installation.

It is also likely that we'll need more logic to handle additional
packages/resources. For example, help resources are always in a
help/ directory and map cleanly, but templates resources are in a
Templates/ directory and there are case-sensitivity concerns.
Our initial target for using the resource reading API is help.
So we can defer on additional complexity.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

indygreg created this revision.Nov 14 2019, 10:58 PM
indygreg planned changes to this revision.Nov 14 2019, 11:02 PM

The commit message on this one is probably a bit out of date, since packaging has changed some since I initially authored this commit.