ensure: provide the ability to use alternate paths to do the initial cloning
2 files changed, 15 insertions(+), 4 deletions(-)

M hgext3rd/confman/commands.py
M hgext3rd/confman/configuration.py
M hgext3rd/confman/commands.py +2 -2
@@ 63,7 63,7 @@ def command(name, opts):
 
 
 @command('cfensureconf',
-         DEFAULTOPTS + REMOTEOPTS + [
+         DEFAULTOPTS + REMOTEOPTS + [PULLURIOPT] + [
              ('s', 'share-path', '', 'specify share path'),
              ('', 'keep-descendant', False,
               'do not update managed if it is on a descendant of track')])

          
@@ 85,7 85,7 @@ def ensureconf(ui, repo, *args, **opts):
 
     """
     confman, repo = readconf(ui, repo, args, opts)
-    confman.fill_missing()
+    confman.fill_missing(opts)
 
     snaps = confman.readsnapshot()
 

          
M hgext3rd/confman/configuration.py +13 -2
@@ 163,7 163,7 @@ class configurationmanager(object):
                 return newuri
         return uri
 
-    def fill_missing(self):
+    def fill_missing(self, opts):
         "Try to clone the missing managed repositories if possible"
         from .managed import repoclassbyconf
         ui = self.ui

          
@@ 175,7 175,18 @@ class configurationmanager(object):
             dest = self.pathfromsection(section)
             if not os.path.exists(dest):
                 os.makedirs(dest)
-            source = conf['pulluri'].format(**conf)
+
+            # compute the source
+            usehgrcpath = opts.get('use_hgrc_path')
+            if usehgrcpath:
+                source = conf.get(f'hgrc.paths.{usehgrcpath}')
+                if not source:
+                    ui.warn(f'no such path: `{usehgrcpath}`')
+            if not source:
+                # fallback to the default uri
+                source = conf['pulluri'].format(**conf)
+
+            # clone
             ui.status('cloning %s from %s to %s\n' % (section, source, dest))
             try:
                 path = self.pathfromsection(section)