[PATCH STABLE] cmdserver: take repo.baseui as our ui

Idan Kamara idankk86 at gmail.com
Thu Jul 14 05:10:26 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1310633175 -10800
# Branch stable
# Node ID 42437e33d200d491428920540b29bd6f67ffeb06
# Parent  29d324c2bc930b135fd6ee8cc82d1fc29b7a8b08
cmdserver: take repo.baseui as our ui

The ui passed to server() is really repo.ui, that is it contains its local
configuration as well.

When running commands that use a different repo than the servers cached repo,
we don't want to use that ui as the baseui for the new repo.

diff -r 29d324c2bc93 -r 42437e33d200 mercurial/commandserver.py
--- a/mercurial/commandserver.py	Wed Jul 13 19:30:09 2011 -0500
+++ b/mercurial/commandserver.py	Thu Jul 14 11:46:15 2011 +0300
@@ -132,7 +132,6 @@
     """
     def __init__(self, ui, repo, mode):
         self.cwd = os.getcwd()
-        self.ui = ui
 
         logpath = ui.config("cmdserver", "log", None)
         if logpath:
@@ -143,6 +142,9 @@
             else:
                 logfile = open(logpath, 'a')
 
+        # the ui here is really the repo ui so take its baseui so we don't end up
+        # with its local configuration
+        self.ui = repo.baseui
         self.repo = repo
         self.repoui = repo.ui
 
diff -r 29d324c2bc93 -r 42437e33d200 tests/test-commandserver.py
--- a/tests/test-commandserver.py	Wed Jul 13 19:30:09 2011 -0500
+++ b/tests/test-commandserver.py	Thu Jul 14 11:46:15 2011 +0300
@@ -1,4 +1,4 @@
-import sys, os, struct, subprocess, cStringIO, re
+import sys, os, struct, subprocess, cStringIO, re, shutil
 
 def connect(path=None):
     cmdline = ['hg', 'serve', '--cmdserver', 'pipe']
@@ -129,6 +129,19 @@
     runcommand(server, ['st', 'foo/bar'])
     os.remove('foo/bar')
 
+def localhgrc(server):
+    """ check that local configs for the cached repo aren't inherited when -R
+    is used """
+    readchannel(server)
+
+    # the cached repo local hgrc contains ui.foo=bar, so showconfig should show it
+    runcommand(server, ['showconfig'])
+
+    # but not for this repo
+    runcommand(server, ['init', 'foo'])
+    runcommand(server, ['-R', 'foo', 'showconfig'])
+    shutil.rmtree('foo')
+
 if __name__ == '__main__':
     os.system('hg init')
 
@@ -138,3 +151,8 @@
     check(inputeof)
     check(serverinput)
     check(cwd)
+
+    hgrc = open('.hg/hgrc', 'a')
+    hgrc.write('[ui]\nfoo=bar\n')
+    hgrc.close()
+    check(localhgrc)
diff -r 29d324c2bc93 -r 42437e33d200 tests/test-commandserver.py.out
--- a/tests/test-commandserver.py.out	Wed Jul 13 19:30:09 2011 -0500
+++ b/tests/test-commandserver.py.out	Thu Jul 14 11:46:15 2011 +0300
@@ -38,3 +38,14 @@
 
 ? bar
 ? foo/bar
+bundle.mainreporoot=$TESTTMP
+defaults.backout=-d "0 0"
+defaults.commit=-d "0 0"
+defaults.tag=-d "0 0"
+ui.slash=True
+ui.foo=bar
+bundle.mainreporoot=$TESTTMP/foo
+defaults.backout=-d "0 0"
+defaults.commit=-d "0 0"
+defaults.tag=-d "0 0"
+ui.slash=True


More information about the Mercurial-devel mailing list