Mercurial > hg
changeset 45482:9a99ab8217bd
scmutil: introduce filterrequirements() to split reqs into wc and store ones
In upcoming patches where we try to implement requirements in store, we will
need a mechanism to split all requirements on some basis and decide which one
goes to `.hg/requires` and which one goes to `.hg/store/requires`.
This patch introduce a separate function for that. Filtering logic for now is
put under an `if False:`. In upcoming patches it will be removed.
Differential Revision: https://phab.mercurial-scm.org/D8913
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 16:11:19 +0530 |
parents | bddc4f2ef317 |
children | d252f51ab032 |
files | mercurial/scmutil.py |
diffstat | 1 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/scmutil.py Thu Sep 17 18:28:53 2020 -0700 +++ b/mercurial/scmutil.py Fri Aug 07 16:11:19 2020 +0530 @@ -38,6 +38,7 @@ phases, policy, pycompat, + requirements as requirementsmod, revsetlang, similar, smartset, @@ -1470,11 +1471,34 @@ repo._quick_access_changeid_invalidate() +def filterrequirements(requirements): + """ filters the requirements into two sets: + + wcreq: requirements which should be written in .hg/requires + storereq: which should be written in .hg/store/requires + + Returns (wcreq, storereq) + """ + if False: + wc, store = set(), set() + for r in requirements: + if r in requirementsmod.WORKING_DIR_REQUIREMENTS: + wc.add(r) + else: + store.add(r) + return wc, store + return requirements, None + + def writereporequirements(repo, requirements=None): """ writes requirements for the repo to .hg/requires """ if requirements: repo.requirements = requirements - writerequires(repo.vfs, repo.requirements) + wcreq, storereq = filterrequirements(repo.requirements) + if wcreq is not None: + writerequires(repo.vfs, wcreq) + if storereq is not None: + writerequires(repo.svfs, storereq) def writerequires(opener, requirements):