[PATCH 1 of 2] upgraderepo: allow extension to register preserved requirements

Boris Feld boris.feld at octobus.net
Thu Dec 7 12:06:09 UTC 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1512607914 -3600
#      Thu Dec 07 01:51:54 2017 +0100
# Node ID 858933ee312507ecd05498ff72f7c4f7a4802b80
# Parent  fcc96cf0983d01c542a9b5e529b434b98941371d
# EXP-Topic updaterepo.largefiles
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 858933ee3125
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.

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -94,6 +94,9 @@ def allowednewrequirements(repo):
         'generaldelta',
     }
 
+def preservedrequirements(repo):
+    return set()
+
 deficiency = 'deficiency'
 optimisation = 'optimization'
 
@@ -679,6 +682,7 @@ def upgraderepo(ui, repo, run=False, opt
     # 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))


More information about the Mercurial-devel mailing list