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

login
register
mail settings
Submitter Boris Feld
Date Dec. 7, 2017, 12:06 p.m.
Message ID <858933ee312507ecd054.1512648369@FB>
Download mbox | patch
Permalink /patch/25993/
State Accepted
Headers show

Comments

Boris Feld - Dec. 7, 2017, 12:06 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@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.

Patch

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))