Mercurial > hg
diff hgext/remotefilelog/shallowutil.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 | 3a333a582d7b |
children | 1419f780207c |
line wrap: on
line diff
--- a/hgext/remotefilelog/shallowutil.py Wed Oct 24 16:59:05 2018 +0300 +++ b/hgext/remotefilelog/shallowutil.py Mon Nov 05 11:52:10 2018 -0800 @@ -30,6 +30,10 @@ if not pycompat.iswindows: import grp +def isenabled(repo): + """returns whether the repository is remotefilelog enabled or not""" + return constants.SHALLOWREPO_REQUIREMENT in repo.requirements + def getcachekey(reponame, file, id): pathhash = hashlib.sha1(file).hexdigest() return os.path.join(reponame, pathhash[:2], pathhash[2:], id)