Show More
@@ -240,7 +240,9 b' class notifier(object):' | |||||
240 | difflines = self.ui.popbuffer().splitlines(1) |
|
240 | difflines = self.ui.popbuffer().splitlines(1) | |
241 | if self.ui.configbool('notify', 'diffstat', True): |
|
241 | if self.ui.configbool('notify', 'diffstat', True): | |
242 | s = patch.diffstat(difflines) |
|
242 | s = patch.diffstat(difflines) | |
243 | self.ui.write('\ndiffstat:\n\n' + s) |
|
243 | # s may be nil, don't include the header if it is | |
|
244 | if s: | |||
|
245 | self.ui.write('\ndiffstat:\n\n%s' % s) | |||
244 | if maxdiff > 0 and len(difflines) > maxdiff: |
|
246 | if maxdiff > 0 and len(difflines) > maxdiff: | |
245 | self.ui.write(_('\ndiffs (truncated from %d to %d lines):\n\n') % |
|
247 | self.ui.write(_('\ndiffs (truncated from %d to %d lines):\n\n') % | |
246 | (len(difflines), maxdiff)) |
|
248 | (len(difflines), maxdiff)) |
@@ -2298,11 +2298,12 b' def serve(ui, repo, **opts):' | |||||
2298 | s = sshserver.sshserver(ui, repo) |
|
2298 | s = sshserver.sshserver(ui, repo) | |
2299 | s.serve_forever() |
|
2299 | s.serve_forever() | |
2300 |
|
2300 | |||
|
2301 | parentui = ui.parentui or ui | |||
2301 | optlist = ("name templates style address port ipv6" |
|
2302 | optlist = ("name templates style address port ipv6" | |
2302 | " accesslog errorlog webdir_conf") |
|
2303 | " accesslog errorlog webdir_conf") | |
2303 | for o in optlist.split(): |
|
2304 | for o in optlist.split(): | |
2304 | if opts[o]: |
|
2305 | if opts[o]: | |
2305 | ui.setconfig("web", o, str(opts[o])) |
|
2306 | parentui.setconfig("web", o, str(opts[o])) | |
2306 |
|
2307 | |||
2307 | if repo is None and not ui.config("web", "webdir_conf"): |
|
2308 | if repo is None and not ui.config("web", "webdir_conf"): | |
2308 | raise hg.RepoError(_("There is no Mercurial repository here" |
|
2309 | raise hg.RepoError(_("There is no Mercurial repository here" | |
@@ -2318,7 +2319,7 b' def serve(ui, repo, **opts):' | |||||
2318 | os.read(rfd, 1) |
|
2319 | os.read(rfd, 1) | |
2319 | os._exit(0) |
|
2320 | os._exit(0) | |
2320 |
|
2321 | |||
2321 | httpd = hgweb.server.create_server(ui, repo) |
|
2322 | httpd = hgweb.server.create_server(parentui, repo) | |
2322 |
|
2323 | |||
2323 | if ui.verbose: |
|
2324 | if ui.verbose: | |
2324 | if httpd.port != 80: |
|
2325 | if httpd.port != 80: |
@@ -389,7 +389,7 b' class dirstate(object):' | |||||
389 |
|
389 | |||
390 | # self.root may end with a path separator when self.root == '/' |
|
390 | # self.root may end with a path separator when self.root == '/' | |
391 | common_prefix_len = len(self.root) |
|
391 | common_prefix_len = len(self.root) | |
392 |
if not self.root.endswith( |
|
392 | if not self.root.endswith(os.sep): | |
393 | common_prefix_len += 1 |
|
393 | common_prefix_len += 1 | |
394 | # recursion free walker, faster than os.walk. |
|
394 | # recursion free walker, faster than os.walk. | |
395 | def findfiles(s): |
|
395 | def findfiles(s): |
@@ -55,6 +55,7 b' repo_setup_hooks = []' | |||||
55 | def repository(ui, path='', create=False): |
|
55 | def repository(ui, path='', create=False): | |
56 | """return a repository object for the specified path""" |
|
56 | """return a repository object for the specified path""" | |
57 | repo = _lookup(path).instance(ui, path, create) |
|
57 | repo = _lookup(path).instance(ui, path, create) | |
|
58 | ui = getattr(repo, "ui", ui) | |||
58 | for hook in repo_setup_hooks: |
|
59 | for hook in repo_setup_hooks: | |
59 | hook(ui, repo) |
|
60 | hook(ui, repo) | |
60 | return repo |
|
61 | return repo |
@@ -15,12 +15,13 b' from hgweb_mod import hgweb' | |||||
15 |
|
15 | |||
16 | # This is a stopgap |
|
16 | # This is a stopgap | |
17 | class hgwebdir(object): |
|
17 | class hgwebdir(object): | |
18 | def __init__(self, config): |
|
18 | def __init__(self, config, parentui=None): | |
19 | def cleannames(items): |
|
19 | def cleannames(items): | |
20 | return [(name.strip(os.sep), path) for name, path in items] |
|
20 | return [(name.strip(os.sep), path) for name, path in items] | |
21 |
|
21 | |||
22 |
self. |
|
22 | self.parentui = parentui | |
23 |
self. |
|
23 | self.motd = None | |
|
24 | self.style = None | |||
24 | self.repos_sorted = ('name', False) |
|
25 | self.repos_sorted = ('name', False) | |
25 | if isinstance(config, (list, tuple)): |
|
26 | if isinstance(config, (list, tuple)): | |
26 | self.repos = cleannames(config) |
|
27 | self.repos = cleannames(config) | |
@@ -73,13 +74,23 b' class hgwebdir(object):' | |||||
73 | yield tmpl("footer", **map) |
|
74 | yield tmpl("footer", **map) | |
74 |
|
75 | |||
75 | def motd(**map): |
|
76 | def motd(**map): | |
76 |
|
|
77 | if self.motd is not None: | |
|
78 | yield self.motd | |||
|
79 | else: | |||
|
80 | yield config('web', 'motd', '') | |||
|
81 | ||||
|
82 | parentui = self.parentui or ui.ui(report_untrusted=False) | |||
|
83 | ||||
|
84 | def config(section, name, default=None, untrusted=True): | |||
|
85 | return parentui.config(section, name, default, untrusted) | |||
77 |
|
86 | |||
78 | url = req.env['REQUEST_URI'].split('?')[0] |
|
87 | url = req.env['REQUEST_URI'].split('?')[0] | |
79 | if not url.endswith('/'): |
|
88 | if not url.endswith('/'): | |
80 | url += '/' |
|
89 | url += '/' | |
81 |
|
90 | |||
82 | style = self.style |
|
91 | style = self.style | |
|
92 | if style is None: | |||
|
93 | style = config('web', 'style', '') | |||
83 | if req.form.has_key('style'): |
|
94 | if req.form.has_key('style'): | |
84 | style = req.form['style'][0] |
|
95 | style = req.form['style'][0] | |
85 | mapfile = style_map(templater.templatepath(), style) |
|
96 | mapfile = style_map(templater.templatepath(), style) | |
@@ -113,7 +124,7 b' class hgwebdir(object):' | |||||
113 | rows = [] |
|
124 | rows = [] | |
114 | parity = 0 |
|
125 | parity = 0 | |
115 | for name, path in self.repos: |
|
126 | for name, path in self.repos: | |
116 |
u = ui.ui( |
|
127 | u = ui.ui(parentui=parentui) | |
117 | try: |
|
128 | try: | |
118 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) |
|
129 | u.readconfig(os.path.join(path, '.hg', 'hgrc')) | |
119 | except IOError: |
|
130 | except IOError: | |
@@ -181,7 +192,8 b' class hgwebdir(object):' | |||||
181 | if real: |
|
192 | if real: | |
182 | req.env['REPO_NAME'] = virtual |
|
193 | req.env['REPO_NAME'] = virtual | |
183 | try: |
|
194 | try: | |
184 | hgweb(real).run_wsgi(req) |
|
195 | repo = hg.repository(parentui, real) | |
|
196 | hgweb(repo).run_wsgi(req) | |||
185 | except IOError, inst: |
|
197 | except IOError, inst: | |
186 | req.write(tmpl("error", error=inst.strerror)) |
|
198 | req.write(tmpl("error", error=inst.strerror)) | |
187 | except hg.RepoError, inst: |
|
199 | except hg.RepoError, inst: |
@@ -220,7 +220,7 b' def create_server(ui, repo):' | |||||
220 |
|
220 | |||
221 | def make_handler(self): |
|
221 | def make_handler(self): | |
222 | if self.webdir_conf: |
|
222 | if self.webdir_conf: | |
223 | hgwebobj = self.webdirmaker(self.webdir_conf) |
|
223 | hgwebobj = self.webdirmaker(self.webdir_conf, ui) | |
224 | elif self.repo is not None: |
|
224 | elif self.repo is not None: | |
225 | hgwebobj = self.repoviewmaker(repo.__class__(repo.ui, |
|
225 | hgwebobj = self.repoviewmaker(repo.__class__(repo.ui, | |
226 | repo.origroot)) |
|
226 | repo.origroot)) |
@@ -9,8 +9,10 b'' | |||||
9 | # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side |
|
9 | # http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side | |
10 |
|
10 | |||
11 | import os, sys |
|
11 | import os, sys | |
|
12 | from mercurial import util | |||
12 |
|
13 | |||
13 | def launch(application): |
|
14 | def launch(application): | |
|
15 | util.set_binary(sys.stdout) | |||
14 |
|
16 | |||
15 | environ = dict(os.environ.items()) |
|
17 | environ = dict(os.environ.items()) | |
16 | environ['wsgi.input'] = sys.stdin |
|
18 | environ['wsgi.input'] = sys.stdin |
@@ -7,9 +7,12 b' from mercurial import commands' | |||||
7 |
|
7 | |||
8 | def uisetup(ui): |
|
8 | def uisetup(ui): | |
9 | ui.write("uisetup called\\n") |
|
9 | ui.write("uisetup called\\n") | |
|
10 | ui.write("ui.parentui is%s None\\n" % (ui.parentui is not None | |||
|
11 | and "not" or "")) | |||
10 |
|
12 | |||
11 | def reposetup(ui, repo): |
|
13 | def reposetup(ui, repo): | |
12 | ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) |
|
14 | ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) | |
|
15 | ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) | |||
13 |
|
16 | |||
14 | def foo(ui, *args, **kwargs): |
|
17 | def foo(ui, *args, **kwargs): | |
15 | ui.write("Foo\\n") |
|
18 | ui.write("Foo\\n") |
@@ -1,9 +1,15 b'' | |||||
1 | uisetup called |
|
1 | uisetup called | |
|
2 | ui.parentui is None | |||
2 | reposetup called for a |
|
3 | reposetup called for a | |
|
4 | ui == repo.ui | |||
3 | Foo |
|
5 | Foo | |
4 | uisetup called |
|
6 | uisetup called | |
|
7 | ui.parentui is None | |||
5 | reposetup called for a |
|
8 | reposetup called for a | |
|
9 | ui == repo.ui | |||
6 | reposetup called for b |
|
10 | reposetup called for b | |
|
11 | ui == repo.ui | |||
7 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
12 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
8 | uisetup called |
|
13 | uisetup called | |
|
14 | ui.parentui is None | |||
9 | Bar |
|
15 | Bar |
General Comments 0
You need to be logged in to leave comments.
Login now