comparison mercurial/bundle2.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 d2e1dcd4490d
comparison
equal deleted inserted replaced
45551:4c8d9b53b1c7 45552:10284ce3d5ed
1962 # the source and url passed here are overwritten by the one contained in 1962 # the source and url passed here are overwritten by the one contained in
1963 # the transaction.hookargs argument. So 'bundle2' is a placeholder 1963 # the transaction.hookargs argument. So 'bundle2' is a placeholder
1964 nbchangesets = None 1964 nbchangesets = None
1965 if b'nbchanges' in inpart.params: 1965 if b'nbchanges' in inpart.params:
1966 nbchangesets = int(inpart.params.get(b'nbchanges')) 1966 nbchangesets = int(inpart.params.get(b'nbchanges'))
1967 if ( 1967 if b'treemanifest' in inpart.params and not scmutil.istreemanifest(op.repo):
1968 b'treemanifest' in inpart.params
1969 and requirements.TREEMANIFEST_REQUIREMENT not in op.repo.requirements
1970 ):
1971 if len(op.repo.changelog) != 0: 1968 if len(op.repo.changelog) != 0:
1972 raise error.Abort( 1969 raise error.Abort(
1973 _( 1970 _(
1974 b"bundle contains tree manifests, but local repo is " 1971 b"bundle contains tree manifests, but local repo is "
1975 b"non-empty and does not use tree manifests" 1972 b"non-empty and does not use tree manifests"
2575 changelog=False, 2572 changelog=False,
2576 ) 2573 )
2577 2574
2578 part = bundler.newpart(b'changegroup', data=cgdata) 2575 part = bundler.newpart(b'changegroup', data=cgdata)
2579 part.addparam(b'version', cgversion) 2576 part.addparam(b'version', cgversion)
2580 if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: 2577 if scmutil.istreemanifest(repo):
2581 part.addparam(b'treemanifest', b'1') 2578 part.addparam(b'treemanifest', b'1')
2582 if b'exp-sidedata-flag' in repo.requirements: 2579 if b'exp-sidedata-flag' in repo.requirements:
2583 part.addparam(b'exp-sidedata', b'1') 2580 part.addparam(b'exp-sidedata', b'1')
2584 2581
2585 return bundler 2582 return bundler