##// END OF EJS Templates
localrepo: move some vfs initialization out of __init__...
Gregory Szorc -
r39724:2f9cdb5b default
parent child Browse files
Show More
@@ -386,7 +386,18 b' def makelocalrepository(ui, path, intent'
386 The returned object conforms to the ``repository.completelocalrepository``
386 The returned object conforms to the ``repository.completelocalrepository``
387 interface.
387 interface.
388 """
388 """
389 return localrepository(ui, path, intents=intents)
389 # Working directory VFS rooted at repository root.
390 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
391
392 # Main VFS for .hg/ directory.
393 hgpath = wdirvfs.join(b'.hg')
394 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
395
396 return localrepository(
397 ui, path,
398 wdirvfs=wdirvfs,
399 hgvfs=hgvfs,
400 intents=intents)
390
401
391 @interfaceutil.implementer(repository.completelocalrepository)
402 @interfaceutil.implementer(repository.completelocalrepository)
392 class localrepository(object):
403 class localrepository(object):
@@ -438,30 +449,51 b' class localrepository(object):'
438 'bisect.state',
449 'bisect.state',
439 }
450 }
440
451
441 def __init__(self, baseui, path, intents=None):
452 def __init__(self, baseui, origroot, wdirvfs, hgvfs, intents=None):
442 """Create a new local repository instance.
453 """Create a new local repository instance.
443
454
444 Most callers should use ``hg.repository()`` or ``localrepo.instance()``
455 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
445 for obtaining a new repository object.
456 or ``localrepo.makelocalrepository()`` for obtaining a new repository
457 object.
458
459 Arguments:
460
461 baseui
462 ``ui.ui`` instance to use. A copy will be made (since new config
463 options may be loaded into it).
464
465 origroot
466 ``bytes`` path to working directory root of this repository.
467
468 wdirvfs
469 ``vfs.vfs`` rooted at the working directory.
470
471 hgvfs
472 ``vfs.vfs`` rooted at .hg/
473
474 intents
475 ``set`` of system strings indicating what this repo will be used
476 for.
446 """
477 """
478 self.baseui = baseui
479 self.ui = baseui.copy()
480 self.ui.copy = baseui.copy # prevent copying repo configuration
481
482 self.origroot = origroot
483 # vfs rooted at working directory.
484 self.wvfs = wdirvfs
485 self.root = wdirvfs.base
486 # vfs rooted at .hg/. Used to access most non-store paths.
487 self.vfs = hgvfs
488 self.path = hgvfs.base
447
489
448 self.requirements = set()
490 self.requirements = set()
449 self.filtername = None
491 self.filtername = None
450 # wvfs: rooted at the repository root, used to access the working copy
451 self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
452 # vfs: rooted at .hg, used to access repo files outside of .hg/store
453 self.vfs = None
454 # svfs: usually rooted at .hg/store, used to access repository history
492 # svfs: usually rooted at .hg/store, used to access repository history
455 # If this is a shared repository, this vfs may point to another
493 # If this is a shared repository, this vfs may point to another
456 # repository's .hg/store directory.
494 # repository's .hg/store directory.
457 self.svfs = None
495 self.svfs = None
458 self.root = self.wvfs.base
496
459 self.path = self.wvfs.join(".hg")
460 self.origroot = path
461 self.baseui = baseui
462 self.ui = baseui.copy()
463 self.ui.copy = baseui.copy # prevent copying repo configuration
464 self.vfs = vfsmod.vfs(self.path, cacheaudited=True)
465 if (self.ui.configbool('devel', 'all-warnings') or
497 if (self.ui.configbool('devel', 'all-warnings') or
466 self.ui.configbool('devel', 'check-locks')):
498 self.ui.configbool('devel', 'check-locks')):
467 self.vfs.audit = self._getvfsward(self.vfs.audit)
499 self.vfs.audit = self._getvfsward(self.vfs.audit)
@@ -498,7 +530,7 b' class localrepository(object):'
498 except OSError as inst:
530 except OSError as inst:
499 if inst.errno != errno.ENOENT:
531 if inst.errno != errno.ENOENT:
500 raise
532 raise
501 raise error.RepoError(_("repository %s not found") % path)
533 raise error.RepoError(_("repository %s not found") % origroot)
502 else:
534 else:
503 try:
535 try:
504 self.requirements = scmutil.readrequires(
536 self.requirements = scmutil.readrequires(
General Comments 0
You need to be logged in to leave comments. Login now