##// END OF EJS Templates
localrepo: define storage backend in creation options (API)...
Gregory Szorc -
r40032:dbcb466d default
parent child Browse files
Show More
@@ -941,6 +941,9 b" coreconfigitem('progress', 'width',"
941 coreconfigitem('push', 'pushvars.server',
941 coreconfigitem('push', 'pushvars.server',
942 default=False,
942 default=False,
943 )
943 )
944 coreconfigitem('storage', 'new-repo-backend',
945 default='revlogv1',
946 )
944 coreconfigitem('storage', 'revlog.optimize-delta-parent-choice',
947 coreconfigitem('storage', 'revlog.optimize-delta-parent-choice',
945 default=True,
948 default=True,
946 alias=[('format', 'aggressivemergedeltas')],
949 alias=[('format', 'aggressivemergedeltas')],
@@ -2808,14 +2808,26 b' def instance(ui, path, create, intents=N'
2808 def islocal(path):
2808 def islocal(path):
2809 return True
2809 return True
2810
2810
2811 def newreporequirements(ui, createopts=None):
2811 def defaultcreateopts(ui, createopts=None):
2812 """Populate the default creation options for a repository.
2813
2814 A dictionary of explicitly requested creation options can be passed
2815 in. Missing keys will be populated.
2816 """
2817 createopts = dict(createopts or {})
2818
2819 if 'backend' not in createopts:
2820 # experimental config: storage.new-repo-backend
2821 createopts['backend'] = ui.config('storage', 'new-repo-backend')
2822
2823 return createopts
2824
2825 def newreporequirements(ui, createopts):
2812 """Determine the set of requirements for a new local repository.
2826 """Determine the set of requirements for a new local repository.
2813
2827
2814 Extensions can wrap this function to specify custom requirements for
2828 Extensions can wrap this function to specify custom requirements for
2815 new repositories.
2829 new repositories.
2816 """
2830 """
2817 createopts = createopts or {}
2818
2819 # If the repo is being created from a shared repository, we copy
2831 # If the repo is being created from a shared repository, we copy
2820 # its requirements.
2832 # its requirements.
2821 if 'sharedrepo' in createopts:
2833 if 'sharedrepo' in createopts:
@@ -2827,6 +2839,14 b' def newreporequirements(ui, createopts=N'
2827
2839
2828 return requirements
2840 return requirements
2829
2841
2842 if 'backend' not in createopts:
2843 raise error.ProgrammingError('backend key not present in createopts; '
2844 'was defaultcreateopts() called?')
2845
2846 if createopts['backend'] != 'revlogv1':
2847 raise error.Abort(_('unable to determine repository requirements for '
2848 'storage backend: %s') % createopts['backend'])
2849
2830 requirements = {'revlogv1'}
2850 requirements = {'revlogv1'}
2831 if ui.configbool('format', 'usestore'):
2851 if ui.configbool('format', 'usestore'):
2832 requirements.add('store')
2852 requirements.add('store')
@@ -2885,6 +2905,7 b' def filterknowncreateopts(ui, createopts'
2885 they know how to handle.
2905 they know how to handle.
2886 """
2906 """
2887 known = {
2907 known = {
2908 'backend',
2888 'narrowfiles',
2909 'narrowfiles',
2889 'sharedrepo',
2910 'sharedrepo',
2890 'sharedrelative',
2911 'sharedrelative',
@@ -2901,6 +2922,8 b' def createrepository(ui, path, createopt'
2901
2922
2902 The following keys for ``createopts`` are recognized:
2923 The following keys for ``createopts`` are recognized:
2903
2924
2925 backend
2926 The storage backend to use.
2904 narrowfiles
2927 narrowfiles
2905 Set up repository to support narrow file storage.
2928 Set up repository to support narrow file storage.
2906 sharedrepo
2929 sharedrepo
@@ -2912,7 +2935,7 b' def createrepository(ui, path, createopt'
2912 shareditems
2935 shareditems
2913 Set of items to share to the new repository (in addition to storage).
2936 Set of items to share to the new repository (in addition to storage).
2914 """
2937 """
2915 createopts = createopts or {}
2938 createopts = defaultcreateopts(ui, createopts=createopts)
2916
2939
2917 unknownopts = filterknowncreateopts(ui, createopts)
2940 unknownopts = filterknowncreateopts(ui, createopts)
2918
2941
@@ -199,7 +199,8 b' class requirementformatvariant(formatvar'
199
199
200 @staticmethod
200 @staticmethod
201 def _newreporequirements(ui):
201 def _newreporequirements(ui):
202 return localrepo.newreporequirements(ui)
202 return localrepo.newreporequirements(
203 ui, localrepo.defaultcreateopts(ui))
203
204
204 @classmethod
205 @classmethod
205 def fromrepo(cls, repo):
206 def fromrepo(cls, repo):
@@ -747,7 +748,8 b' def upgraderepo(ui, repo, run=False, opt'
747
748
748 # FUTURE there is potentially a need to control the wanted requirements via
749 # FUTURE there is potentially a need to control the wanted requirements via
749 # command arguments or via an extension hook point.
750 # command arguments or via an extension hook point.
750 newreqs = localrepo.newreporequirements(repo.ui)
751 newreqs = localrepo.newreporequirements(
752 repo.ui, localrepo.defaultcreateopts(repo.ui))
751 newreqs.update(preservedrequirements(repo))
753 newreqs.update(preservedrequirements(repo))
752
754
753 noremovereqs = (repo.requirements - newreqs -
755 noremovereqs = (repo.requirements - newreqs -
General Comments 0
You need to be logged in to leave comments. Login now