changeset 4866:9858477ed74c

serve: respect settings from .hg/hgrc create_server was looking only at the root ui object, ignoring any settings from .hg/hgrc. To keep respecting command-line arguments, commands.serve must also call repo.ui.setconfig.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Wed, 11 Jul 2007 19:56:16 -0300
parents 439e2f2fde42
children 0e2d0a78f81a
files mercurial/commands.py mercurial/hgweb/server.py tests/test-serve tests/test-serve.out
diffstat 4 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2457,6 +2457,8 @@ def serve(ui, repo, **opts):
     for o in optlist.split():
         if opts[o]:
             parentui.setconfig("web", o, str(opts[o]))
+            if repo.ui != parentui:
+                repo.ui.setconfig("web", o, str(opts[o]))
 
     if repo is None and not ui.config("web", "webdir_conf"):
         raise hg.RepoError(_("There is no Mercurial repository here"
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -172,12 +172,12 @@ def create_server(ui, repo):
             return open(opt, 'w')
         return default
 
-    address = ui.config("web", "address", "")
-    port = int(ui.config("web", "port", 8000))
-    use_ipv6 = ui.configbool("web", "ipv6")
-    webdir_conf = ui.config("web", "webdir_conf")
-    accesslog = openlog(ui.config("web", "accesslog", "-"), sys.stdout)
-    errorlog = openlog(ui.config("web", "errorlog", "-"), sys.stderr)
+    address = repo.ui.config("web", "address", "")
+    port = int(repo.ui.config("web", "port", 8000))
+    use_ipv6 = repo.ui.configbool("web", "ipv6")
+    webdir_conf = repo.ui.config("web", "webdir_conf")
+    accesslog = openlog(repo.ui.config("web", "accesslog", "-"), sys.stdout)
+    errorlog = openlog(repo.ui.config("web", "errorlog", "-"), sys.stderr)
 
     if use_threads:
         try:
--- a/tests/test-serve
+++ b/tests/test-serve
@@ -3,9 +3,15 @@
 hg init test
 cd test
 
+echo '[web]' > .hg/hgrc
+echo 'accesslog = access.log' >> .hg/hgrc
+
 echo % Without -v
 hg serve -a localhost -p 20063 -d --pid-file=hg.pid
 cat hg.pid >> "$DAEMON_PIDS"
+if [ -f access.log ]; then
+    echo 'access log created - .hg/hgrc respected'
+fi
 
 echo % With -v
 hg serve -a localhost -p 20064 -d --pid-file=hg.pid -v
--- a/tests/test-serve.out
+++ b/tests/test-serve.out
@@ -1,3 +1,4 @@
 % Without -v
+access log created - .hg/hgrc respected
 % With -v
 listening at http://localhost:20064/