mercurial/localrepo.py
changeset 39852 2c2fadbc9851
parent 39850 d89d5bc06eaa
child 39854 823a580448d7
equal deleted inserted replaced
39851:1f7b3b980af8 39852:2c2fadbc9851
   444     # The .hg/hgrc file may load extensions or contain config options
   444     # The .hg/hgrc file may load extensions or contain config options
   445     # that influence repository construction. Attempt to load it and
   445     # that influence repository construction. Attempt to load it and
   446     # process any new extensions that it may have pulled in.
   446     # process any new extensions that it may have pulled in.
   447     try:
   447     try:
   448         ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
   448         ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
       
   449         # Run this before extensions.loadall() so extensions can be
       
   450         # automatically enabled.
       
   451         afterhgrcload(ui, wdirvfs, hgvfs, requirements)
   449     except IOError:
   452     except IOError:
   450         pass
   453         pass
   451     else:
   454     else:
   452         extensions.loadall(ui)
   455         extensions.loadall(ui)
   453 
   456 
   569         sharedpath=storebasepath,
   572         sharedpath=storebasepath,
   570         store=store,
   573         store=store,
   571         cachevfs=cachevfs,
   574         cachevfs=cachevfs,
   572         features=features,
   575         features=features,
   573         intents=intents)
   576         intents=intents)
       
   577 
       
   578 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
       
   579     """Perform additional actions after .hg/hgrc is loaded.
       
   580 
       
   581     This function is called during repository loading immediately after
       
   582     the .hg/hgrc file is loaded and before per-repo extensions are loaded.
       
   583 
       
   584     The function can be used to validate configs, automatically add
       
   585     options (including extensions) based on requirements, etc.
       
   586     """
       
   587 
       
   588     # Map of requirements to list of extensions to load automatically when
       
   589     # requirement is present.
       
   590     autoextensions = {
       
   591         b'lfs': [b'lfs'],
       
   592     }
       
   593 
       
   594     for requirement, names in sorted(autoextensions.items()):
       
   595         if requirement not in requirements:
       
   596             continue
       
   597 
       
   598         for name in names:
       
   599             if not ui.hasconfig(b'extensions', name):
       
   600                 ui.setconfig(b'extensions', name, b'', source='autoload')
   574 
   601 
   575 def gathersupportedrequirements(ui):
   602 def gathersupportedrequirements(ui):
   576     """Determine the complete set of recognized requirements."""
   603     """Determine the complete set of recognized requirements."""
   577     # Start with all requirements supported by this file.
   604     # Start with all requirements supported by this file.
   578     supported = set(localrepository._basesupported)
   605     supported = set(localrepository._basesupported)