localrepo: add requirement when narrow files creation option present
The previous commit taught hg.clone() to define a creation option
when file include or exclude patterns are passed.
This commit teaches the new repo creation code to convert that creation
option into a repository requirement.
While not yet used by the narrow extension, the eventual side-effect
of this change is that newly-created repositories will have the narrow
requirement from their creation onset. Currently, the requirement is
added to the repo at exchange.pull() time via a wrapped function in
the narrow extension.
Differential Revision: https://phab.mercurial-scm.org/D4537
--- a/mercurial/localrepo.py Tue Sep 11 17:15:35 2018 -0700
+++ b/mercurial/localrepo.py Tue Sep 11 14:16:05 2018 -0700
@@ -2440,6 +2440,9 @@
if ui.configbool('format', 'internal-phase'):
requirements.add('internal-phase')
+ if createopts.get('narrowfiles'):
+ requirements.add(repository.NARROW_REQUIREMENT)
+
return requirements
def filterknowncreateopts(ui, createopts):
@@ -2456,7 +2459,9 @@
Extensions can wrap this function to filter out creation options
they know how to handle.
"""
- return dict(createopts)
+ known = {'narrowfiles'}
+
+ return {k: v for k, v in createopts.items() if k not in known}
def createrepository(ui, wdirvfs, createopts=None):
"""Create a new repository in a vfs.