Patchwork D10849: localrepo: introduce a clone_requirements function

login
register
mail settings
Submitter phabricator
Date June 9, 2021, 2:38 p.m.
Message ID <differential-rev-PHID-DREV-gikg23vnxp6evkn5g5qw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49171/
State Superseded
Headers show

Comments

phabricator - June 9, 2021, 2:38 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10849

AFFECTED FILES
  mercurial/localrepo.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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.