Show More
@@ -56,7 +56,7 from . import ( | |||
|
56 | 56 | revsetlang, |
|
57 | 57 | scmutil, |
|
58 | 58 | sparse, |
|
59 | store, | |
|
59 | store as storemod, | |
|
60 | 60 | subrepoutil, |
|
61 | 61 | tags as tagsmod, |
|
62 | 62 | transaction, |
@@ -454,6 +454,40 def makelocalrepository(baseui, path, in | |||
|
454 | 454 | # At this point, we know we should be capable of opening the repository. |
|
455 | 455 | # Now get on with doing that. |
|
456 | 456 | |
|
457 | # The "store" part of the repository holds versioned data. How it is | |
|
458 | # accessed is determined by various requirements. The ``shared`` or | |
|
459 | # ``relshared`` requirements indicate the store lives in the path contained | |
|
460 | # in the ``.hg/sharedpath`` file. This is an absolute path for | |
|
461 | # ``shared`` and relative to ``.hg/`` for ``relshared``. | |
|
462 | if b'shared' in requirements or b'relshared' in requirements: | |
|
463 | sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') | |
|
464 | if b'relshared' in requirements: | |
|
465 | sharedpath = hgvfs.join(sharedpath) | |
|
466 | ||
|
467 | sharedvfs = vfsmod.vfs(sharedpath, realpath=True) | |
|
468 | ||
|
469 | if not sharedvfs.exists(): | |
|
470 | raise error.RepoError(_(b'.hg/sharedpath points to nonexistent ' | |
|
471 | b'directory %s') % sharedvfs.base) | |
|
472 | ||
|
473 | storebasepath = sharedvfs.base | |
|
474 | cachepath = sharedvfs.join(b'cache') | |
|
475 | else: | |
|
476 | storebasepath = hgvfs.base | |
|
477 | cachepath = hgvfs.join(b'cache') | |
|
478 | ||
|
479 | # The store has changed over time and the exact layout is dictated by | |
|
480 | # requirements. The store interface abstracts differences across all | |
|
481 | # of them. | |
|
482 | store = storemod.store(requirements, storebasepath, | |
|
483 | lambda base: vfsmod.vfs(base, cacheaudited=True)) | |
|
484 | ||
|
485 | hgvfs.createmode = store.createmode | |
|
486 | ||
|
487 | # The cache vfs is used to manage cache files. | |
|
488 | cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) | |
|
489 | cachevfs.createmode = store.createmode | |
|
490 | ||
|
457 | 491 | return localrepository( |
|
458 | 492 | baseui=baseui, |
|
459 | 493 | ui=ui, |
@@ -462,6 +496,9 def makelocalrepository(baseui, path, in | |||
|
462 | 496 | hgvfs=hgvfs, |
|
463 | 497 | requirements=requirements, |
|
464 | 498 | supportedrequirements=supportedrequirements, |
|
499 | sharedpath=storebasepath, | |
|
500 | store=store, | |
|
501 | cachevfs=cachevfs, | |
|
465 | 502 | intents=intents) |
|
466 | 503 | |
|
467 | 504 | def gathersupportedrequirements(ui): |
@@ -581,7 +618,8 class localrepository(object): | |||
|
581 | 618 | } |
|
582 | 619 | |
|
583 | 620 | def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, requirements, |
|
584 |
supportedrequirements, |
|
|
621 | supportedrequirements, sharedpath, store, cachevfs, | |
|
622 | intents=None): | |
|
585 | 623 | """Create a new local repository instance. |
|
586 | 624 | |
|
587 | 625 | Most callers should use ``hg.repository()``, ``localrepo.instance()``, |
@@ -612,6 +650,17 class localrepository(object): | |||
|
612 | 650 | ``set`` of bytestrings representing repository requirements that we |
|
613 | 651 | know how to open. May be a supetset of ``requirements``. |
|
614 | 652 | |
|
653 | sharedpath | |
|
654 | ``bytes`` Defining path to storage base directory. Points to a | |
|
655 | ``.hg/`` directory somewhere. | |
|
656 | ||
|
657 | store | |
|
658 | ``store.basicstore`` (or derived) instance providing access to | |
|
659 | versioned storage. | |
|
660 | ||
|
661 | cachevfs | |
|
662 | ``vfs.vfs`` used for cache files. | |
|
663 | ||
|
615 | 664 | intents |
|
616 | 665 | ``set`` of system strings indicating what this repo will be used |
|
617 | 666 | for. |
@@ -627,12 +676,11 class localrepository(object): | |||
|
627 | 676 | self.path = hgvfs.base |
|
628 | 677 | self.requirements = requirements |
|
629 | 678 | self.supported = supportedrequirements |
|
679 | self.sharedpath = sharedpath | |
|
680 | self.store = store | |
|
681 | self.cachevfs = cachevfs | |
|
630 | 682 | |
|
631 | 683 | self.filtername = None |
|
632 | # svfs: usually rooted at .hg/store, used to access repository history | |
|
633 | # If this is a shared repository, this vfs may point to another | |
|
634 | # repository's .hg/store directory. | |
|
635 | self.svfs = None | |
|
636 | 684 | |
|
637 | 685 | if (self.ui.configbool('devel', 'all-warnings') or |
|
638 | 686 | self.ui.configbool('devel', 'check-locks')): |
@@ -644,32 +692,9 class localrepository(object): | |||
|
644 | 692 | |
|
645 | 693 | color.setup(self.ui) |
|
646 | 694 | |
|
647 | cachepath = self.vfs.join('cache') | |
|
648 | self.sharedpath = self.path | |
|
649 | try: | |
|
650 | sharedpath = self.vfs.read("sharedpath").rstrip('\n') | |
|
651 | if 'relshared' in self.requirements: | |
|
652 | sharedpath = self.vfs.join(sharedpath) | |
|
653 | vfs = vfsmod.vfs(sharedpath, realpath=True) | |
|
654 | cachepath = vfs.join('cache') | |
|
655 | s = vfs.base | |
|
656 | if not vfs.exists(): | |
|
657 | raise error.RepoError( | |
|
658 | _('.hg/sharedpath points to nonexistent directory %s') % s) | |
|
659 | self.sharedpath = s | |
|
660 | except IOError as inst: | |
|
661 | if inst.errno != errno.ENOENT: | |
|
662 | raise | |
|
663 | ||
|
664 | self.store = store.store( | |
|
665 | self.requirements, self.sharedpath, | |
|
666 | lambda base: vfsmod.vfs(base, cacheaudited=True)) | |
|
667 | 695 | self.spath = self.store.path |
|
668 | 696 | self.svfs = self.store.vfs |
|
669 | 697 | self.sjoin = self.store.join |
|
670 | self.vfs.createmode = self.store.createmode | |
|
671 | self.cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) | |
|
672 | self.cachevfs.createmode = self.store.createmode | |
|
673 | 698 | if (self.ui.configbool('devel', 'all-warnings') or |
|
674 | 699 | self.ui.configbool('devel', 'check-locks')): |
|
675 | 700 | if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs |
General Comments 0
You need to be logged in to leave comments.
Login now