comparison mercurial/changegroup.py @ 45552: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
comparison
equal deleted inserted replaced
45551:4c8d9b53b1c7 45552:10284ce3d5ed
25 match as matchmod, 25 match as matchmod,
26 mdiff, 26 mdiff,
27 phases, 27 phases,
28 pycompat, 28 pycompat,
29 requirements, 29 requirements,
30 scmutil,
30 util, 31 util,
31 ) 32 )
32 33
33 from .interfaces import repository 34 from .interfaces import repository
34 35
947 # cc0ff93d0c0c. 948 # cc0ff93d0c0c.
948 949
949 # Treemanifests don't work correctly with fastpathlinkrev 950 # Treemanifests don't work correctly with fastpathlinkrev
950 # either, because we don't discover which directory nodes to 951 # either, because we don't discover which directory nodes to
951 # send along with files. This could probably be fixed. 952 # send along with files. This could probably be fixed.
952 fastpathlinkrev = fastpathlinkrev and ( 953 fastpathlinkrev = fastpathlinkrev and not scmutil.istreemanifest(repo)
953 requirements.TREEMANIFEST_REQUIREMENT not in repo.requirements
954 )
955 954
956 fnodes = {} # needed file nodes 955 fnodes = {} # needed file nodes
957 956
958 size = 0 957 size = 0
959 it = self.generatemanifests( 958 it = self.generatemanifests(
1466 versions = set(_packermap.keys()) 1465 versions = set(_packermap.keys())
1467 needv03 = False 1466 needv03 = False
1468 if ( 1467 if (
1469 repo.ui.configbool(b'experimental', b'changegroup3') 1468 repo.ui.configbool(b'experimental', b'changegroup3')
1470 or repo.ui.configbool(b'experimental', b'treemanifest') 1469 or repo.ui.configbool(b'experimental', b'treemanifest')
1471 or requirements.TREEMANIFEST_REQUIREMENT in repo.requirements 1470 or scmutil.istreemanifest(repo)
1472 ): 1471 ):
1473 # we keep version 03 because we need to to exchange treemanifest data 1472 # we keep version 03 because we need to to exchange treemanifest data
1474 # 1473 #
1475 # we also keep vresion 01 and 02, because it is possible for repo to 1474 # we also keep vresion 01 and 02, because it is possible for repo to
1476 # contains both normal and tree manifest at the same time. so using 1475 # contains both normal and tree manifest at the same time. so using
1494 1493
1495 1494
1496 # Changegroup versions that can be created from the repo 1495 # Changegroup versions that can be created from the repo
1497 def supportedoutgoingversions(repo): 1496 def supportedoutgoingversions(repo):
1498 versions = allsupportedversions(repo) 1497 versions = allsupportedversions(repo)
1499 if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: 1498 if scmutil.istreemanifest(repo):
1500 # Versions 01 and 02 support only flat manifests and it's just too 1499 # Versions 01 and 02 support only flat manifests and it's just too
1501 # expensive to convert between the flat manifest and tree manifest on 1500 # expensive to convert between the flat manifest and tree manifest on
1502 # the fly. Since tree manifests are hashed differently, all of history 1501 # the fly. Since tree manifests are hashed differently, all of history
1503 # would have to be converted. Instead, we simply don't even pretend to 1502 # would have to be converted. Instead, we simply don't even pretend to
1504 # support versions 01 and 02. 1503 # support versions 01 and 02.