On Sun, 26 Feb 2017 23:09:59 -0500, Matt Harbison wrote: > On Sun, 26 Feb 2017 08:28:01 -0500, Yuya Nishihara <y...@tcha.org> wrote: > > This is a dirty hack to make hgwebdir serve a repo at '/'. > > > > diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py > > --- a/mercurial/hgweb/hgweb_mod.py > > +++ b/mercurial/hgweb/hgweb_mod.py > > @@ -335,7 +335,7 @@ class hgweb(object): > > req.url = req.env['SCRIPT_NAME'] > > if not req.url.endswith('/'): > > req.url += '/' > > - if 'REPO_NAME' in req.env: > > + if req.env.get('REPO_NAME'): > > req.url += req.env['REPO_NAME'] + '/' > > if 'PATH_INFO' in req.env: > > 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 > > @@ -254,18 +254,19 @@ class hgwebdir(object): > > return [] > > # top-level index > > - elif not virtual: > > + elif False: > > req.respond(HTTP_OK, ctype) > > return self.makeindex(req, tmpl) > > # nested indexes and hgwebs > > repos = dict(self.repos) > > - virtualrepo = virtual > > - while virtualrepo: > > - real = repos.get(virtualrepo) > > + # XXX dirty hack to handle ''. IIRC, we have a helper > > function > > + virtualrepo = '/' + virtual > > + while True: > > + real = repos.get(virtualrepo[1:]) > > if real: > > - req.env['REPO_NAME'] = virtualrepo > > + req.env['REPO_NAME'] = virtualrepo[1:] > > try: > > # ensure caller gets private copy of ui > > repo = hg.repository(self.ui.copy(), real) > > Oh, nice! Thanks for this. > > Can you clarify what you mean by the hack?
I wrote that code without thinking an edge case nor what would be the best way. That's all. > It seems like adding '/' to > paths isn't all that uncommon (especially in subrepo code), and the > closest I could find to a helper for removing '/' is > hgwebdir_mod.cleannames(). But that takes a list and also does a > util.pconvert(). Ok, found it. What I had in mind was util.finddirs(), which requires the first '/' though. > Just a couple lines above this, 'virtual' is cleaned up with > string.strip('/'). (That's interesting, because then I can't see how the > "virtual.startswith('static/')" tests can ever be true. It looks like > this was papered over in 74f65f44a9aa?) 'virtual/foo', maybe. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel