Mercurial > public > mercurial-scm > hg
comparison mercurial/server.py @ 32005:2406dbba49bd
serve: add support for Mercurial subrepositories
I've been using `hg serve --web-conf ...` with a simple '/=projects/**' [paths]
configuration for awhile without issue. Let's ditch the need for the manual
configuration in this case, and limit the repos served to the actual subrepos.
This doesn't attempt to handle the case where a new subrepo appears while the
server is running. That could probably be handled with a hook if somebody wants
it. But it's such a rare case, it probably doesn't matter for the temporary
serves.
The main repo is served at '/', just like a repository without subrepos. I'm
not sure why the duplicate 'adding ...' lines appear on Linux. They don't
appear on Windows (see 594dd384803c), so they are optional.
Subrepositories that are configured with '../path' or absolute paths are not
cloneable from the server. (They aren't cloneable locally either, unless they
also exist at their configured source, perhaps via the share extension.) They
are still served, so that they can be browsed, or cloned individually. If we
care about that cloning someday, we can probably just add the extra entries to
the webconf dictionary. Even if the entries use '../' to escape the root, only
the related subrepositories would end up in the dictionary.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 15 Apr 2017 18:05:40 -0400 |
parents | ce4ddcda868b |
children | bd872f64a8ba |
comparison
equal
deleted
inserted
replaced
32004:bd3cb917761a | 32005:2406dbba49bd |
---|---|
13 | 13 |
14 from .i18n import _ | 14 from .i18n import _ |
15 | 15 |
16 from . import ( | 16 from . import ( |
17 chgserver, | 17 chgserver, |
18 cmdutil, | |
18 commandserver, | 19 commandserver, |
19 error, | 20 error, |
20 hgweb, | 21 hgweb, |
21 util, | 22 util, |
22 ) | 23 ) |
128 alluis.update([repo.baseui, repo.ui]) | 129 alluis.update([repo.baseui, repo.ui]) |
129 else: | 130 else: |
130 baseui = ui | 131 baseui = ui |
131 webconf = opts.get('web_conf') or opts.get('webdir_conf') | 132 webconf = opts.get('web_conf') or opts.get('webdir_conf') |
132 if webconf: | 133 if webconf: |
134 if opts.get('subrepos'): | |
135 raise error.Abort(_('--web-conf cannot be used with --subrepos')) | |
136 | |
133 # load server settings (e.g. web.port) to "copied" ui, which allows | 137 # load server settings (e.g. web.port) to "copied" ui, which allows |
134 # hgwebdir to reload webconf cleanly | 138 # hgwebdir to reload webconf cleanly |
135 servui = ui.copy() | 139 servui = ui.copy() |
136 servui.readconfig(webconf, sections=['web']) | 140 servui.readconfig(webconf, sections=['web']) |
137 alluis.add(servui) | 141 alluis.add(servui) |
142 elif opts.get('subrepos'): | |
143 servui = ui | |
144 | |
145 # If repo is None, hgweb.createapp() already raises a proper abort | |
146 # message as long as webconf is None. | |
147 if repo: | |
148 webconf = dict() | |
149 cmdutil.addwebdirpath(repo, "", webconf) | |
138 else: | 150 else: |
139 servui = ui | 151 servui = ui |
140 | 152 |
141 optlist = ("name templates style address port prefix ipv6" | 153 optlist = ("name templates style address port prefix ipv6" |
142 " accesslog errorlog certificate encoding") | 154 " accesslog errorlog certificate encoding") |