diff --git a/contrib/hgwebdir.fcgi b/contrib/hgwebdir.fcgi --- a/contrib/hgwebdir.fcgi +++ b/contrib/hgwebdir.fcgi @@ -29,12 +29,28 @@ from flup.server.fcgi import WSGIServer # repos, collections of repos in a directory tree, or both. # # [paths] -# virtual/path = /real/path -# virtual/path = /real/path +# virtual/path1 = /real/path1 +# virtual/path2 = /real/path2 +# virtual/root = /real/root/* +# / = /real/root2/* # # [collections] # /prefix/to/strip/off = /root/of/tree/full/of/repos # +# paths example: +# +# * First two lines mount one repository into one virtual path, like +# '/real/path1' into 'virtual/path1'. +# +# * The third entry tells every mercurial repository found in +# '/real/root', recursively, should be mounted in 'virtual/root'. This +# format is preferred over the [collections] one, using absolute paths +# as configuration keys is not supported on every platform (including +# Windows). +# +# * The last entry is a special case mounting all repositories in +# '/real/root2' in the root of the virtual directory. +# # collections example: say directory tree /foo contains repos /foo/bar, # /foo/quux/baz. Give this config section: # [collections] diff --git a/hgwebdir.cgi b/hgwebdir.cgi --- a/hgwebdir.cgi +++ b/hgwebdir.cgi @@ -28,12 +28,28 @@ import mercurial.hgweb.wsgicgi as wsgicg # repos, collections of repos in a directory tree, or both. # # [paths] -# virtual/path = /real/path -# virtual/path = /real/path +# virtual/path1 = /real/path1 +# virtual/path2 = /real/path2 +# virtual/root = /real/root/* +# / = /real/root2/* # # [collections] # /prefix/to/strip/off = /root/of/tree/full/of/repos # +# paths example: +# +# * First two lines mount one repository into one virtual path, like +# '/real/path1' into 'virtual/path1'. +# +# * The third entry tells every mercurial repository found in +# '/real/root', recursively, should be mounted in 'virtual/root'. This +# format is preferred over the [collections] one, using absolute paths +# as configuration keys is not supported on every platform (including +# Windows). +# +# * The last entry is a special case mounting all repositories in +# /'real/root2' in the root of the virtual directory. +# # collections example: say directory tree /foo contains repos /foo/bar, # /foo/quux/baz. Give this config section: # [collections] diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -51,7 +51,21 @@ class hgwebdir(object): if cp.has_option('web', 'baseurl'): self._baseurl = cp.get('web', 'baseurl') if cp.has_section('paths'): - self.repos.extend(cleannames(cp.items('paths'))) + paths = cleannames(cp.items('paths')) + for prefix, root in paths: + roothead, roottail = os.path.split(root) + if roottail != '*': + self.repos.append((prefix, root)) + continue + # "foo = /bar/*" makes every subrepo of /bar/ to be + # mounted as foo/subrepo + roothead = os.path.normpath(roothead) + for path in util.walkrepos(roothead, followsym=True): + path = os.path.normpath(path) + name = util.pconvert(path[len(roothead):]).strip('/') + if prefix: + name = prefix + '/' + name + self.repos.append((name, path)) if cp.has_section('collections'): for prefix, root in cp.items('collections'): for path in util.walkrepos(root, followsym=True): diff --git a/tests/test-hgwebdir b/tests/test-hgwebdir --- a/tests/test-hgwebdir +++ b/tests/test-hgwebdir @@ -51,6 +51,7 @@ cat > paths.conf < collections.conf <