upgraderepo: allow extension to register preserved requirements
authorBoris Feld <boris.feld@octobus.net>
Thu, 07 Dec 2017 01:51:54 +0100
changeset 35302 ad2b35ebf670
parent 35301 d67bcfc0041f
child 35303 67b7e39b441b
upgraderepo: allow extension to register preserved requirements Some requirement does not directly result from config and needs more advanced logic to be preserved. The current example is 'largefiles'. We add a hook point in the upgrade code so that extensions can handle these cases. The 'largefiles' extension will use it in the next changeset.
mercurial/upgrade.py
--- a/mercurial/upgrade.py	Thu Sep 22 19:41:42 2016 +0900
+++ b/mercurial/upgrade.py	Thu Dec 07 01:51:54 2017 +0100
@@ -94,6 +94,9 @@
         'generaldelta',
     }
 
+def preservedrequirements(repo):
+    return set()
+
 deficiency = 'deficiency'
 optimisation = 'optimization'
 
@@ -679,6 +682,7 @@
     # FUTURE there is potentially a need to control the wanted requirements via
     # command arguments or via an extension hook point.
     newreqs = localrepo.newreporequirements(repo)
+    newreqs.update(preservedrequirements(repo))
 
     noremovereqs = (repo.requirements - newreqs -
                    supportremovedrequirements(repo))