[Commented On] D10848: createrepository: allow to directly pass the target requirements

baymax (Baymax, Your Personal Patch-care Companion) phabricator at mercurial-scm.org
Mon Jun 21 05:10:44 UTC 2021


baymax added a comment.
baymax updated this revision to Diff 28618.


  ✅ refresh by Heptapod after a successful CI run (🐙 💚)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10848?vs=28570&id=28618

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10848/new/

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, pulkit, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210621/dcffa26f/attachment-0002.html>


More information about the Mercurial-patches mailing list