Mercurial > hg
diff hgext/remotefilelog/shallowbundle.py @ 40514:6f0b6905ef6f
shallowutil: introduce a helper function isenabled()
This patch introduces a inenabled() function which will check whether
remotefilelog is enabled or not. The function is then also used at all the
places where check whether remotefilelog is enabled or not. The new function
makes code easy to read without need to understand what is the constant involved
and why we are checking repo.requirements.
Differential Revision: https://phab.mercurial-scm.org/D5190
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Mon, 05 Nov 2018 11:52:10 -0800 |
parents | fc2766860796 |
children | 13d4ad8d7801 |
line wrap: on
line diff
--- a/hgext/remotefilelog/shallowbundle.py Wed Oct 24 16:59:05 2018 +0300 +++ b/hgext/remotefilelog/shallowbundle.py Mon Nov 05 11:52:10 2018 -0800 @@ -54,7 +54,7 @@ class shallowcg1packer(changegroup.cgpacker): def generate(self, commonrevs, clnodes, fastpathlinkrev, source): - if constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements: + if shallowutil.isenabled(self._repo): fastpathlinkrev = False return super(shallowcg1packer, self).generate(commonrevs, clnodes, @@ -69,7 +69,7 @@ linknodes, commonrevs, source = args except ValueError: commonrevs, source, mfdicts, fastpathlinkrev, fnodes, clrevs = args - if constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements: + if shallowutil.isenabled(self._repo): repo = self._repo if isinstance(repo, bundlerepo.bundlerepository): # If the bundle contains filelogs, we can't pull from it, since @@ -91,7 +91,7 @@ def shouldaddfilegroups(self, source): repo = self._repo - if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: + if not shallowutil.isenabled(repo): return AllFiles if source == "push" or source == "bundle": @@ -139,7 +139,7 @@ yield delta def makechangegroup(orig, repo, outgoing, version, source, *args, **kwargs): - if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: + if not shallowutil.isenabled(repo): return orig(repo, outgoing, version, source, *args, **kwargs) original = repo.shallowmatch @@ -168,7 +168,7 @@ repo.shallowmatch = original def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args): - if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: + if not shallowutil.isenabled(repo): return orig(repo, source, revmap, trp, expectedfiles, *args) files = 0