diff mercurial/changegroup.py @ 45558:10284ce3d5ed

scmutil: introduce function to check whether repo uses treemanifest or not In an upcoming patch, I wanted to check whether current repo uses treemanifest or not. I looked for a function and found that at all places we manually check for the requirement in repo requirements. I guess having a dedicated function for that is much better. Differential Revision: https://phab.mercurial-scm.org/D8981
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 01 Sep 2020 18:08:24 +0530
parents 77b8588dd84e
children 44d84b726c8a
line wrap: on
line diff
--- a/mercurial/changegroup.py	Thu Sep 03 11:07:47 2020 -0400
+++ b/mercurial/changegroup.py	Tue Sep 01 18:08:24 2020 +0530
@@ -27,6 +27,7 @@
     phases,
     pycompat,
     requirements,
+    scmutil,
     util,
 )
 
@@ -949,9 +950,7 @@
         # Treemanifests don't work correctly with fastpathlinkrev
         # either, because we don't discover which directory nodes to
         # send along with files. This could probably be fixed.
-        fastpathlinkrev = fastpathlinkrev and (
-            requirements.TREEMANIFEST_REQUIREMENT not in repo.requirements
-        )
+        fastpathlinkrev = fastpathlinkrev and not scmutil.istreemanifest(repo)
 
         fnodes = {}  # needed file nodes
 
@@ -1468,7 +1467,7 @@
     if (
         repo.ui.configbool(b'experimental', b'changegroup3')
         or repo.ui.configbool(b'experimental', b'treemanifest')
-        or requirements.TREEMANIFEST_REQUIREMENT in repo.requirements
+        or scmutil.istreemanifest(repo)
     ):
         # we keep version 03 because we need to to exchange treemanifest data
         #
@@ -1496,7 +1495,7 @@
 # Changegroup versions that can be created from the repo
 def supportedoutgoingversions(repo):
     versions = allsupportedversions(repo)
-    if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements:
+    if scmutil.istreemanifest(repo):
         # Versions 01 and 02 support only flat manifests and it's just too
         # expensive to convert between the flat manifest and tree manifest on
         # the fly. Since tree manifests are hashed differently, all of history