Skip to content
Snippets Groups Projects
Commit 335ae4d0 authored by Gregory Szorc's avatar Gregory Szorc
Browse files

bundlerepo: dynamically create repository type from base repository

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()``.

Differential Revision: https://phab.mercurial-scm.org/D4555
parent a8d2faec
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment