changeset 4081:e6d26e71f049

merge with crew-stable
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 13 Feb 2007 10:25:45 -0200
parents 95ffa36d1d2a (current diff) ef14fdb675da (diff)
children 6b2909e84203
files hgext/notify.py mercurial/commands.py mercurial/dirstate.py mercurial/hg.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/server.py
diffstat 9 files changed, 38 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/notify.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/hgext/notify.py	Tue Feb 13 10:25:45 2007 -0200
@@ -240,7 +240,9 @@
         difflines = self.ui.popbuffer().splitlines(1)
         if self.ui.configbool('notify', 'diffstat', True):
             s = patch.diffstat(difflines)
-            self.ui.write('\ndiffstat:\n\n' + s)
+            # s may be nil, don't include the header if it is
+            if s:
+                self.ui.write('\ndiffstat:\n\n%s' % s)
         if maxdiff > 0 and len(difflines) > maxdiff:
             self.ui.write(_('\ndiffs (truncated from %d to %d lines):\n\n') %
                           (len(difflines), maxdiff))
--- a/mercurial/commands.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/commands.py	Tue Feb 13 10:25:45 2007 -0200
@@ -2298,11 +2298,12 @@
         s = sshserver.sshserver(ui, repo)
         s.serve_forever()
 
+    parentui = ui.parentui or ui
     optlist = ("name templates style address port ipv6"
                " accesslog errorlog webdir_conf")
     for o in optlist.split():
         if opts[o]:
-            ui.setconfig("web", o, str(opts[o]))
+            parentui.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"
@@ -2318,7 +2319,7 @@
         os.read(rfd, 1)
         os._exit(0)
 
-    httpd = hgweb.server.create_server(ui, repo)
+    httpd = hgweb.server.create_server(parentui, repo)
 
     if ui.verbose:
         if httpd.port != 80:
--- a/mercurial/dirstate.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/dirstate.py	Tue Feb 13 10:25:45 2007 -0200
@@ -389,7 +389,7 @@
 
         # self.root may end with a path separator when self.root == '/'
         common_prefix_len = len(self.root)
-        if not self.root.endswith('/'):
+        if not self.root.endswith(os.sep):
             common_prefix_len += 1
         # recursion free walker, faster than os.walk.
         def findfiles(s):
--- a/mercurial/hg.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/hg.py	Tue Feb 13 10:25:45 2007 -0200
@@ -55,6 +55,7 @@
 def repository(ui, path='', create=False):
     """return a repository object for the specified path"""
     repo = _lookup(path).instance(ui, path, create)
+    ui = getattr(repo, "ui", ui)
     for hook in repo_setup_hooks:
         hook(ui, repo)
     return repo
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue Feb 13 10:25:45 2007 -0200
@@ -15,12 +15,13 @@
 
 # This is a stopgap
 class hgwebdir(object):
-    def __init__(self, config):
+    def __init__(self, config, parentui=None):
         def cleannames(items):
             return [(name.strip(os.sep), path) for name, path in items]
 
-        self.motd = ""
-        self.style = ""
+        self.parentui = parentui
+        self.motd = None
+        self.style = None
         self.repos_sorted = ('name', False)
         if isinstance(config, (list, tuple)):
             self.repos = cleannames(config)
@@ -73,13 +74,23 @@
             yield tmpl("footer", **map)
 
         def motd(**map):
-            yield self.motd
+            if self.motd is not None:
+                yield self.motd
+            else:
+                yield config('web', 'motd', '')
+
+        parentui = self.parentui or ui.ui(report_untrusted=False)
+
+        def config(section, name, default=None, untrusted=True):
+            return parentui.config(section, name, default, untrusted)
 
         url = req.env['REQUEST_URI'].split('?')[0]
         if not url.endswith('/'):
             url += '/'
 
         style = self.style
+        if style is None:
+            style = config('web', 'style', '')
         if req.form.has_key('style'):
             style = req.form['style'][0]
         mapfile = style_map(templater.templatepath(), style)
@@ -113,7 +124,7 @@
             rows = []
             parity = 0
             for name, path in self.repos:
-                u = ui.ui(report_untrusted=False)
+                u = ui.ui(parentui=parentui)
                 try:
                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
                 except IOError:
@@ -181,7 +192,8 @@
             if real:
                 req.env['REPO_NAME'] = virtual
                 try:
-                    hgweb(real).run_wsgi(req)
+                    repo = hg.repository(parentui, real)
+                    hgweb(repo).run_wsgi(req)
                 except IOError, inst:
                     req.write(tmpl("error", error=inst.strerror))
                 except hg.RepoError, inst:
--- a/mercurial/hgweb/server.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/hgweb/server.py	Tue Feb 13 10:25:45 2007 -0200
@@ -220,7 +220,7 @@
 
         def make_handler(self):
             if self.webdir_conf:
-                hgwebobj = self.webdirmaker(self.webdir_conf)
+                hgwebobj = self.webdirmaker(self.webdir_conf, ui)
             elif self.repo is not None:
                 hgwebobj = self.repoviewmaker(repo.__class__(repo.ui,
                                                              repo.origroot))
--- a/mercurial/hgweb/wsgicgi.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/hgweb/wsgicgi.py	Tue Feb 13 10:25:45 2007 -0200
@@ -9,8 +9,10 @@
 # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
 
 import os, sys
+from mercurial import util
 
 def launch(application):
+    util.set_binary(sys.stdout)
 
     environ = dict(os.environ.items())
     environ['wsgi.input'] = sys.stdin
--- a/tests/test-extension	Tue Jan 02 21:40:20 2007 -0800
+++ b/tests/test-extension	Tue Feb 13 10:25:45 2007 -0200
@@ -7,9 +7,12 @@
 
 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))
+    ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
 
 def foo(ui, *args, **kwargs):
     ui.write("Foo\\n")
--- a/tests/test-extension.out	Tue Jan 02 21:40:20 2007 -0800
+++ b/tests/test-extension.out	Tue Feb 13 10:25:45 2007 -0200
@@ -1,9 +1,15 @@
 uisetup called
+ui.parentui is 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
+ui == repo.ui
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 uisetup called
+ui.parentui is None
 Bar