[Request] [+-- ] D10848: createrepository: allow to directly pass the target requirements
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Jun 9 14:38:37 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This is useful when doing a local clone that copies store contents, it will
requires the destination to use the very same store requirements so directly
providing them will be simpler and safer
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10848
AFFECTED FILES
mercurial/localrepo.py
CHANGE DETAILS
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3677,11 +3677,13 @@
return {k: v for k, v in createopts.items() if k not in known}
-def createrepository(ui, path, createopts=None):
+def createrepository(ui, path, createopts=None, requirements=None):
"""Create a new repository in a vfs.
``path`` path to the new repo's working directory.
``createopts`` options for the new repository.
+ ``requirement`` predefined set of requirements.
+ (incompatible with ``createopts``)
The following keys for ``createopts`` are recognized:
@@ -3704,27 +3706,34 @@
Indicates that storage for files should be shallow (not all ancestor
revisions are known).
"""
- createopts = defaultcreateopts(ui, createopts=createopts)
-
- unknownopts = filterknowncreateopts(ui, createopts)
-
- if not isinstance(unknownopts, dict):
- raise error.ProgrammingError(
- b'filterknowncreateopts() did not return a dict'
- )
-
- if unknownopts:
- raise error.Abort(
- _(
- b'unable to create repository because of unknown '
- b'creation option: %s'
+
+ if requirements is not None:
+ if createopts is not None:
+ msg = b'cannot specify both createopts and requirements'
+ raise error.ProgrammingError(msg)
+ createopts = {}
+ else:
+ createopts = defaultcreateopts(ui, createopts=createopts)
+
+ unknownopts = filterknowncreateopts(ui, createopts)
+
+ if not isinstance(unknownopts, dict):
+ raise error.ProgrammingError(
+ b'filterknowncreateopts() did not return a dict'
)
- % b', '.join(sorted(unknownopts)),
- hint=_(b'is a required extension not loaded?'),
- )
-
- requirements = newreporequirements(ui, createopts=createopts)
- requirements -= checkrequirementscompat(ui, requirements)
+
+ if unknownopts:
+ raise error.Abort(
+ _(
+ b'unable to create repository because of unknown '
+ b'creation option: %s'
+ )
+ % b', '.join(sorted(unknownopts)),
+ hint=_(b'is a required extension not loaded?'),
+ )
+
+ requirements = newreporequirements(ui, createopts=createopts)
+ requirements -= checkrequirementscompat(ui, requirements)
wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210609/a4331530/attachment-0001.html>
More information about the Mercurial-patches
mailing list