changeset 47447:e33c6dd346e7

localrepo: introduce a clone_requirements function This function take a source repository and return a relevant set of requirements that should be used by a copy clone. This will help make the creation of the destination repository during copy clone simpler. Differential Revision: https://phab.mercurial-scm.org/D10849
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 09 Jun 2021 01:10:26 +0200
parents e43e68624dfb
children d1c1fd7ac46d
files mercurial/localrepo.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Jun 07 20:40:43 2021 +0200
+++ b/mercurial/localrepo.py	Wed Jun 09 01:10:26 2021 +0200
@@ -3485,6 +3485,24 @@
     return createopts
 
 
+def clone_requirements(ui, createopts, srcrepo):
+    """clone the requirements of a local repo for a local clone
+
+    The store requirements are unchanged while the working copy requirements
+    depends on the configuration
+    """
+    target_requirements = set()
+    createopts = defaultcreateopts(ui, createopts=createopts)
+    for r in newreporequirements(ui, createopts):
+        if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
+            target_requirements.add(r)
+
+    for r in srcrepo.requirements:
+        if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
+            target_requirements.add(r)
+    return target_requirements
+
+
 def newreporequirements(ui, createopts):
     """Determine the set of requirements for a new local repository.