changeset 4835: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	Sat May 12 00:41:30 2007 +0200
+++ b/mercurial/commands.py	Wed Jul 11 19:56:16 2007 -0300
@@ -2457,6 +2457,8 @@
     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	Sat May 12 00:41:30 2007 +0200
+++ b/mercurial/hgweb/server.py	Wed Jul 11 19:56:16 2007 -0300
@@ -172,12 +172,12 @@
             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	Sat May 12 00:41:30 2007 +0200
+++ b/tests/test-serve	Wed Jul 11 19:56:16 2007 -0300
@@ -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	Sat May 12 00:41:30 2007 +0200
+++ b/tests/test-serve.out	Wed Jul 11 19:56:16 2007 -0300
@@ -1,3 +1,4 @@
 % Without -v
+access log created - .hg/hgrc respected
 % With -v
 listening at http://localhost:20064/