localrepo: add requirement when narrow files creation option present
authorGregory Szorc <gregory.szorc@gmail.com>
Tue, 11 Sep 2018 14:16:05 -0700
changeset 39551 261f1e8dc300
parent 39550 65b5900f30be
child 39552 4c807ec07888
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
mercurial/localrepo.py
--- 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.