Mercurial > hg
comparison mercurial/bundlerepo.py @ 39549:089fc0db0954
hg: allow extra arguments to be passed to repo creation (API)
Currently, repository creation is influenced by consulting the
ui instance and turning config options into requirements. This
means that in order to influence repository creation, you need
to define and set a config option and that the option must translate
to a requirement stored in the .hg/requires file.
This commit introduces a new mechanism to influence repository
creation. hg.repository() and hg.peer() have been taught to
receive a new optional argument defining extra options to apply
to repository creation. This value is passed along to the various
instance() functions and can be used to influence repository
creation. This will allow us to pass rich data directly to repository
creation without having to go through the config layer. It also allows
us to be more explicit about the features requested during repository
creation and provides a natural point to detect unhandled options
influencing repository creation. The new code detects when unknown
creation options are present and aborts in that case.
.. api:: options can now be passed to influence repository creation
The various instance() functions to spawn new peers or repository
instances now receive a ``createopts`` argument that can be a
dict defining additional options to influence repository creation.
localrepo.newreporequirements() also receives this argument.
Differential Revision: https://phab.mercurial-scm.org/D4535
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 11 Sep 2018 17:11:32 -0700 |
parents | 0d97530eb535 |
children | 2d2bbf3f3e09 |
comparison
equal
deleted
inserted
replaced
39548:7ce9dea3a14a | 39549:089fc0db0954 |
---|---|
447 self.ui.warn(msg % nodemod.hex(p1)) | 447 self.ui.warn(msg % nodemod.hex(p1)) |
448 if self.changelog.repotiprev < p2rev: | 448 if self.changelog.repotiprev < p2rev: |
449 self.ui.warn(msg % nodemod.hex(p2)) | 449 self.ui.warn(msg % nodemod.hex(p2)) |
450 return super(bundlerepository, self).setparents(p1, p2) | 450 return super(bundlerepository, self).setparents(p1, p2) |
451 | 451 |
452 def instance(ui, path, create, intents=None): | 452 def instance(ui, path, create, intents=None, createopts=None): |
453 if create: | 453 if create: |
454 raise error.Abort(_('cannot create new bundle repository')) | 454 raise error.Abort(_('cannot create new bundle repository')) |
455 # internal config: bundle.mainreporoot | 455 # internal config: bundle.mainreporoot |
456 parentpath = ui.config("bundle", "mainreporoot") | 456 parentpath = ui.config("bundle", "mainreporoot") |
457 if not parentpath: | 457 if not parentpath: |