diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py --- a/hgext/narrow/narrowbundle2.py +++ b/hgext/narrow/narrowbundle2.py @@ -108,7 +108,7 @@ part = bundler.newpart(b'changegroup', data=cgdata) part.addparam(b'version', version) - if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: + if scmutil.istreemanifest(repo): part.addparam(b'treemanifest', b'1') @@ -163,7 +163,7 @@ part = bundler.newpart(b'changegroup', data=cgdata) part.addparam(b'version', version) - if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: + if scmutil.istreemanifest(repo): part.addparam(b'treemanifest', b'1') diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -23,7 +23,7 @@ extensions, match, pycompat, - requirements, + scmutil, store, streamclone, util, @@ -170,7 +170,7 @@ if kind == stat.S_IFDIR: visit.append(fp) - if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: + if scmutil.istreemanifest(repo): for (u, e, s) in repo.store.datafiles(): if u.startswith(b'meta/') and ( u.endswith(b'.i') or u.endswith(b'.d') diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1964,10 +1964,7 @@ nbchangesets = None if b'nbchanges' in inpart.params: nbchangesets = int(inpart.params.get(b'nbchanges')) - if ( - b'treemanifest' in inpart.params - and requirements.TREEMANIFEST_REQUIREMENT not in op.repo.requirements - ): + if b'treemanifest' in inpart.params and not scmutil.istreemanifest(op.repo): if len(op.repo.changelog) != 0: raise error.Abort( _( @@ -2577,7 +2574,7 @@ part = bundler.newpart(b'changegroup', data=cgdata) part.addparam(b'version', cgversion) - if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: + if scmutil.istreemanifest(repo): part.addparam(b'treemanifest', b'1') if b'exp-sidedata-flag' in repo.requirements: part.addparam(b'exp-sidedata', b'1') diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -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 diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -46,7 +46,6 @@ phases, pycompat, repair, - requirements, revlog, rewriteutil, scmutil, @@ -1359,7 +1358,7 @@ if cl: r = repo.unfiltered().changelog elif dir: - if requirements.TREEMANIFEST_REQUIREMENT not in repo.requirements: + if not scmutil.istreemanifest(repo): raise error.Abort( _( b"--dir can only be used on repos with " diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1068,7 +1068,7 @@ cgpart = bundler.newpart(b'changegroup', data=cgstream) if cgversions: cgpart.addparam(b'version', version) - if requirements.TREEMANIFEST_REQUIREMENT in pushop.repo.requirements: + if scmutil.istreemanifest(pushop.repo): cgpart.addparam(b'treemanifest', b'1') if b'exp-sidedata-flag' in pushop.repo.requirements: cgpart.addparam(b'exp-sidedata', b'1') @@ -2557,7 +2557,7 @@ part.addparam(b'nbchanges', b'%d' % len(outgoing.missing), mandatory=False) - if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: + if scmutil.istreemanifest(repo): part.addparam(b'treemanifest', b'1') if b'exp-sidedata-flag' in repo.requirements: diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -27,6 +27,7 @@ phases, pycompat, requirements, + scmutil, util, ) from .utils import ( @@ -419,7 +420,7 @@ def manifestrevlogs(repo): yield repo.manifestlog.getstorage(b'') - if requirements.TREEMANIFEST_REQUIREMENT in repo.requirements: + if scmutil.istreemanifest(repo): # This logic is safe if treemanifest isn't enabled, but also # pointless, so we skip it if treemanifest isn't enabled. for unencoded, encoded, size in repo.store.datafiles(): diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -38,6 +38,7 @@ phases, policy, pycompat, + requirements as requirementsmod, revsetlang, similar, smartset, @@ -1470,6 +1471,11 @@ repo._quick_access_changeid_invalidate() +def istreemanifest(repo): + """ returns whether the repository is using treemanifest or not """ + return requirementsmod.TREEMANIFEST_REQUIREMENT in repo.requirements + + def writereporequirements(repo, requirements=None): """ writes requirements for the repo to .hg/requires """ if requirements: