This is an archive of the discontinued Mercurial Phabricator instance.

hg: allow extra arguments to be passed to repo creation
ClosedPublic

Authored by indygreg on Sep 11 2018, 8:27 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Sep 11 2018, 8:27 PM
yuja added a subscriber: yuja.Sep 12 2018, 8:43 AM

+def filterknowncreateopts(ui, createopts):
+ """Filters a dict of repo creation options against options that are known.

Nit: I thought this would select only known options.

+ raise error.Abort(_('unable to create repository because of unknown '
+ 'creation option: %s') %
+ ', '.sorted(unknownopts.keys()),

Removed .keys() to make it clearer that we don't need a new list on Py2.

This revision was automatically updated to reflect the committed changes.