comparison hgext/remotefilelog/remotefilelogserver.py @ 40510:fc2766860796

remotefilelog: consolidate and rename on-disk store requirement The value of this constant appeared in too many places. While we're here, rename it to be more consistent with our naming conventions for experimental functionality. Differential Revision: https://phab.mercurial-scm.org/D5128
author Augie Fackler <augie@google.com>
date Tue, 16 Oct 2018 17:02:48 -0400
parents ed19958dbf5d
children 466dd4d70bff
comparison
equal deleted inserted replaced
40509:ed19958dbf5d 40510:fc2766860796
28 wireprototypes, 28 wireprototypes,
29 wireprotov1server, 29 wireprotov1server,
30 ) 30 )
31 from . import ( 31 from . import (
32 constants, 32 constants,
33 shallowrepo,
34 shallowutil, 33 shallowutil,
35 ) 34 )
36 35
37 _sshv1server = wireprotoserver.sshv1protocolhandler 36 _sshv1server = wireprotoserver.sshv1protocolhandler
38 37
131 130
132 # don't clone filelogs to shallow clients 131 # don't clone filelogs to shallow clients
133 def _walkstreamfiles(orig, repo): 132 def _walkstreamfiles(orig, repo):
134 if state.shallowremote: 133 if state.shallowremote:
135 # if we are shallow ourselves, stream our local commits 134 # if we are shallow ourselves, stream our local commits
136 if shallowrepo.requirement in repo.requirements: 135 if constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
137 striplen = len(repo.store.path) + 1 136 striplen = len(repo.store.path) + 1
138 readdir = repo.store.rawvfs.readdir 137 readdir = repo.store.rawvfs.readdir
139 visit = [os.path.join(repo.store.path, 'data')] 138 visit = [os.path.join(repo.store.path, 'data')]
140 while visit: 139 while visit:
141 p = visit.pop() 140 p = visit.pop()
165 for x in repo.store.topfiles(): 164 for x in repo.store.topfiles():
166 if state.noflatmf and x[0][:11] == '00manifest.': 165 if state.noflatmf and x[0][:11] == '00manifest.':
167 continue 166 continue
168 yield x 167 yield x
169 168
170 elif shallowrepo.requirement in repo.requirements: 169 elif constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
171 # don't allow cloning from a shallow repo to a full repo 170 # don't allow cloning from a shallow repo to a full repo
172 # since it would require fetching every version of every 171 # since it would require fetching every version of every
173 # file in order to create the revlogs. 172 # file in order to create the revlogs.
174 raise error.Abort(_("Cannot clone from a shallow repo " 173 raise error.Abort(_("Cannot clone from a shallow repo "
175 "to a full repo.")) 174 "to a full repo."))
192 wireprotov1server.commands["getbundle_shallow"] = (getbundleshallow, '*') 191 wireprotov1server.commands["getbundle_shallow"] = (getbundleshallow, '*')
193 192
194 # expose remotefilelog capabilities 193 # expose remotefilelog capabilities
195 def _capabilities(orig, repo, proto): 194 def _capabilities(orig, repo, proto):
196 caps = orig(repo, proto) 195 caps = orig(repo, proto)
197 if ((shallowrepo.requirement in repo.requirements or 196 if ((constants.SHALLOWREPO_REQUIREMENT in repo.requirements or
198 ui.configbool('remotefilelog', 'server'))): 197 ui.configbool('remotefilelog', 'server'))):
199 if isinstance(proto, _sshv1server): 198 if isinstance(proto, _sshv1server):
200 # legacy getfiles method which only works over ssh 199 # legacy getfiles method which only works over ssh
201 caps.append(constants.NETWORK_CAP_LEGACY_SSH_GETFILES) 200 caps.append(constants.NETWORK_CAP_LEGACY_SSH_GETFILES)
202 caps.append('getflogheads') 201 caps.append('getflogheads')
277 non-zero for an error. 276 non-zero for an error.
278 277
279 data is a compressed blob with revlog flag and ancestors information. See 278 data is a compressed blob with revlog flag and ancestors information. See
280 createfileblob for its content. 279 createfileblob for its content.
281 """ 280 """
282 if shallowrepo.requirement in repo.requirements: 281 if constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
283 return '1\0' + _('cannot fetch remote files from shallow repo') 282 return '1\0' + _('cannot fetch remote files from shallow repo')
284 cachepath = repo.ui.config("remotefilelog", "servercachepath") 283 cachepath = repo.ui.config("remotefilelog", "servercachepath")
285 if not cachepath: 284 if not cachepath:
286 cachepath = os.path.join(repo.path, "remotefilelogcache") 285 cachepath = os.path.join(repo.path, "remotefilelogcache")
287 node = bin(node.strip()) 286 node = bin(node.strip())
290 return '0\0' + _loadfileblob(repo, cachepath, file, node) 289 return '0\0' + _loadfileblob(repo, cachepath, file, node)
291 290
292 def getfiles(repo, proto): 291 def getfiles(repo, proto):
293 """A server api for requesting particular versions of particular files. 292 """A server api for requesting particular versions of particular files.
294 """ 293 """
295 if shallowrepo.requirement in repo.requirements: 294 if constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
296 raise error.Abort(_('cannot fetch remote files from shallow repo')) 295 raise error.Abort(_('cannot fetch remote files from shallow repo'))
297 if not isinstance(proto, _sshv1server): 296 if not isinstance(proto, _sshv1server):
298 raise error.Abort(_('cannot fetch remote files over non-ssh protocol')) 297 raise error.Abort(_('cannot fetch remote files over non-ssh protocol'))
299 298
300 def streamer(): 299 def streamer():