# HG changeset patch # User Matt Harbison <matt_harbi...@yahoo.com> # Date 1487129917 18000 # Tue Feb 14 22:38:37 2017 -0500 # Node ID 3a0c0f139204e6fa86af22c1d54d8c1dd7a4aa2b # Parent 38babd487181374325f3d27c5bc081dadf31b9b9 serve: restore the index file for `hg serve -S`
There's currently no integration of subrepos into the browsable directory listing for the parent repo, so this is a nice to have. The redirect is only necessary for a Mercurial client. The comment in mercurial.url.opener() seems to indicate that the 'Accept' header will always be around for BC. Another option to detect a Mercurial client is to check the Request URI for the capabilities command. 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 @@ -255,10 +255,11 @@ staticfile(static, fname, req) return [] - # top-level index + # top-level index, or HTTP_MOVED_PERMANENTLY for a Mercurial client + # when the server is invoked with --subrepos. elif not virtual: - if self._rootrepo: - # Redirect '/' to the main repo when -S is given. + accept = req.env.get('HTTP_ACCEPT', "") + if self._rootrepo and accept == 'application/mercurial-0.1': path = '/' + self._rootrepo if self.prefix: path = '/' + self.prefix + path diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t --- a/tests/test-subrepo-recursion.t +++ b/tests/test-subrepo-recursion.t @@ -295,6 +295,10 @@ z2 z3 + $ wget -q http://localhost:$HGPORT + $ cat index.html | grep '<title>' + <title>Mercurial repositories index</title> + $ cat access.log * "GET /?cmd=capabilities HTTP/1.1" 301 - (glob) * "GET /repo HTTP/1.1" 200 - (glob) @@ -308,9 +312,10 @@ * "GET /repo/foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob) * "GET /repo/foo/bar?cmd=batch HTTP/1.1" 200 - * (glob) * "GET /repo/foo/bar?cmd=getbundle HTTP/1.1" 200 - * (glob) + * "GET / HTTP/1.0" 200 - (glob) $ killdaemons.py - $ rm hg1.pid error.log access.log + $ rm hg1.pid error.log access.log index.html $ cd repo #endif _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel