comparison 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
comparison
equal deleted inserted replaced
40513:525dcf5c1d41 40514:6f0b6905ef6f
27 ) 27 )
28 from . import constants 28 from . import constants
29 29
30 if not pycompat.iswindows: 30 if not pycompat.iswindows:
31 import grp 31 import grp
32
33 def isenabled(repo):
34 """returns whether the repository is remotefilelog enabled or not"""
35 return constants.SHALLOWREPO_REQUIREMENT in repo.requirements
32 36
33 def getcachekey(reponame, file, id): 37 def getcachekey(reponame, file, id):
34 pathhash = hashlib.sha1(file).hexdigest() 38 pathhash = hashlib.sha1(file).hexdigest()
35 return os.path.join(reponame, pathhash[:2], pathhash[2:], id) 39 return os.path.join(reponame, pathhash[:2], pathhash[2:], id)
36 40