We will want to load the .hg/hgrc file from makelocalrepository() so
we can consult its options as part of deriving the repository type.
This means we need to create our ui instance copy in that function.
hg-reviewers |
We will want to load the .hg/hgrc file from makelocalrepository() so
we can consult its options as part of deriving the repository type.
This means we need to create our ui instance copy in that function.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
# the ability to load repositories with custom requirements. Only | # the ability to load repositories with custom requirements. Only | ||||
# functions defined in loaded extensions are called. | # functions defined in loaded extensions are called. | ||||
# | # | ||||
# The function receives a set of requirement strings that the repository | # The function receives a set of requirement strings that the repository | ||||
# is capable of opening. Functions will typically add elements to the | # is capable of opening. Functions will typically add elements to the | ||||
# set to reflect that the extension knows how to handle that requirements. | # set to reflect that the extension knows how to handle that requirements. | ||||
featuresetupfuncs = set() | featuresetupfuncs = set() | ||||
def makelocalrepository(ui, path, intents=None): | def makelocalrepository(baseui, path, intents=None): | ||||
"""Create a local repository object. | """Create a local repository object. | ||||
Given arguments needed to construct a local repository, this function | Given arguments needed to construct a local repository, this function | ||||
derives a type suitable for representing that repository and returns an | derives a type suitable for representing that repository and returns an | ||||
instance of it. | instance of it. | ||||
The returned object conforms to the ``repository.completelocalrepository`` | The returned object conforms to the ``repository.completelocalrepository`` | ||||
interface. | interface. | ||||
""" | """ | ||||
ui = baseui.copy() | |||||
# Prevent copying repo configuration. | |||||
ui.copy = baseui.copy | |||||
# Working directory VFS rooted at repository root. | # Working directory VFS rooted at repository root. | ||||
wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) | ||||
# Main VFS for .hg/ directory. | # Main VFS for .hg/ directory. | ||||
hgpath = wdirvfs.join(b'.hg') | hgpath = wdirvfs.join(b'.hg') | ||||
hgvfs = vfsmod.vfs(hgpath, cacheaudited=True) | hgvfs = vfsmod.vfs(hgpath, cacheaudited=True) | ||||
return localrepository( | return localrepository( | ||||
ui, path, | baseui=baseui, | ||||
ui=ui, | |||||
origroot=path, | |||||
wdirvfs=wdirvfs, | wdirvfs=wdirvfs, | ||||
hgvfs=hgvfs, | hgvfs=hgvfs, | ||||
intents=intents) | intents=intents) | ||||
@interfaceutil.implementer(repository.completelocalrepository) | @interfaceutil.implementer(repository.completelocalrepository) | ||||
class localrepository(object): | class localrepository(object): | ||||
# obsolete experimental requirements: | # obsolete experimental requirements: | ||||
# XXX shouldn't be dirstate covered by the wlock? | # XXX shouldn't be dirstate covered by the wlock? | ||||
'dirstate', | 'dirstate', | ||||
# XXX bisect was still a bit too messy at the time | # XXX bisect was still a bit too messy at the time | ||||
# this changeset was introduced. Someone should fix | # this changeset was introduced. Someone should fix | ||||
# the remainig bit and drop this line | # the remainig bit and drop this line | ||||
'bisect.state', | 'bisect.state', | ||||
} | } | ||||
def __init__(self, baseui, origroot, wdirvfs, hgvfs, intents=None): | def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, intents=None): | ||||
"""Create a new local repository instance. | """Create a new local repository instance. | ||||
Most callers should use ``hg.repository()``, ``localrepo.instance()``, | Most callers should use ``hg.repository()``, ``localrepo.instance()``, | ||||
or ``localrepo.makelocalrepository()`` for obtaining a new repository | or ``localrepo.makelocalrepository()`` for obtaining a new repository | ||||
object. | object. | ||||
Arguments: | Arguments: | ||||
baseui | baseui | ||||
``ui.ui`` instance to use. A copy will be made (since new config | ``ui.ui`` instance that ``ui`` argument was based off of. | ||||
options may be loaded into it). | |||||
ui | |||||
``ui.ui`` instance for use by the repository. | |||||
origroot | origroot | ||||
``bytes`` path to working directory root of this repository. | ``bytes`` path to working directory root of this repository. | ||||
wdirvfs | wdirvfs | ||||
``vfs.vfs`` rooted at the working directory. | ``vfs.vfs`` rooted at the working directory. | ||||
hgvfs | hgvfs | ||||
``vfs.vfs`` rooted at .hg/ | ``vfs.vfs`` rooted at .hg/ | ||||
intents | intents | ||||
``set`` of system strings indicating what this repo will be used | ``set`` of system strings indicating what this repo will be used | ||||
for. | for. | ||||
""" | """ | ||||
self.baseui = baseui | self.baseui = baseui | ||||
self.ui = baseui.copy() | self.ui = ui | ||||
self.ui.copy = baseui.copy # prevent copying repo configuration | |||||
self.origroot = origroot | self.origroot = origroot | ||||
# vfs rooted at working directory. | # vfs rooted at working directory. | ||||
self.wvfs = wdirvfs | self.wvfs = wdirvfs | ||||
self.root = wdirvfs.base | self.root = wdirvfs.base | ||||
# vfs rooted at .hg/. Used to access most non-store paths. | # vfs rooted at .hg/. Used to access most non-store paths. | ||||
self.vfs = hgvfs | self.vfs = hgvfs | ||||
self.path = hgvfs.base | self.path = hgvfs.base | ||||