@@ -85,9 +85,9 @@
def run(self):
self.httpd.serve_forever()
-def createapp(baseui, repo, webconf):
+def createapp(baseui, repo, webconf, subrepos=False):
if webconf:
- return hgwebdir_mod.hgwebdir(webconf, baseui=baseui)
+ return hgwebdir_mod.hgwebdir(webconf, baseui=baseui, subrepos=subrepos)
else:
if not repo:
raise error.RepoError(_("there is no Mercurial repository"
@@ -115,12 +115,13 @@
Instances are typically used as WSGI applications.
"""
- def __init__(self, conf, baseui=None):
+ def __init__(self, conf, baseui=None, subrepos=False):
self.conf = conf
self.baseui = baseui
self.ui = None
self.lastrefresh = 0
self.motd = None
+ self._subrepos = subrepos
self.refresh()
def refresh(self):
@@ -254,7 +255,7 @@
return []
# top-level index
- elif not virtual:
+ elif not virtual and not self._subrepos:
req.respond(HTTP_OK, ctype)
return self.makeindex(req, tmpl)
@@ -262,8 +263,9 @@
repos = dict(self.repos)
virtualrepo = virtual
- while virtualrepo:
- real = repos.get(virtualrepo)
+ real = repos.get(virtualrepo)
+
+ while virtualrepo or self._subrepos:
if real:
req.env['REPO_NAME'] = virtualrepo
try:
@@ -280,6 +282,7 @@
if up < 0:
break
virtualrepo = virtualrepo[:up]
+ real = repos.get(virtualrepo)
# browse subdirectories
subdir = virtual + '/'
@@ -152,12 +152,11 @@
# message as long as webconf is None.
if repo:
webconf = dict()
- cmdutil.addwebdirpath(repo, repo.wvfs.basename(repo.root) + '/',
- webconf)
+ cmdutil.addwebdirpath(repo, "", webconf)
# The icons aren't rendered in a web browser without this.
# Unfortunately, the pages generated aren't sensitive to this
- # config, so it can't be set to something else if there's a repo
+ # config, so it can't be set to something else if there's a subrepo
# named 'static'.
if 'static' not in webconf:
baseui.setconfig('web', 'staticurl', 'static', source='serve')
@@ -173,7 +172,7 @@
for u in alluis:
u.setconfig("web", o, val, 'serve')
- app = hgweb.createapp(baseui, repo, webconf)
+ app = hgweb.createapp(baseui, repo, webconf, opts.get('subrepos'))
return hgweb.httpservice(servui, app, opts)
def createservice(ui, repo, opts):
@@ -75,29 +75,29 @@
#if serve
$ hg serve -R main --debug -S -p $HGPORT -d --pid-file=hg1.pid -E error.log -A access.log
- adding main/ = $TESTTMP/main (glob)
- adding sub1/ = $TESTTMP/main/sub1 (glob)
- adding sub2/ = $TESTTMP/main/sub1/sub2 (glob)
+ adding = $TESTTMP/main (glob)
+ adding ../sub1/ = $TESTTMP/main/sub1 (glob)
+ adding ../sub2/ = $TESTTMP/main/sub1/sub2 (glob)
listening at http://*:$HGPORT/ (bound to *:$HGPORT) (glob)
- adding main/ = $TESTTMP/main (glob)
- adding sub1/ = $TESTTMP/main/sub1 (glob)
- adding sub2/ = $TESTTMP/main/sub1/sub2 (glob)
+ adding = $TESTTMP/main (glob)
+ adding ../sub1/ = $TESTTMP/main/sub1 (glob)
+ adding ../sub2/ = $TESTTMP/main/sub1/sub2 (glob)
$ cat hg1.pid >> $DAEMON_PIDS
- $ hg clone http://localhost:$HGPORT/main httpclone --config progress.disable=True
+ $ hg clone http://localhost:$HGPORT httpclone --config progress.disable=True
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 3 changes to 3 files
updating to branch default
- cloning subrepo sub1 from http://localhost:$HGPORT/sub1
+ cloning subrepo sub1 from http://localhost:$HGPORT/../sub1
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 3 changes to 3 files
- cloning subrepo sub1/sub2 from http://localhost:$HGPORT/sub2 (glob)
+ cloning subrepo sub1/sub2 from http://localhost:$HGPORT/../sub2 (glob)
requesting all changes
adding changesets
adding manifests
@@ -106,15 +106,15 @@
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cat access.log
- * "GET /main?cmd=capabilities HTTP/1.1" 200 - (glob)
- * "GET /main?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /main?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=7f491f53a367861f47ee64a80eb997d1f341b77a&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /sub1?cmd=capabilities HTTP/1.1" 200 - (glob)
- * "GET /sub1?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /sub1?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=fc3b4ce2696f7741438c79207583768f2ce6b0dd&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /sub2?cmd=capabilities HTTP/1.1" 200 - (glob)
- * "GET /sub2?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /sub2?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=c57a0840e3badd667ef3c3ef65471609acb2ba3c&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
+ * "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=7f491f53a367861f47ee64a80eb997d1f341b77a&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /../sub1?cmd=capabilities HTTP/1.1" 200 - (glob)
+ * "GET /../sub1?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /../sub1?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=fc3b4ce2696f7741438c79207583768f2ce6b0dd&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /../sub2?cmd=capabilities HTTP/1.1" 200 - (glob)
+ * "GET /../sub2?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /../sub2?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=c57a0840e3badd667ef3c3ef65471609acb2ba3c&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
$ killdaemons.py
$ rm hg1.pid error.log access.log
@@ -254,29 +254,29 @@
#if serve
$ cd ..
$ hg serve -R repo --debug -S -p $HGPORT -d --pid-file=hg1.pid -E error.log -A access.log
- adding repo/ = $TESTTMP/repo (glob)
- adding repo/foo/ = $TESTTMP/repo/foo (glob)
- adding repo/foo/bar/ = $TESTTMP/repo/foo/bar (glob)
+ adding = $TESTTMP/repo (glob)
+ adding foo/ = $TESTTMP/repo/foo (glob)
+ adding foo/bar/ = $TESTTMP/repo/foo/bar (glob)
listening at http://*:$HGPORT/ (bound to *:$HGPORT) (glob)
- adding repo/ = $TESTTMP/repo (glob)
- adding repo/foo/ = $TESTTMP/repo/foo (glob)
- adding repo/foo/bar/ = $TESTTMP/repo/foo/bar (glob)
+ adding = $TESTTMP/repo (glob)
+ adding foo/ = $TESTTMP/repo/foo (glob)
+ adding foo/bar/ = $TESTTMP/repo/foo/bar (glob)
$ cat hg1.pid >> $DAEMON_PIDS
- $ hg clone http://localhost:$HGPORT/repo clone --config progress.disable=True
+ $ hg clone http://localhost:$HGPORT clone --config progress.disable=True
requesting all changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 5 changes to 3 files
updating to branch default
- cloning subrepo foo from http://localhost:$HGPORT/repo/foo
+ cloning subrepo foo from http://localhost:$HGPORT/foo
requesting all changes
adding changesets
adding manifests
adding file changes
added 4 changesets with 7 changes to 3 files
- cloning subrepo foo/bar from http://localhost:$HGPORT/repo/foo/bar (glob)
+ cloning subrepo foo/bar from http://localhost:$HGPORT/foo/bar (glob)
requesting all changes
adding changesets
adding manifests
@@ -290,15 +290,15 @@
z3
$ cat access.log
- * "GET /repo?cmd=capabilities HTTP/1.1" 200 - (glob)
- * "GET /repo?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /repo?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=1326fa26d0c00d2146c63b56bb6a45149d7325ac&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /repo/foo?cmd=capabilities HTTP/1.1" 200 - (glob)
- * "GET /repo/foo?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /repo/foo?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /repo/foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
- * "GET /repo/foo/bar?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
- * "GET /repo/foo/bar?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=31ecbdafd357f54b281c9bd1d681bb90de219e22&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
+ * "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=1326fa26d0c00d2146c63b56bb6a45149d7325ac&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /foo?cmd=capabilities HTTP/1.1" 200 - (glob)
+ * "GET /foo?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /foo?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=65903cebad86f1a84bd4f1134f62fa7dcb7a1c98&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /foo/bar?cmd=capabilities HTTP/1.1" 200 - (glob)
+ * "GET /foo/bar?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
+ * "GET /foo/bar?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bundlecaps=HG20%2Cbundle2%3DHG20%250Achangegroup%253D01%252C02%250Adigests%253Dmd5%252Csha1%252Csha512%250Aerror%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250Ahgtagsfnodes%250Alistkeys%250Apushkey%250Aremote-changegroup%253Dhttp%252Chttps&cg=1&common=0000000000000000000000000000000000000000&heads=31ecbdafd357f54b281c9bd1d681bb90de219e22&listkeys=phases%2Cbookmarks x-hgproto-1:0.1 0.2 comp=zstd,zlib,none,bzip2 (glob)
$ killdaemons.py
$ rm hg1.pid error.log access.log