This is an archive of the discontinued Mercurial Phabricator instance.

bundlerepo: dynamically create repository type from base repository
ClosedPublic

Authored by indygreg on Sep 12 2018, 10:02 PM.

Details

Summary

Previously, bundlerepository inherited from localrepo.localrepository.
You simply instantiated a bundlerepository and its init called
localrepo.localrepository.init. Things were simple.

Unfortunately, this strategy is limiting because it assumes that
the base repository is a localrepository instance. And it assumes
various properties of localrepository, such as the arguments its
init takes. And it prevents us from changing behavior of
localrepository.init without also having to change derived classes.

Previous and ongoing work to abstract storage revealed these
limitations.

This commit changes the initialization strategy of bundle repositories
to dynamically create a type to represent the repository. Instead of
a static type, we instantiate a new local repo instance via
localrepo.instance(). We then combine its class with
bundlerepository to produce a new type. This ensures that no matter
how localrepo.instance() decides to create a repository object, we
can derive a bundle repo object from it. i.e. localrepo.instance()
could return a type that isn't a localrepository and it would "just
work."

Well, it would "just work" if bundlerepository's custom implementations
only accessed attributes in the documented repository interface. I'm
pretty sure it violates the interface contract in a handful of
places. But we can worry about that another day. This change gets us
closer to doing more clever things around instantiating repository
instances without having to worry about teaching bundlerepository about
them.

.. api::

``bundlerepo.bundlerepository`` is no longer usable on its own.

The class is combined with the class of the base repository it is
associated with at run-time.

New bundlerepository instances can be obtained by calling
``bundlerepo.instance()`` or ``bundlerepo.makebundlerepository()``.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped