comparison mercurial/cmdutil.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 e6eb86b154c5
children 3eceeede26e9
comparison
equal deleted inserted replaced
32004:bd3cb917761a 32005:2406dbba49bd
2288 if not opts.get('dry_run'): 2288 if not opts.get('dry_run'):
2289 rejected = wctx.add(names, prefix) 2289 rejected = wctx.add(names, prefix)
2290 bad.extend(f for f in rejected if f in match.files()) 2290 bad.extend(f for f in rejected if f in match.files())
2291 return bad 2291 return bad
2292 2292
2293 def addwebdirpath(repo, serverpath, webconf):
2294 webconf[serverpath] = repo.root
2295 repo.ui.debug('adding %s = %s\n' % (serverpath, repo.root))
2296
2297 for r in repo.revs('filelog("path:.hgsub")'):
2298 ctx = repo[r]
2299 for subpath in ctx.substate:
2300 ctx.sub(subpath).addwebdirpath(serverpath, webconf)
2301
2293 def forget(ui, repo, match, prefix, explicitonly): 2302 def forget(ui, repo, match, prefix, explicitonly):
2294 join = lambda f: os.path.join(prefix, f) 2303 join = lambda f: os.path.join(prefix, f)
2295 bad = [] 2304 bad = []
2296 badfn = lambda x, y: bad.append(x) or match.bad(x, y) 2305 badfn = lambda x, y: bad.append(x) or match.bad(x, y)
2297 wctx = repo[None] 2306 wctx = repo[None]