ui: replace parentui mechanism with repo.baseui
authorMatt Mackall <mpm@selenic.com>
Sun, 26 Apr 2009 16:50:43 -0500
changeset 8189 d2899a856f9f
parent 8188 f3abe032fc89
child 8190 9b8ac5fb7760
ui: replace parentui mechanism with repo.baseui
mercurial/cmdutil.py
mercurial/commands.py
mercurial/localrepo.py
mercurial/ui.py
tests/test-extension
tests/test-extension.out
--- a/mercurial/cmdutil.py	Sun Apr 26 16:50:43 2009 -0500
+++ b/mercurial/cmdutil.py	Sun Apr 26 16:50:43 2009 -0500
@@ -100,10 +100,10 @@
 
 def remoteui(src, opts):
     'build a remote ui from ui or repo and opts'
-    if hasattr(src, 'ui'): # looks like a repository
-        dst = src.ui.parentui # drop repo-specific config
+    if hasattr(src, 'baseui'): # looks like a repository
+        dst = src.baseui # drop repo-specific config
         src = src.ui # copy target options from repo
-    else: # assume it's a ui object
+    else: # assume it's a global ui object
         dst = src # keep all global options
 
     # copy ssh-specific options
--- a/mercurial/commands.py	Sun Apr 26 16:50:43 2009 -0500
+++ b/mercurial/commands.py	Sun Apr 26 16:50:43 2009 -0500
@@ -2677,7 +2677,7 @@
         s = sshserver.sshserver(ui, repo)
         s.serve_forever()
 
-    parentui = ui.parentui or ui
+    parentui = repo and repo.baseui or ui
     optlist = ("name templates style address port prefix ipv6"
                " accesslog errorlog webdir_conf certificate")
     for o in optlist.split():
--- a/mercurial/localrepo.py	Sun Apr 26 16:50:43 2009 -0500
+++ b/mercurial/localrepo.py	Sun Apr 26 16:50:43 2009 -0500
@@ -20,7 +20,7 @@
     capabilities = set(('lookup', 'changegroupsubset'))
     supported = ('revlogv1', 'store', 'fncache')
 
-    def __init__(self, parentui, path=None, create=0):
+    def __init__(self, baseui, path=None, create=0):
         repo.repository.__init__(self)
         self.root = os.path.realpath(path)
         self.path = os.path.join(self.root, ".hg")
@@ -34,10 +34,10 @@
                     os.mkdir(path)
                 os.mkdir(self.path)
                 requirements = ["revlogv1"]
-                if parentui.configbool('format', 'usestore', True):
+                if baseui.configbool('format', 'usestore', True):
                     os.mkdir(os.path.join(self.path, "store"))
                     requirements.append("store")
-                    if parentui.configbool('format', 'usefncache', True):
+                    if baseui.configbool('format', 'usefncache', True):
                         requirements.append("fncache")
                     # create an invalid changelog
                     self.opener("00changelog.i", "a").write(
@@ -70,7 +70,8 @@
         self.sjoin = self.store.join
         self.opener.createmode = self.store.createmode
 
-        self.ui = ui.ui(parentui=parentui)
+        self.baseui = baseui
+        self.ui = baseui.copy()
         try:
             self.ui.readconfig(self.join("hgrc"), self.root)
             extensions.loadall(self.ui)
--- a/mercurial/ui.py	Sun Apr 26 16:50:43 2009 -0500
+++ b/mercurial/ui.py	Sun Apr 26 16:50:43 2009 -0500
@@ -20,23 +20,22 @@
         self.overlay = config.config()
         self.cdata = config.config()
         self.ucdata = config.config()
-        self.parentui = None
         self.trusted_users = {}
         self.trusted_groups = {}
 
         if parentui:
-            self.parentui = parentui.parentui or parentui
-            self.cdata = self.parentui.cdata.copy()
-            self.ucdata = self.parentui.ucdata.copy()
+            self.cdata = parentui.cdata.copy()
+            self.ucdata = parentui.ucdata.copy()
             self.overlay = parentui.overlay.copy()
             self.trusted_users = parentui.trusted_users.copy()
             self.trusted_groups = parentui.trusted_groups.copy()
-            self.buffers = parentui.buffers
             self.fixconfig()
         else:
             # we always trust global config files
             for f in util.rcpath():
                 self.readconfig(f, assumetrusted=True)
+    def copy(self):
+        return ui(self)
 
     _isatty = None
     def isatty(self):
--- a/tests/test-extension	Sun Apr 26 16:50:43 2009 -0500
+++ b/tests/test-extension	Sun Apr 26 16:50:43 2009 -0500
@@ -9,8 +9,6 @@
 
 def uisetup(ui):
     ui.write("uisetup called\\n")
-    ui.write("ui.parentui is%s None\\n" % (ui.parentui is not None
-                                           and "not" or ""))
 
 def reposetup(ui, repo):
     ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
--- a/tests/test-extension.out	Sun Apr 26 16:50:43 2009 -0500
+++ b/tests/test-extension.out	Sun Apr 26 16:50:43 2009 -0500
@@ -1,10 +1,8 @@
 uisetup called
-ui.parentui isnot None
 reposetup called for a
 ui == repo.ui
 Foo
 uisetup called
-ui.parentui is None
 reposetup called for a
 ui == repo.ui
 reposetup called for b
@@ -12,11 +10,9 @@
 updating working directory
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 uisetup called
-ui.parentui is None
 Bar
 % module/__init__.py-style
 uisetup called
-ui.parentui isnot None
 reposetup called for a
 ui == repo.ui
 Foo