changeset 39705:f19bba3f4d3f

localrepo: copy ui in makelocalrepository() 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. Differential Revision: https://phab.mercurial-scm.org/D4565
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 12 Sep 2018 11:34:02 -0700
parents 2f9cdb5b3644
children e0c5017124b3
files mercurial/localrepo.py
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Sep 12 11:31:14 2018 -0700
+++ b/mercurial/localrepo.py	Wed Sep 12 11:34:02 2018 -0700
@@ -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,6 +386,10 @@
     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)
 
@@ -394,7 +398,9 @@
     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