Mercurial > hg
comparison hgext/lfs/wrapper.py @ 50901:6543469a351e
lfs: use sysstr to check for attribute presence
We do not need bytes here.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 30 Aug 2023 12:51:27 +0200 |
parents | 609a3b8058c3 |
children | d718eddf01d9 |
comparison
equal
deleted
inserted
replaced
50900:a99e62dae4c8 | 50901:6543469a351e |
---|---|
70 | 70 |
71 @eh.wrapfunction(wireprotov1server, '_capabilities') | 71 @eh.wrapfunction(wireprotov1server, '_capabilities') |
72 def _capabilities(orig, repo, proto): | 72 def _capabilities(orig, repo, proto): |
73 '''Wrap server command to announce lfs server capability''' | 73 '''Wrap server command to announce lfs server capability''' |
74 caps = orig(repo, proto) | 74 caps = orig(repo, proto) |
75 if util.safehasattr(repo.svfs, b'lfslocalblobstore'): | 75 if util.safehasattr(repo.svfs, 'lfslocalblobstore'): |
76 # Advertise a slightly different capability when lfs is *required*, so | 76 # Advertise a slightly different capability when lfs is *required*, so |
77 # that the client knows it MUST load the extension. If lfs is not | 77 # that the client knows it MUST load the extension. If lfs is not |
78 # required on the server, there's no reason to autoload the extension | 78 # required on the server, there's no reason to autoload the extension |
79 # on the client. | 79 # on the client. |
80 if b'lfs' in repo.requirements: | 80 if b'lfs' in repo.requirements: |
332 for k, v in othervfs.options.items(): | 332 for k, v in othervfs.options.items(): |
333 if k.startswith(b'lfs'): | 333 if k.startswith(b'lfs'): |
334 self.options[k] = v | 334 self.options[k] = v |
335 # also copy lfs blobstores. note: this can run before reposetup, so lfs | 335 # also copy lfs blobstores. note: this can run before reposetup, so lfs |
336 # blobstore attributes are not always ready at this time. | 336 # blobstore attributes are not always ready at this time. |
337 for name in [b'lfslocalblobstore', b'lfsremoteblobstore']: | 337 for name in ['lfslocalblobstore', 'lfsremoteblobstore']: |
338 if util.safehasattr(othervfs, name): | 338 if util.safehasattr(othervfs, name): |
339 setattr(self, name, getattr(othervfs, name)) | 339 setattr(self, name, getattr(othervfs, name)) |
340 | 340 |
341 | 341 |
342 def _prefetchfiles(repo, revmatches): | 342 def _prefetchfiles(repo, revmatches): |
343 """Ensure that required LFS blobs are present, fetching them as a group if | 343 """Ensure that required LFS blobs are present, fetching them as a group if |
344 needed.""" | 344 needed.""" |
345 if not util.safehasattr(repo.svfs, b'lfslocalblobstore'): | 345 if not util.safehasattr(repo.svfs, 'lfslocalblobstore'): |
346 return | 346 return |
347 | 347 |
348 pointers = [] | 348 pointers = [] |
349 oids = set() | 349 oids = set() |
350 localstore = repo.svfs.lfslocalblobstore | 350 localstore = repo.svfs.lfslocalblobstore |
364 blobstore.remote(repo).readbatch(pointers, localstore) | 364 blobstore.remote(repo).readbatch(pointers, localstore) |
365 | 365 |
366 | 366 |
367 def _canskipupload(repo): | 367 def _canskipupload(repo): |
368 # Skip if this hasn't been passed to reposetup() | 368 # Skip if this hasn't been passed to reposetup() |
369 if not util.safehasattr(repo.svfs, b'lfsremoteblobstore'): | 369 if not util.safehasattr(repo.svfs, 'lfsremoteblobstore'): |
370 return True | 370 return True |
371 | 371 |
372 # if remotestore is a null store, upload is a no-op and can be skipped | 372 # if remotestore is a null store, upload is a no-op and can be skipped |
373 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) | 373 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) |
374 | 374 |
375 | 375 |
376 def candownload(repo): | 376 def candownload(repo): |
377 # Skip if this hasn't been passed to reposetup() | 377 # Skip if this hasn't been passed to reposetup() |
378 if not util.safehasattr(repo.svfs, b'lfsremoteblobstore'): | 378 if not util.safehasattr(repo.svfs, 'lfsremoteblobstore'): |
379 return False | 379 return False |
380 | 380 |
381 # if remotestore is a null store, downloads will lead to nothing | 381 # if remotestore is a null store, downloads will lead to nothing |
382 return not isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) | 382 return not isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) |
383 | 383 |
522 @eh.wrapfunction(upgrade_engine, 'finishdatamigration') | 522 @eh.wrapfunction(upgrade_engine, 'finishdatamigration') |
523 def upgradefinishdatamigration(orig, ui, srcrepo, dstrepo, requirements): | 523 def upgradefinishdatamigration(orig, ui, srcrepo, dstrepo, requirements): |
524 orig(ui, srcrepo, dstrepo, requirements) | 524 orig(ui, srcrepo, dstrepo, requirements) |
525 | 525 |
526 # Skip if this hasn't been passed to reposetup() | 526 # Skip if this hasn't been passed to reposetup() |
527 if util.safehasattr( | 527 if util.safehasattr(srcrepo.svfs, 'lfslocalblobstore') and util.safehasattr( |
528 srcrepo.svfs, b'lfslocalblobstore' | 528 dstrepo.svfs, 'lfslocalblobstore' |
529 ) and util.safehasattr(dstrepo.svfs, b'lfslocalblobstore'): | 529 ): |
530 srclfsvfs = srcrepo.svfs.lfslocalblobstore.vfs | 530 srclfsvfs = srcrepo.svfs.lfslocalblobstore.vfs |
531 dstlfsvfs = dstrepo.svfs.lfslocalblobstore.vfs | 531 dstlfsvfs = dstrepo.svfs.lfslocalblobstore.vfs |
532 | 532 |
533 for dirpath, dirs, files in srclfsvfs.walk(): | 533 for dirpath, dirs, files in srclfsvfs.walk(): |
534 for oid in files: | 534 for oid in files: |