mercurial/localrepo.py
changeset 47440 e43e68624dfb
parent 47421 d2e0226b511a
child 47441 e33c6dd346e7
equal deleted inserted replaced
47439:86418ad637d1 47440:e43e68624dfb
  3675     }
  3675     }
  3676 
  3676 
  3677     return {k: v for k, v in createopts.items() if k not in known}
  3677     return {k: v for k, v in createopts.items() if k not in known}
  3678 
  3678 
  3679 
  3679 
  3680 def createrepository(ui, path, createopts=None):
  3680 def createrepository(ui, path, createopts=None, requirements=None):
  3681     """Create a new repository in a vfs.
  3681     """Create a new repository in a vfs.
  3682 
  3682 
  3683     ``path`` path to the new repo's working directory.
  3683     ``path`` path to the new repo's working directory.
  3684     ``createopts`` options for the new repository.
  3684     ``createopts`` options for the new repository.
       
  3685     ``requirement`` predefined set of requirements.
       
  3686                     (incompatible with ``createopts``)
  3685 
  3687 
  3686     The following keys for ``createopts`` are recognized:
  3688     The following keys for ``createopts`` are recognized:
  3687 
  3689 
  3688     backend
  3690     backend
  3689        The storage backend to use.
  3691        The storage backend to use.
  3702        Set of items to share to the new repository (in addition to storage).
  3704        Set of items to share to the new repository (in addition to storage).
  3703     shallowfilestore
  3705     shallowfilestore
  3704        Indicates that storage for files should be shallow (not all ancestor
  3706        Indicates that storage for files should be shallow (not all ancestor
  3705        revisions are known).
  3707        revisions are known).
  3706     """
  3708     """
  3707     createopts = defaultcreateopts(ui, createopts=createopts)
  3709 
  3708 
  3710     if requirements is not None:
  3709     unknownopts = filterknowncreateopts(ui, createopts)
  3711         if createopts is not None:
  3710 
  3712             msg = b'cannot specify both createopts and requirements'
  3711     if not isinstance(unknownopts, dict):
  3713             raise error.ProgrammingError(msg)
  3712         raise error.ProgrammingError(
  3714         createopts = {}
  3713             b'filterknowncreateopts() did not return a dict'
  3715     else:
  3714         )
  3716         createopts = defaultcreateopts(ui, createopts=createopts)
  3715 
  3717 
  3716     if unknownopts:
  3718         unknownopts = filterknowncreateopts(ui, createopts)
  3717         raise error.Abort(
  3719 
  3718             _(
  3720         if not isinstance(unknownopts, dict):
  3719                 b'unable to create repository because of unknown '
  3721             raise error.ProgrammingError(
  3720                 b'creation option: %s'
  3722                 b'filterknowncreateopts() did not return a dict'
  3721             )
  3723             )
  3722             % b', '.join(sorted(unknownopts)),
  3724 
  3723             hint=_(b'is a required extension not loaded?'),
  3725         if unknownopts:
  3724         )
  3726             raise error.Abort(
  3725 
  3727                 _(
  3726     requirements = newreporequirements(ui, createopts=createopts)
  3728                     b'unable to create repository because of unknown '
  3727     requirements -= checkrequirementscompat(ui, requirements)
  3729                     b'creation option: %s'
       
  3730                 )
       
  3731                 % b', '.join(sorted(unknownopts)),
       
  3732                 hint=_(b'is a required extension not loaded?'),
       
  3733             )
       
  3734 
       
  3735         requirements = newreporequirements(ui, createopts=createopts)
       
  3736         requirements -= checkrequirementscompat(ui, requirements)
  3728 
  3737 
  3729     wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
  3738     wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
  3730 
  3739 
  3731     hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
  3740     hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
  3732     if hgvfs.exists():
  3741     if hgvfs.exists():