D4565: localrepo: copy ui in makelocalrepository()
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Thu Sep 13 16:30:48 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4565
AFFECTED FILES
mercurial/localrepo.py
CHANGE DETAILS
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -376,7 +376,7 @@
# set to reflect that the extension knows how to handle that requirements.
featuresetupfuncs = set()
-def makelocalrepository(ui, path, intents=None):
+def makelocalrepository(baseui, path, intents=None):
"""Create a local repository object.
Given arguments needed to construct a local repository, this function
@@ -386,15 +386,21 @@
The returned object conforms to the ``repository.completelocalrepository``
interface.
"""
+ ui = baseui.copy()
+ # Prevent copying repo configuration.
+ ui.copy = baseui.copy
+
# Working directory VFS rooted at repository root.
wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
# Main VFS for .hg/ directory.
hgpath = wdirvfs.join(b'.hg')
hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
return localrepository(
- ui, path,
+ baseui=baseui,
+ ui=ui,
+ origroot=path,
wdirvfs=wdirvfs,
hgvfs=hgvfs,
intents=intents)
@@ -449,7 +455,7 @@
'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.
Most callers should use ``hg.repository()``, ``localrepo.instance()``,
@@ -459,8 +465,10 @@
Arguments:
baseui
- ``ui.ui`` instance to use. A copy will be made (since new config
- options may be loaded into it).
+ ``ui.ui`` instance that ``ui`` argument was based off of.
+
+ ui
+ ``ui.ui`` instance for use by the repository.
origroot
``bytes`` path to working directory root of this repository.
@@ -476,9 +484,7 @@
for.
"""
self.baseui = baseui
- self.ui = baseui.copy()
- self.ui.copy = baseui.copy # prevent copying repo configuration
-
+ self.ui = ui
self.origroot = origroot
# vfs rooted at working directory.
self.wvfs = wdirvfs
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list