##// END OF EJS Templates
localrepo: refactor logic to calculate sharedvfs in separate fn...
Pulkit Goyal -
r45912:665e9115 default
parent child Browse files
Show More
@@ -459,6 +459,31 b" NODEMAP_REQUIREMENT = b'persistent-nodem"
459 featuresetupfuncs = set()
459 featuresetupfuncs = set()
460
460
461
461
462 def _getsharedvfs(hgvfs, requirements):
463 """ returns the vfs object pointing to root of shared source
464 repo for a shared repository
465
466 hgvfs is vfs pointing at .hg/ of current repo (shared one)
467 requirements is a set of requirements of current repo (shared one)
468 """
469 # The ``shared`` or ``relshared`` requirements indicate the
470 # store lives in the path contained in the ``.hg/sharedpath`` file.
471 # This is an absolute path for ``shared`` and relative to
472 # ``.hg/`` for ``relshared``.
473 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
474 if b'relshared' in requirements:
475 sharedpath = hgvfs.join(sharedpath)
476
477 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
478
479 if not sharedvfs.exists():
480 raise error.RepoError(
481 _(b'.hg/sharedpath points to nonexistent directory %s')
482 % sharedvfs.base
483 )
484 return sharedvfs
485
486
462 def makelocalrepository(baseui, path, intents=None):
487 def makelocalrepository(baseui, path, intents=None):
463 """Create a local repository object.
488 """Create a local repository object.
464
489
@@ -500,6 +525,10 b' def makelocalrepository(baseui, path, in'
500 # Main VFS for .hg/ directory.
525 # Main VFS for .hg/ directory.
501 hgpath = wdirvfs.join(b'.hg')
526 hgpath = wdirvfs.join(b'.hg')
502 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
527 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
528 # Whether this repository is shared one or not
529 shared = False
530 # If this repository is shared, vfs pointing to shared repo
531 sharedvfs = None
503
532
504 # The .hg/ path should exist and should be a directory. All other
533 # The .hg/ path should exist and should be a directory. All other
505 # cases are errors.
534 # cases are errors.
@@ -567,27 +596,15 b' def makelocalrepository(baseui, path, in'
567 features = set()
596 features = set()
568
597
569 # The "store" part of the repository holds versioned data. How it is
598 # The "store" part of the repository holds versioned data. How it is
570 # accessed is determined by various requirements. The ``shared`` or
599 # accessed is determined by various requirements. If `shared` or
571 # ``relshared`` requirements indicate the store lives in the path contained
600 # `relshared` requirements are present, this indicates current repository
572 # in the ``.hg/sharedpath`` file. This is an absolute path for
601 # is a share and store exists in path mentioned in `.hg/sharedpath`
573 # ``shared`` and relative to ``.hg/`` for ``relshared``.
602 shared = b'shared' in requirements or b'relshared' in requirements
574 if b'shared' in requirements or b'relshared' in requirements:
603 if shared:
575 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
604 sharedvfs = _getsharedvfs(hgvfs, requirements)
576 if b'relshared' in requirements:
577 sharedpath = hgvfs.join(sharedpath)
578
579 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
580
581 if not sharedvfs.exists():
582 raise error.RepoError(
583 _(b'.hg/sharedpath points to nonexistent directory %s')
584 % sharedvfs.base
585 )
586
587 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
588
589 storebasepath = sharedvfs.base
605 storebasepath = sharedvfs.base
590 cachepath = sharedvfs.join(b'cache')
606 cachepath = sharedvfs.join(b'cache')
607 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
591 else:
608 else:
592 storebasepath = hgvfs.base
609 storebasepath = hgvfs.base
593 cachepath = hgvfs.join(b'cache')
610 cachepath = hgvfs.join(b'cache')
General Comments 0
You need to be logged in to leave comments. Login now